Documentation
¶
Overview ¶
Package layout provides terminal-aware text layout primitives. It owns: visual width measurement, ANSI-transparent wrapping, and value column detection. It has no I/O and no terminal detection — those are the caller's responsibility.
Index ¶
Constants ¶
const ( // FramePrefix is the visible column width of the section row prefix " │ ". // Used by callers computing a content budget from terminal width. FramePrefix = 6 // DefaultContentWidth is the fallback content budget when terminal width // cannot be detected (CI pipes, file output, etc.). // 120 is a safe width for CI log viewers and wide terminals. DefaultContentWidth = 120 )
Variables ¶
This section is empty.
Functions ¶
func DetectValueIndent ¶
DetectValueIndent returns the column position where the value starts in a formatted row string — immediately after the first padding gap of 2+ spaces that follows non-space content. Used to align continuation lines.
For "key value..." this returns the position of 'v' (e.g. 16). Returns 0 if no gap is found.
func VisualWidth ¶
VisualWidth returns the visible column width of s. ANSI escape sequences contribute zero width; wide characters (emoji, CJK) are counted at their actual terminal column width via go-runewidth.
func WrapContent ¶
WrapContent wraps line at word boundaries so each segment fits within budget visible columns. ANSI escape sequences are transparent (zero visual width); emoji and other wide characters are measured at their true terminal width.
Wrap pattern:
first line: "key value value value" continuation: " value value value"
Continuation lines are indented to the value column — the position after the first padding gap (2+ spaces) that follows key content.
The "..." ellipsis is used ONLY for hard mid-token cuts (no word boundary available). Word-boundary wraps are clean — no decoration.
Types ¶
This section is empty.