Skip to main content

Module display_width

Module display_width 

Source
Expand description

Display width calculation for Unicode text.

The single source of truth for “how many terminal columns does this text occupy”, backed by the unicode-width crate. Used for cursor positioning, line wrapping, and UI layout with CJK characters, emoji, and other double-width or zero-width characters.

This lives in fresh-core so that both the editor (layout/rendering) and the plugin runtime (the charWidth / stringWidth plugin APIs) compute width with the same logic — plugins must not re-derive their own width tables, or their measurements drift from how the editor actually lays out cells.

Functions§

char_width
Display width of a single character, in terminal columns.
str_width
Display width of a string, in terminal columns (the sum of its characters’ widths). Use this instead of .chars().count() for visual layout.