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§

ASCII_ELLIPSIS
The mark that stands for ELLIPSIS in ASCII glyph mode.
ELLIPSIS
The ellipsis drawn where text is cut.

Functions§

grapheme_width
Display width of one grapheme cluster.
printable
One line written for a terminal, as the terminal would leave it on screen: what a carriage return wrote over is gone, colour and cursor sequences are taken out, a tab becomes spaces up to the next stop of eight and no other control character is left.
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.