Expand description
Cell types and invariants.
The Cell is the fundamental unit of the terminal grid. Each cell occupies
exactly 16 bytes to ensure optimal cache utilization (4 cells per 64-byte
cache line) and enable fast SIMD comparisons.
§Layout (16 bytes, non-negotiable)
Cell {
content: CellContent, // 4 bytes - char or GraphemeId
fg: PackedRgba, // 4 bytes - foreground color
bg: PackedRgba, // 4 bytes - background color
attrs: CellAttrs, // 4 bytes - style flags + link ID
}§Why 16 Bytes?
- 4 cells per 64-byte cache line (perfect fit)
- Single 128-bit SIMD comparison
- No heap allocation for 99% of cells
- 24 bytes wastes cache, 32 bytes doubles bandwidth
Structs§
- Cell
- A single terminal cell (16 bytes).
- Cell
Attrs - Packed cell attributes:
- Cell
Content - Cell content: either a direct Unicode char or a reference to a grapheme cluster.
- Grapheme
Id - Grapheme ID: reference to an interned string in [
GraphemePool]. - Packed
Rgba - A compact RGBA color.
- Style
Flags - 8-bit cell style flags.