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: Cell
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.
Trait Implementations§
impl Copy for Cell
Source§impl<'de> Deserialize<'de> for Cell
impl<'de> Deserialize<'de> for Cell
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Cell, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Cell, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for Cell
Source§impl Serialize for Cell
impl Serialize for Cell
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Cell
Auto Trait Implementations§
impl Freeze for Cell
impl RefUnwindSafe for Cell
impl Send for Cell
impl Sync for Cell
impl Unpin for Cell
impl UnsafeUnpin for Cell
impl UnwindSafe for Cell
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.