(active bool, cfg *config.Config, configPath, version string)
| 64 | } |
| 65 | |
| 66 | func (v *SettingsView) Render(active bool, cfg *config.Config, configPath, version string) string { |
| 67 | headerFocused := active && v.ActiveSection == SettingsSectionHeader |
| 68 | contentFocused := active && v.ActiveSection == SettingsSectionContent |
| 69 | |
| 70 | contentBorderColor := colorDarkGray |
| 71 | if contentFocused { |
| 72 | contentBorderColor = colorGreen |
| 73 | } |
| 74 | |
| 75 | // Pass 1: render fixed-height sections (header and help). |
| 76 | |
| 77 | headerStr := renderNavHeader("Settings", headerFocused, active, version, v.Width) |
| 78 | |
| 79 | var helpText string |
| 80 | switch v.ActiveSection { |
| 81 | case SettingsSectionHeader: |
| 82 | helpText = styleHelpKey("[↔]") + " Switch " + styleHelpKey("[↓]") + " Content " + styleHelpKey("[Esc]") + " Quit" |
| 83 | case SettingsSectionContent: |
| 84 | helpText = styleHelpKey("[↑]") + " Header " + styleHelpKey("[Esc]") + " Quit" |
| 85 | } |
| 86 | helpTitle := lipgloss.NewStyle().Foreground(colorDarkGray).Render("Help") |
| 87 | helpStr := boxWithTitle(helpTitle, helpText, colorDarkGray, v.Width) |
| 88 | |
| 89 | // Content section gets whatever's left. strings.Join("\n") does not add |
| 90 | // extra lines beyond the sum of each section's lineCount. |
| 91 | fixedLines := lineCount(headerStr) + lineCount(helpStr) |
| 92 | contentMinHeight := v.Height - fixedLines |
| 93 | if contentMinHeight < 3 { |
| 94 | contentMinHeight = 3 |
| 95 | } |
| 96 | |
| 97 | // Pass 2: build content lines and render with min height. |
| 98 | var contentLines []string |
| 99 | contentLines = append(contentLines, "") |
| 100 | contentLines = append(contentLines, lipgloss.NewStyle().Foreground(colorYellow).Bold(true).Render("Configuration")) |
| 101 | contentLines = append(contentLines, "") |
| 102 | |
| 103 | if cfg != nil { |
| 104 | maskedKey := "Not set" |
| 105 | if cfg.APIKey != nil { |
| 106 | key := *cfg.APIKey |
| 107 | if len(key) > 12 { |
| 108 | maskedKey = key[:8] + "..." + key[len(key)-4:] |
| 109 | } else { |
| 110 | maskedKey = "****" |
| 111 | } |
| 112 | } |
| 113 | contentLines = append(contentLines, |
| 114 | lipgloss.NewStyle().Foreground(colorCyan).Render("CLI ID: ")+ |
| 115 | lipgloss.NewStyle().Foreground(colorWhite).Render(cfg.CliID)) |
| 116 | contentLines = append(contentLines, "") |
| 117 | contentLines = append(contentLines, |
| 118 | lipgloss.NewStyle().Foreground(colorCyan).Render("API Key: ")+ |
| 119 | lipgloss.NewStyle().Foreground(colorWhite).Render(maskedKey)) |
| 120 | contentLines = append(contentLines, "") |
| 121 | contentLines = append(contentLines, |
| 122 | lipgloss.NewStyle().Foreground(colorCyan).Render("Config Path: ")+ |
| 123 | lipgloss.NewStyle().Foreground(colorWhite).Render(configPath)) |
nothing calls this directly
no test coverage detected