boxWithTitle renders content in a rounded-border box whose title is embedded in the top border line: ╭─ Title ─────────────────────────────╮ │ content │ ╰──────────────────────────────────────╯ styledTitle may contain ANSI escape codes; pass "" for a plain box. tota
(styledTitle string, content string, borderColor lipgloss.Color, totalWidth int)
| 40 | // styledTitle may contain ANSI escape codes; pass "" for a plain box. |
| 41 | // totalWidth is the full rendered width including the border characters. |
| 42 | func boxWithTitle(styledTitle string, content string, borderColor lipgloss.Color, totalWidth int) string { |
| 43 | style := lipgloss.NewStyle(). |
| 44 | Border(lipgloss.RoundedBorder()). |
| 45 | BorderForeground(borderColor). |
| 46 | Width(totalWidth - 2) |
| 47 | rendered := style.Render(content) |
| 48 | if styledTitle == "" { |
| 49 | return rendered |
| 50 | } |
| 51 | return injectBorderTitle(rendered, styledTitle, lipgloss.Width(styledTitle), borderColor) |
| 52 | } |
| 53 | |
| 54 | // boxWithTitleMinHeight is like boxWithTitle but forces the box to be at least |
| 55 | // minHeight terminal lines tall (including the two border lines). Content |
no test coverage detected