pub struct Cell {
pub ch: char,
pub style: Style,
pub width: u8,
}Expand description
One character cell: a char, its Style, and its display width in
terminal columns. The default cell is a single-width space in the default
style.
width lets the grid model East Asian double-width glyphs and emoji, which
occupy two columns:
1— a normal single-width cell (the common case, and the default).2— the lead (left half) of a double-width glyph;chholds the character. The cell immediately to its right should be a width-0continuation.0— a continuation (right half) of the glyph to its left: it carries no character of its own and is never emitted, because the terminal advances the cursor by two columns when it draws the lead glyph.
This crate does not compute width — that needs the Unicode database, which
a zero-dependency crate cannot own. Callers set width (e.g. from the
uwidth crate); the renderers here honor whatever width they are given.
Fields§
§ch: char§style: Style§width: u8Implementations§
Source§impl Cell
impl Cell
Sourcepub const fn wide(ch: char, style: Style) -> Self
pub const fn wide(ch: char, style: Style) -> Self
The lead (left half) of a double-width glyph (width == 2). Its right
neighbor should be a Cell::continuation.
Sourcepub const fn continuation(style: Style) -> Self
pub const fn continuation(style: Style) -> Self
A continuation (right half) of a double-width glyph (width == 0): no
character of its own, but carrying style so the covered column keeps
the right background. Never emitted — the lead glyph fills both columns.