Skip to main content

Module cell

Module cell 

Source
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).
CellAttrs
Packed cell attributes:
CellContent
Cell content: either a direct Unicode char or a reference to a grapheme cluster.
GraphemeId
Grapheme ID: reference to an interned string in [GraphemePool].
PackedRgba
A compact RGBA color.
StyleFlags
8-bit cell style flags.