Expand description
Character-exact line wrapping primitives.
These back both a panel’s rendering (turning one raw line into the
wrapped rows actually shown) and its selection geometry (mapping
between logical positions and on-screen rows) — see crate::wrapcache.
Wrapping is character-exact (not word-aware): a line is broken every
width display columns, matching how a raw HTTP response body or JSON
preview is displayed.
Functions§
- wrap_
line - Wrap a (possibly multi-span, styled)
Linetowidthcolumns, breaking exactly on the character boundary and preserving each span’s style across the break.width == 0returns the line unchanged. - wrap_
line_ window - Wrap only a bounded window of a single (unstyled) line — skip
skip_rowswhole wrapped rows, then wrap at mostmax_rowsmore, without ever touching or allocating the rest of the line. Unlikewrap_line, whose cost is proportional to the entire line, this keeps cost proportional to(skip_rows + max_rows) * width— critical for panels holding one enormous raw line (e.g. a large base64 blob or minified JSON body pasted with no newlines), where re-wrapping the whole line on every redraw would grind the app to a halt regardless of how few rows are actually on screen. - wrapped_
row_ count - Number of wrapped rows a line of
char_lencharacters produces atwidthdisplay columns, matchingwrap_line’s own boundary math exactly (one row minimum, even for an empty line). Used to size the total scrollable extent and locate a scroll position without ever wrapping every line.