Skip to main content

Module width

Module width 

Source
Expand description

How many terminal columns a glyph occupies.

Every renderer measures cells through this one function, so a hidden cell reserves exactly as many columns as the glyph will need once it appears. That is what keeps a row from shifting sideways as the reveal crosses a wide glyph.

Functionsยง

glyph_cols
Display columns a glyph occupies: 0 for zero-width and combining marks, 2 for wide glyphs (CJK and many emoji), 1 otherwise.
sanitize
Replace control characters with spaces.
str_cols
Total display columns of a string.
truncate_to_cols
Truncate s to at most max display columns, dropping whole glyphs so a wide glyph is never split across the edge.