pub struct Cell {
pub ch: char,
pub fg: Color,
pub bg: Color,
pub attrs: CellAttrs,
pub width: u8,
pub combining: u16,
}Expand description
One cell in a snapshotted pane. Carries the rendered character
- foreground / background colors + attrs + display width. Hyperlink / combining-char fields stay mado-side until a later phase ports mado’s full Cell wholesale.
Fields§
§ch: char§fg: Color§bg: Color§attrs: CellAttrs§width: u8Display columns this cell occupies: 1 normal, 2 the LEAD of a
double-width glyph, 0 the CONTINUATION cell owned by the lead to
its left.
#[serde(default = "width_one")] and NOT a bare #[serde(default)]:
bare default is 0, which means continuation, so an old daemon’s
snapshot would decode as a grid of continuation cells and a renderer
that skips width-0 would draw a completely blank pane. This is the
highest-consequence default in the type.
combining: u16Combining marks attached to this cell, as a 1-based index into
PaneSnapshot::combining. 0 means none — the overwhelmingly
common case, and why this is an index rather than an inline box.
§Why interned and not Option<Box<Vec<char>>>
mado stores marks inline on the cell, and copying that shape here
would cost Cell its Copy. That matters because
PaneGrid::snapshot clones the entire scrollback, whose default
cap is usize::MAX rows: with Copy those clones are a memcpy,
while a boxed field turns every one into a per-cell branch plus drop
glue over potentially millions of cells.
Interning keeps the hot path a memcpy and moves the rare data to the
side, at the cost of one extra u16 per cell (Cell is 16 bytes,
still under mado’s 24-byte budget).
Implementations§
Source§impl Cell
impl Cell
pub const BLANK: Self
Sourcepub const fn is_continuation(&self) -> bool
pub const fn is_continuation(&self) -> bool
True when this cell is the second half of a double-width glyph and therefore owns no character of its own.
Sourcepub fn marks<'a>(&self, table: &'a [Vec<char>]) -> &'a [char]
pub fn marks<'a>(&self, table: &'a [Vec<char>]) -> &'a [char]
The combining marks attached to this cell, resolved against a
snapshot’s PaneSnapshot::combining table.
Empty for the common case. An index that outruns the table also yields empty rather than panicking — a truncated or mismatched table is a wire-level defect that must not take the renderer down.