#[repr(C, align(16))]pub struct Cell {
pub content: CellContent,
pub fg: PackedRgba,
pub bg: PackedRgba,
pub attrs: CellAttrs,
}Expand description
A single terminal cell (16 bytes).
§Layout
#[repr(C, align(16))]
Cell {
content: CellContent, // 4 bytes
fg: PackedRgba, // 4 bytes
bg: PackedRgba, // 4 bytes
attrs: CellAttrs, // 4 bytes
}§Invariants
- Size is exactly 16 bytes (verified by compile-time assert)
- All fields are valid (no uninitialized memory)
- Continuation cells should not have meaningful fg/bg (they inherit from parent)
§Default
The default cell is empty with transparent background, white foreground, and no style attributes.
Fields§
§content: CellContentCharacter or grapheme content.
fg: PackedRgbaForeground color.
bg: PackedRgbaBackground color.
attrs: CellAttrsStyle flags and hyperlink ID.
Implementations§
Source§impl Cell
impl Cell
Sourcepub const CONTINUATION: Cell
pub const CONTINUATION: Cell
A continuation cell (placeholder for wide characters).
When a character has display width > 1, subsequent cells are filled with this to indicate they are “owned” by the previous cell.
Sourcepub const fn new(content: CellContent) -> Cell
pub const fn new(content: CellContent) -> Cell
Create a new cell with the given content and default colors.
Sourcepub const fn is_continuation(&self) -> bool
pub const fn is_continuation(&self) -> bool
Check if this is a continuation cell.
Sourcepub const fn width_hint(&self) -> usize
pub const fn width_hint(&self) -> usize
Get the display width hint for this cell.
See CellContent::width_hint for details.
Sourcepub fn bits_eq(&self, other: &Cell) -> bool
pub fn bits_eq(&self, other: &Cell) -> bool
Bitwise equality comparison (fast path for diffing).
Uses bitwise AND (&) instead of short-circuit AND (&&) so all
four u32 comparisons are always evaluated. This avoids branch
mispredictions in tight loops and allows LLVM to lower the check
to a single 128-bit SIMD compare on supported targets.
Sourcepub const fn with_char(self, c: char) -> Cell
pub const fn with_char(self, c: char) -> Cell
Set the cell content to a character, preserving other fields.
Sourcepub const fn with_fg(self, fg: PackedRgba) -> Cell
pub const fn with_fg(self, fg: PackedRgba) -> Cell
Set the foreground color.
Sourcepub const fn with_bg(self, bg: PackedRgba) -> Cell
pub const fn with_bg(self, bg: PackedRgba) -> Cell
Set the background color.
Sourcepub const fn with_attrs(self, attrs: CellAttrs) -> Cell
pub const fn with_attrs(self, attrs: CellAttrs) -> Cell
Set the style attributes.
Trait Implementations§
impl Copy for Cell
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.