pub struct Cell {
pub ch: char,
pub style: CellStyle,
pub width: u8,
}Expand description
One screen cell: glyph + its visual attributes. Cell equality is byte-perfect — two cells are equal iff their serialised bytes would be identical, which is the invariant the diff relies on.
width is the display width in terminal columns: 1 for ASCII
and other narrow glyphs, 2 for CJK / emoji / other wide glyphs,
and 0 for continuation cells — placeholder cells that follow a
wide glyph to keep the invariant cell_index == terminal_column.
Without continuation cells, typing “你是谁” (3 wide chars = 6 cols)
into a row model that tracked only char count (3 cells) would emit
patches at model cols 5/6/7 while the terminal had just advanced
to actual col 11 after the first 你, overwriting each preceding
glyph’s right half with the next glyph — the “you3-type-shows-only-
last-char” bug.
Fields§
§ch: char§style: CellStyle§width: u8Implementations§
Source§impl Cell
impl Cell
Sourcepub fn blank() -> Self
pub fn blank() -> Self
Blank narrow cell — space, width 1. Used for padding and as the diff’s “erase” glyph.
Sourcepub fn continuation() -> Self
pub fn continuation() -> Self
Continuation cell — placeholder for the 2nd (or 3rd, if any)
terminal column occupied by a wide glyph. width = 0 tells
serialize_patches to skip emit for this cell: the wide
glyph emitted in the cell immediately before has already
advanced the terminal cursor past this column.
Trait Implementations§
impl Eq for Cell
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more