#[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: Self
pub const CONTINUATION: Self
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) -> Self
pub const fn new(content: CellContent) -> Self
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: &Self) -> bool
pub fn bits_eq(&self, other: &Self) -> 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) -> Self
pub const fn with_char(self, c: char) -> Self
Set the cell content to a character, preserving other fields.
Sourcepub const fn with_fg(self, fg: PackedRgba) -> Self
pub const fn with_fg(self, fg: PackedRgba) -> Self
Set the foreground color.
Sourcepub const fn with_bg(self, bg: PackedRgba) -> Self
pub const fn with_bg(self, bg: PackedRgba) -> Self
Set the background color.
Sourcepub const fn with_attrs(self, attrs: CellAttrs) -> Self
pub const fn with_attrs(self, attrs: CellAttrs) -> Self
Set the style attributes.