Skip to main content

Module cells

Module cells 

Source
Expand description

Unicode character cell width calculations.

This module provides functions to calculate the display width of text in terminal cells, handling wide characters (CJK, emoji) correctly.

Functionsยง

cell_len
Get the total cell width of a string (cached for longer strings).
cell_len_uncached
Get the total cell width of a string without caching.
cell_positions
Get the cell position for each character in a string.
cell_to_byte_index
Find the byte index for a given cell position.
chop_cells
Split a string at a cell position.
get_character_cell_size
Get the cell width of a single character.
has_wide_chars
Check if a string contains any wide (2-cell) characters.
set_cell_size
Truncate a string to fit within a maximum cell width.