MCPcopy Create free account
hub / github.com/OverloadBlitz/cloudcent-cli / boxWithTitleMinHeight

Function boxWithTitleMinHeight

internal/tui/views/utils.go:57–72  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

55// minHeight terminal lines tall (including the two border lines). Content
56// shorter than minHeight-2 is padded with blank lines by lipgloss.
57func 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.

Callers 4

renderResultsMethod · 0.85
RenderMethod · 0.85
RenderMethod · 0.85
RenderMethod · 0.85

Calls 2

injectBorderTitleFunction · 0.85
RenderMethod · 0.45

Tested by

no test coverage detected