Skip to main content

Cell

Struct Cell 

Source
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

Source

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).

Source

pub fn c(&self) -> char

The base code point.

Source

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.

Source

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.

Source

pub fn fg(&self) -> Color

The foreground colour reference.

Source

pub fn bg(&self) -> Color

The background colour reference.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn set_c(&mut self, c: char)

Overwrite the base code point, preserving the layout markers.

Source

pub fn set_bg(&mut self, bg: Color)

Overwrite the background colour (the BCE erase fill, #16), preserving the bg-word flag bits.

Source

pub fn set_combined(&mut self, on: bool)

Mark (or unmark) this column as carrying combining marks in the row map.

Source

pub fn set_linked(&mut self, on: bool)

Mark (or unmark) this column as carrying an OSC 8 hyperlink in the row map.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn is_wide_spacer(&self) -> bool

Is this the trailing spacer cell of a width-2 glyph?

Source

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.

Source

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.

Source

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.

Source

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).

Source

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).

Trait Implementations§

Source§

impl Clone for Cell

Source§

fn clone(&self) -> Cell

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Cell

Source§

impl Debug for Cell

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Cell

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Cell

Source§

impl PartialEq for Cell

Source§

fn eq(&self, other: &Cell) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Cell

Auto Trait Implementations§

§

impl Freeze for Cell

§

impl RefUnwindSafe for Cell

§

impl Send for Cell

§

impl Sync for Cell

§

impl Unpin for Cell

§

impl UnsafeUnpin for Cell

§

impl UnwindSafe for Cell

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.