TermBuf::Cell
Stability: internal
One cell of the terminal grid.
Sixteen bytes, fixed size, with no reference to anything on the heap, so a
Grid is one flat Slice(Cell) and a row is a Slice view into it.
A cluster wider than a column occupies several cells: the first carries the
character with width set to how many columns it takes, and the rest are
continuations with width zero. No part of one is ever written without the
others; Grid enforces that.
Constants
The most columns one grapheme cluster may occupy: a lead and up to three continuations.
Two is what a cluster costs almost everywhere, and the buffer was built
for a pair. iTerm2 3.6.11 advances three for a Devanagari conjunct
carrying a spacing vowel sign, so a pair is not enough — see
Unicode::WidthPolicy#conjunct_spacing_adds?. Four leaves room above the
widest reading anyone has measured without letting a bad measurement run
away with a row.
Constructors
An empty cell carrying style, which is what a cleared or scrolled-away part of the screen holds.
A cell continuing the cluster to its left.
Instance methods
The cell's character, or '\0' when this cell continues a wide one.
When cluster is set, this is the cluster's first code point and the
full text lives in the pool.
ClusterPool id for a multi code point grapheme cluster, or
ClusterPool::NONE when char says everything.
Whether this cell's glyph may paint outside the columns it was given.
Measured rather than reasoned about. A cluster's ink runs past its own
columns often enough to matter: ﷺ is charged one column and painted
across three, an uncomposed 👨👩 is charged two and painted across four,
and neither terminal measured repaints the cell it draws over. Every case
seen was non-ASCII and no ASCII character in four runs painted outside
its cell, which is what keeps the repaint off ordinary text.
The text this cell paints, resolving a cluster id through pool. Falls back to the base character if pool does not know the cluster, so that rendering a grid against the wrong pool degrades rather than raising.
Cells this character occupies: zero for a continuation, one for a narrow
character, and up to MAX_WIDTH for a cluster the terminal advances
further for.