MCPcopy Create free account
hub / github.com/OverloadBlitz/cloudcent-cli / renderSuggestions

Method renderSuggestions

internal/tui/views/pricing.go:961–1063  ·  view source on GitHub ↗
(active bool)

Source from the content-addressed store, hash-verified

959}
960
961func (v *PricingView) renderSuggestions(active bool) string {
962 cmdActive := active && v.ActiveSection == PricingSectionCommand
963 suggFocused := cmdActive && v.BuilderFocus == BuilderFocusSuggestions
964
965 borderColor := colorDarkGray
966 if suggFocused {
967 borderColor = colorGreen
968 } else if cmdActive {
969 borderColor = colorCyan
970 }
971
972 // Build border title: highlighted field tabs + count + hint
973 fieldNames := []string{"products", "regions", "specs", "price"}
974 var tabParts []string
975 for i, name := range fieldNames {
976 if i == v.CommandBuilder.SelectedField && cmdActive {
977 tabParts = append(tabParts, lipgloss.NewStyle().
978 Foreground(colorBlack).Background(colorGreen).Bold(true).
979 Render(" "+name+" "))
980 } else {
981 tabParts = append(tabParts, lipgloss.NewStyle().Foreground(colorDarkGray).Render(name))
982 }
983 }
984 sep := lipgloss.NewStyle().Foreground(colorDarkGray).Render(" | ")
985 tabsStr := strings.Join(tabParts, sep)
986 hintStr := lipgloss.NewStyle().Foreground(colorDarkGray).
987 Render(fmt.Sprintf(" (%d) [Tab Complete · ↓ Browse]", len(v.SuggestionsCache)))
988 styledTitle := tabsStr + hintStr
989
990 if len(v.SuggestionsCache) == 0 {
991 msg := "(No matches)"
992 if v.Options == nil {
993 msg = "(Sync metadata to see suggestions)"
994 }
995 return boxWithTitle(styledTitle,
996 lipgloss.NewStyle().Foreground(colorDarkGray).Italic(true).Render(msg),
997 borderColor, v.Width)
998 }
999
1000 cols := v.suggestionCols()
1001 innerH := 4 // show ~4 rows max
1002
1003 // Compute total rows in the suggestion grid.
1004 totalRows := (len(v.SuggestionsCache) + cols - 1) / cols
1005
1006 // Ensure the selected item's row is visible by adjusting SuggestionScroll.
1007 if v.SuggestionIndex >= 0 {
1008 selRow := v.SuggestionIndex / cols
1009 if selRow < v.SuggestionScroll {
1010 v.SuggestionScroll = selRow
1011 }
1012 if selRow >= v.SuggestionScroll+innerH {
1013 v.SuggestionScroll = selRow - innerH + 1
1014 }
1015 }
1016 if v.SuggestionScroll > totalRows-innerH {
1017 v.SuggestionScroll = totalRows - innerH
1018 }

Callers 1

RenderMethod · 0.95

Calls 3

suggestionColsMethod · 0.95
boxWithTitleFunction · 0.85
RenderMethod · 0.45

Tested by

no test coverage detected