Skip to main content

Module text

Module text 

Source
Expand description

Single-line column-clipping, unicode-width aware.

For word-wrapping multi-line text, see retroglyph_core::layout::TextLayout (behind the egc feature) rather than reimplementing wrapping here: it already handles grapheme clusters, hard newlines, and per-span styling.

Functions§

draw_clipped
Truncate text to width columns, align it within those columns per align, and print it into surface at at. Returns the printed text’s display width in columns.
truncate
Truncate s so its display width is at most max_cols terminal columns.
truncate_owned
Owned variant of truncate: truncate s to max_cols display columns and copy the surviving prefix into a new String.