Expand description
Layout engine. Takes a list of Segments plus a StatusContext and
fits their renders into a terminal-width budget, dropping the
highest-priority (numerically largest) segments first — or, when a
segment opts in via truncatable, shrinking it to fit before drop.
Priority-0 segments are never dropped or truncated, even when that
overflows the budget.
See docs/specs/segment-system.md §Layout algorithm.
Functions§
- render
- Render
segmentsforctxwithinterminal_widthcells. Returns the final line without a trailing newline. Segment render errors go throughcrate::lsm_error!so a broken segment always surfaces, even underLINESMITH_LOG=off— a blank statusline with zero diagnostic is a bad UX even when the user opted into quiet mode. Output is unstyled (callers that want theming userender_with_warnwith their own closure). - render_
to_ runs - Render
segmentsinto a flatStyledRunsequence. One run per surviving segment, plus one run per non-empty inter-segment separator (in render order). Layout decisions — priority-drop,shrink_to_fit, truncatable reflow, width-bound truncation — matchrender/render_with_warnexactly; only the emit form differs. - render_
with_ warn - Same as
renderbut routes segment render-error diagnostics throughwarnand emits ANSI SGR around each segment perthemeandcapability. Used bycrate::run_with_contextsocli_maintests can capture segment errors alongside exit codes while the render path picks up theme colors. - runs_
to_ ansi - Emit a flat
StyledRunsequence as an ANSI SGR-wrapped string suitable for terminal stdout. Each run with non-empty styling gets its ownsgr_open/sgr_resetpair so decorations don’t leak across boundaries; plain runs pass through unwrapped. Whenhyperlinksistrue, runs carryingStyle.hyperlinkare additionally wrapped in OSC 8 open/close so capable terminals render them as clickable links; the OSC 8 wrap sits outside the SGR pair so the link survives the SGR reset.hyperlinks = falsedrops the URL silently — the run still emits, just without the link.