Raxol.UI.Components.Input.TextWrapping (Raxol v2.6.1)

View Source

Utility functions for text wrapping.

width is always a DISPLAY-COLUMN budget, never a grapheme count. These two are equal only for ASCII: a CJK ideograph or emoji is one grapheme and two columns, so counting graphemes against a column budget overflows the line by up to 2x. Measurement goes through Raxol.UI.TextMeasure, the repo-wide facade (see its "three units" note).

Summary

Functions

Wraps a single line of text to a display-column budget.

Wraps a single line of text by word boundaries.

Functions

wrap_line_by_char(line, width)

Wraps a single line of text to a display-column budget.

Chunks are cut on grapheme-cluster boundaries and never exceed width display columns. A cluster wider than the whole budget is emitted alone on its own line rather than being split in half.

wrap_line_by_word(line, width)

Wraps a single line of text by word boundaries.