Skip to main content

Module text

Module text 

Source
Expand description

Measuring text in terminal cells: width, truncation with an ellipsis at the end or in the middle, and word wrapping.

Constants§

ELLIPSIS
The ellipsis drawn where text is cut.

Functions§

grapheme_width
Display width of one grapheme cluster.
truncate
text cut to at most max cells, ending in when anything was removed.
truncate_middle
text cut to at most max cells by removing its middle, with where the middle was.
width
Display width of text in cells.
wrap
Splits text into lines no wider than max cells.
wrap_ranges
Like wrap, but returns byte ranges into text, so styled text can be wrapped and drawn with its styles.