Skip to main content

Module wrap

Module wrap 

Source
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 wordwrap and wrap: hyphen, comma, period, semicolon, colon, and space ("-,.;: ").

Functions§

hardwrap
Hard-wrap s so no visible line exceeds limit columns.
hardwrap_mode
Width-mode variant of hardwrap.
wordwrap
Word-wrap s at breakpoints so visible lines fit within limit where possible.
wordwrap_mode
Width-mode variant of wordwrap.
wrap
Soft-wrap s at word breakpoints, then hard-wrap any remaining overlong line.
wrap_mode
Width-mode variant of wrap.