pub struct Cell { /* private fields */ }Expand description
One character position: a base glyph, fg/bg colour references, and flags.
Combining marks (#45) and an OSC 8 hyperlink (#46) attach via per-row maps,
signalled by the COMBINED_PRESENT / LINK_PRESENT bits — the cell itself is
three packed words, no Option field. All access is through the accessor seam
(#44); construct with Cell::from_parts or Cell::default.
Eq is a derived bitwise compare, which is exact because the packing is
canonical — every logical cell maps to one bit pattern (unused bits stay 0).
Implementations§
Source§impl Cell
impl Cell
Sourcepub fn from_parts(c: char, fg: Color, bg: Color, flags: CellFlags) -> Self
pub fn from_parts(c: char, fg: Color, bg: Color, flags: CellFlags) -> Self
Assemble a cell from its logical parts. The single construction seam —
Pen::cell and the wire decoder funnel through here, so the bit-packing
lives in exactly one place (#44).
Sourcepub fn is_blank(&self) -> bool
pub fn is_blank(&self) -> bool
Does this cell hold no content — no glyph and no layout marker?
A blank the app never wrote and one it erased to a coloured background are both blank: the
background is not content. But a wide-char spacer, a leading-spacer wrap artefact, or a
combining-cluster carrier all mean something at their column even though their base
code point is a space — they are not blank. Used by reflow to find where a hard-ended
line ends (mirrors xterm.js getTrimmedLength / alacritty line_length, which likewise
test content, not the background); it says nothing about a cell’s colour.
Sourcepub fn underline_style(&self) -> UnderlineStyle
pub fn underline_style(&self) -> UnderlineStyle
How this cell’s underline is drawn (#829). UnderlineStyle::None means not underlined —
there is no separate boolean to consult, and CellFlags::UNDERLINE is derived from this.
Sourcepub fn flags(&self) -> CellFlags
pub fn flags(&self) -> CellFlags
The cell’s flags (SGR attributes + layout markers), reassembled from the
three words — the branchless inverse of Cell::store_flags.
Sourcepub fn is_combined(&self) -> bool
pub fn is_combined(&self) -> bool
Does this column carry combining marks? When true, the cluster lives in the row’s combining map at this column (#45) — a flag-gated cache: never read the map without first checking this bit.
Sourcepub fn is_linked(&self) -> bool
pub fn is_linked(&self) -> bool
Does this column carry an OSC 8 hyperlink? When true, the URI lives in the row’s link map at this column (#46; the URI itself rather than an index into a buffer-wide pool since #628) — flag-gated like combining: never read the link map without first checking this bit.
Sourcepub fn is_ucolored(&self) -> bool
pub fn is_ucolored(&self) -> bool
Does this column carry a non-default underline colour (SGR 58, #520)? When
true, the Color reference lives in the row’s ucolor map at this column —
flag-gated exactly like the hyperlink: never read the ucolor map without
first checking this bit.
Sourcepub fn set_bg(&mut self, bg: Color)
pub fn set_bg(&mut self, bg: Color)
Overwrite the background colour (the BCE erase fill, #16), preserving the bg-word flag bits.
Sourcepub fn set_combined(&mut self, on: bool)
pub fn set_combined(&mut self, on: bool)
Mark (or unmark) this column as carrying combining marks in the row map.
Sourcepub fn set_linked(&mut self, on: bool)
pub fn set_linked(&mut self, on: bool)
Mark (or unmark) this column as carrying an OSC 8 hyperlink in the row map.
Sourcepub fn set_ucolored(&mut self, on: bool)
pub fn set_ucolored(&mut self, on: bool)
Mark (or unmark) this column as carrying a non-default underline colour in
the row’s ucolor map (#520). Mirror of Cell::set_linked.
Sourcepub fn insert_flags(&mut self, flags: CellFlags)
pub fn insert_flags(&mut self, flags: CellFlags)
Add the given flags (leaving the others set). Sets the word bits directly —
no round-trip through flags()/store_flags.
The underline is a field, not a bit, so it is replaced rather than OR-ed (#829).
Bit-OR is the right operation for every other member and the wrong one for a 3-bit value:
OR-ing Dotted (4) into a Single (1) cell yields Dashed (5), a style neither the
caller nor the parser asked for, and a bit pattern no canonical cell has — which would
break the property this type’s derived Eq is a bitwise compare because of. A completeness
pass found this; nothing in this repository reached it, but Cell is published.
Sourcepub fn remove_flags(&mut self, flags: CellFlags)
pub fn remove_flags(&mut self, flags: CellFlags)
Clear the given flags (leaving the others as they are).
Naming the underline clears the whole field (#829), whichever way it was named — the
UNDERLINE flag or a style value. Masking the bits off instead would turn one style into
another (clearing UNDERLINE, which normalises to Single = 0b001, subtracts a bit from
Curly = 0b011 and leaves Double), so a method documented as clearing a flag would
return a cell that is still underlined, in a style no input can produce.
Sourcepub fn set_underline_style(&mut self, style: UnderlineStyle)
pub fn set_underline_style(&mut self, style: UnderlineStyle)
Set the underline style on this cell, arming or disarming the derived UNDERLINE view bit
with it. The one writer of the field on a built cell.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Reset to a blank default cell — default background included.
That is rarely what a terminal operation wants on its own: a blank the engine creates
carries the current background (BCE for an erase, and the same for a structural repair,
#530). Callers pair this with set_bg; Term::free_cell and the erase paths are the
places that do. Using it bare leaves an uncoloured notch in a coloured run.
Sourcepub fn is_wide(&self) -> bool
pub fn is_wide(&self) -> bool
Is this the lead cell of a width-2 glyph? Direct content-bit query — the
hot overwrite/erase/reflow paths use this instead of reconstructing the
full flags() to test one marker.
Sourcepub fn is_wide_spacer(&self) -> bool
pub fn is_wide_spacer(&self) -> bool
Is this the trailing spacer cell of a width-2 glyph?
Sourcepub fn is_leading_spacer(&self) -> bool
pub fn is_leading_spacer(&self) -> bool
Is this the blank column vacated when a wide glyph wrapped off the right edge (#113)? It holds no character; unlike a trailing spacer it has no wide lead to its left, so only the text extractors skip it.
Sourcepub fn is_spacer(&self) -> bool
pub fn is_spacer(&self) -> bool
Does this column hold no text — either half of a wide glyph’s trailing spacer or a wide-wrap leading spacer? Used by the text extractors (search, selection text, logical lines) to skip non-character columns.
Sourcepub fn clear_leading_spacer(&mut self)
pub fn clear_leading_spacer(&mut self)
Drop the leading-spacer marker, leaving the cell otherwise untouched.
The marker claims two things at once, and it has to go when either stops holding, or
the text extractors keep skipping a column that is now a real blank: the row still
soft-wraps (Term::end_wrap owns that half — #538, #540), and the continuation still
begins with the wide lead that could not fit (Term::repair_wrap_artefact_above owns that
one — #534). Clearing is deliberately one-way: nothing here re-arms the marker, because a
wide glyph typed at column 0 of the next row did not wrap from anywhere.
Sourcepub fn set_leading_spacer(&mut self)
pub fn set_leading_spacer(&mut self)
Mark this column as the leading spacer of a wrapped wide glyph.
Records that the column is blank; it does not make it so. The caller must have
written the blank first — this only ORs a marker onto whatever cell is there. Setting
it over a live glyph leaves a cell the text extractors skip while a renderer still
draws it, which is exactly the defect #528 fixed (Term::vacate_for_wrap is the one
place that establishes the precondition; reflow is the other set site, #533).
Sourcepub fn is_wrapline(&self) -> bool
pub fn is_wrapline(&self) -> bool
Does this wire cell end a soft-wrapped row? See CellFlags::WRAPLINE — on the live
grid this is always false and Grid::is_row_wrapped is the question to ask (#538).