(active bool)
| 870 | } |
| 871 | |
| 872 | func (v *PricingView) renderCommand(active bool) string { |
| 873 | cmdActive := active && v.ActiveSection == PricingSectionCommand |
| 874 | isFocused := cmdActive && v.BuilderFocus == BuilderFocusField |
| 875 | borderColor := colorDarkGray |
| 876 | if isFocused { |
| 877 | borderColor = colorGreen |
| 878 | } else if cmdActive { |
| 879 | borderColor = colorCyan |
| 880 | } |
| 881 | |
| 882 | fieldNames := []string{"products", "regions", "specs", "price"} |
| 883 | var parts []string |
| 884 | for i, name := range fieldNames { |
| 885 | var tags []string |
| 886 | switch i { |
| 887 | case 0: |
| 888 | tags = v.CommandBuilder.ProductTags |
| 889 | case 1: |
| 890 | tags = v.CommandBuilder.RegionTags |
| 891 | case 2: |
| 892 | tags = v.CommandBuilder.AttributeTags |
| 893 | default: |
| 894 | tags = v.CommandBuilder.PriceTags |
| 895 | } |
| 896 | isSel := isFocused && i == v.CommandBuilder.SelectedField |
| 897 | |
| 898 | var s string |
| 899 | if isSel { |
| 900 | s = lipgloss.NewStyle().Foreground(colorYellow).Bold(true).Render(name + " ") |
| 901 | } else if len(tags) > 0 { |
| 902 | s = lipgloss.NewStyle().Foreground(colorCyan).Render(name + " ") |
| 903 | } else { |
| 904 | s = lipgloss.NewStyle().Foreground(colorDarkGray).Render(name + " ") |
| 905 | } |
| 906 | for _, t := range tags { |
| 907 | s += lipgloss.NewStyle().Foreground(colorGreen).Render("["+t+"]") + " " |
| 908 | } |
| 909 | if isSel { |
| 910 | if v.CommandBuilder.SearchInput != "" { |
| 911 | s += lipgloss.NewStyle().Foreground(colorWhite).Render(v.CommandBuilder.SearchInput) |
| 912 | } |
| 913 | s += lipgloss.NewStyle().Foreground(colorCyan).Render("▌") |
| 914 | } |
| 915 | if i < 3 { |
| 916 | s += lipgloss.NewStyle().Foreground(colorDarkGray).Render(" │ ") |
| 917 | } |
| 918 | parts = append(parts, s) |
| 919 | } |
| 920 | |
| 921 | rawTitle := "Pricing Query" |
| 922 | if cmdActive { |
| 923 | rawTitle = "> Pricing Query" |
| 924 | } |
| 925 | styledTitle := lipgloss.NewStyle().Foreground(borderColor).Render(rawTitle) |
| 926 | return boxWithTitle(styledTitle, strings.Join(parts, ""), borderColor, v.Width) |
| 927 | } |
| 928 | |
| 929 | func (v *PricingView) suggestionCols() int { |
no test coverage detected