boxWithTitleMinHeight is like boxWithTitle but forces the box to be at least minHeight terminal lines tall (including the two border lines). Content shorter than minHeight-2 is padded with blank lines by lipgloss.
(styledTitle string, content string, borderColor lipgloss.Color, totalWidth, minHeight int)
| 55 | // minHeight terminal lines tall (including the two border lines). Content |
| 56 | // shorter than minHeight-2 is padded with blank lines by lipgloss. |
| 57 | func boxWithTitleMinHeight(styledTitle string, content string, borderColor lipgloss.Color, totalWidth, minHeight int) string { |
| 58 | innerH := minHeight - 2 |
| 59 | if innerH < 1 { |
| 60 | innerH = 1 |
| 61 | } |
| 62 | style := lipgloss.NewStyle(). |
| 63 | Border(lipgloss.RoundedBorder()). |
| 64 | BorderForeground(borderColor). |
| 65 | Width(totalWidth - 2). |
| 66 | Height(innerH) |
| 67 | rendered := style.Render(content) |
| 68 | if styledTitle == "" { |
| 69 | return rendered |
| 70 | } |
| 71 | return injectBorderTitle(rendered, styledTitle, lipgloss.Width(styledTitle), borderColor) |
| 72 | } |
| 73 | |
| 74 | // injectBorderTitle replaces the first line (top border) of a lipgloss-rendered |
| 75 | // box with a new top border containing styledTitle. |
no test coverage detected