Expand description
Width-aware wrapping for ANSI-decorated strings.
§Category
Hard wrap, word wrap, and combined wrap utilities insert newlines based on terminal display columns while preserving ANSI escape sequences verbatim.
§Width conventions
Visible text width comes from crate::ansi::text::tokenize and WidthMode.
Escape tokens are zero-width and stay attached to the current word, separator,
or line segment so styling and hyperlinks survive wrapping.
§Mode interaction
Wrapping does not interpret terminal modes. It treats mode-setting and mode-dependent sequences as bytes to preserve, not as state transitions.
Constants§
- DEFAULT_
BREAKPOINTS - Default break characters for
wordwrapandwrap: hyphen, comma, period, semicolon, colon, and space ("-,.;: ").
Functions§
- hardwrap
- Hard-wrap
sso no visible line exceedslimitcolumns. - hardwrap_
mode - Width-mode variant of
hardwrap. - wordwrap
- Word-wrap
satbreakpointsso visible lines fit withinlimitwhere possible. - wordwrap_
mode - Width-mode variant of
wordwrap. - wrap
- Soft-wrap
sat word breakpoints, then hard-wrap any remaining overlong line. - wrap_
mode - Width-mode variant of
wrap.