Render renders the settings overlay.
()
| 181 | |
| 182 | // Render renders the settings overlay. |
| 183 | func (s *SettingsOverlay) Render() string { |
| 184 | modalWidth := min(60, s.width-10) |
| 185 | modalHeight := min(18, s.height-6) |
| 186 | |
| 187 | if modalWidth < 40 { |
| 188 | modalWidth = 40 |
| 189 | } |
| 190 | if modalHeight < 12 { |
| 191 | modalHeight = 12 |
| 192 | } |
| 193 | |
| 194 | var content strings.Builder |
| 195 | |
| 196 | // Header: "Settings" left-aligned, ".chief/config.yaml" right-aligned |
| 197 | titleStyle := lipgloss.NewStyle(). |
| 198 | Bold(true). |
| 199 | Foreground(PrimaryColor) |
| 200 | pathStyle := lipgloss.NewStyle(). |
| 201 | Foreground(MutedColor) |
| 202 | |
| 203 | title := titleStyle.Render("Settings") |
| 204 | path := pathStyle.Render(".chief/config.yaml") |
| 205 | titleWidth := lipgloss.Width(title) |
| 206 | pathWidth := lipgloss.Width(path) |
| 207 | titlePadding := modalWidth - 4 - titleWidth - pathWidth |
| 208 | if titlePadding < 1 { |
| 209 | titlePadding = 1 |
| 210 | } |
| 211 | content.WriteString(" ") |
| 212 | content.WriteString(title) |
| 213 | content.WriteString(strings.Repeat(" ", titlePadding)) |
| 214 | content.WriteString(path) |
| 215 | content.WriteString("\n") |
| 216 | content.WriteString(DividerStyle.Render(strings.Repeat("─", modalWidth-4))) |
| 217 | content.WriteString("\n\n") |
| 218 | |
| 219 | // GH error dialog overlay |
| 220 | if s.showGHError { |
| 221 | content.WriteString(s.renderGHError(modalWidth)) |
| 222 | } else { |
| 223 | // Render settings items grouped by section |
| 224 | content.WriteString(s.renderItems(modalWidth)) |
| 225 | } |
| 226 | |
| 227 | // Footer |
| 228 | content.WriteString("\n") |
| 229 | content.WriteString(DividerStyle.Render(strings.Repeat("─", modalWidth-4))) |
| 230 | content.WriteString("\n") |
| 231 | |
| 232 | footerStyle := lipgloss.NewStyle(). |
| 233 | Foreground(MutedColor). |
| 234 | Padding(0, 1) |
| 235 | |
| 236 | if s.showGHError { |
| 237 | content.WriteString(footerStyle.Render("Press any key to dismiss")) |
| 238 | } else if s.editing { |
| 239 | content.WriteString(footerStyle.Render("Enter: save │ Esc: cancel")) |
| 240 | } else { |