Skip to main content

Span

Struct Span 

Source
pub struct Span {
    pub line: u16,
    pub left: u16,
    pub right: u16,
    pub cells: Vec<Cell>,
    pub combining: BTreeMap<usize, Vec<char>>,
    pub links: BTreeMap<usize, NonZeroU32>,
    pub ucolors: BTreeMap<usize, Color>,
}
Expand description

A damaged column run on one line, with its cells.

combining and links map a span-relative column to what that cell carries — combining clusters (#45) and hyperlinks (#46) live in per-row maps, so neither rides the cell. Since v14 (#621) both are sparse wire groups of their own, not indices in the cell record, which is what removed the u16 ceilings the engine could legitimately exceed.

The two are deliberately not symmetric, and the asymmetry is measured rather than stylistic:

  • combining holds the cluster inline. Term::frame pushes one entry per combining cell with no interning, so an index bought nothing but a level of indirection and a table to count. Inlining is size-neutral (measured: −0.5% on a combining-heavy frame) and buys the deletion of both.
  • links holds a 1-based index into Frame::link_table, because that table is interned (Term::frame’s link_remap ships each referenced URI once). Inlining a URI at every linked cell was measured at +171…403% on link-dense frames, and all three references share one copy across cells — ghostty ref-counts its hyperlink set explicitly “so that a set of cells can share the same hyperlink without duplicating the data”, xterm.js keys cells to an OscLinkService id, alacritty holds Arc<HyperlinkInner>.

A column is present in either map iff its cell carries the matching bit — and, as with ucolors below, that bit does not travel on the wire (the record encodes cell.c() and encode_color(bg), which drop C_COMBINED and LINK_PRESENT respectively). decode re-arms both from these maps’ own entries. A Span built by hand for a test owes the same pairing.

Fields§

§line: u16§left: u16§right: u16§cells: Vec<Cell>§combining: BTreeMap<usize, Vec<char>>§links: BTreeMap<usize, NonZeroU32>§ucolors: BTreeMap<usize, Color>

Underline colours (SGR 58, #520): span-relative column → the Color reference the cell’s coloured underline draws in. Sparse — only cells that carry a non-default underline colour appear (gated on the UNDERLINE attribute at parse time). Unlike combining/links this is a colour reference, not a side-table index, so it ships inline (no _table on the Frame). Kept off the per-cell record so a plain-text frame pays nothing (ADR-0020: no inert per-cell payload).

Like combining and links, a column here is present iff its cell carries the matching bit (Cell::is_ucolored) — but that bit does not travel on the wire (encode_color keeps only mode+value, and CellFlags holds no presence bits), so decode re-arms it from this map’s own entries. A Span built by hand for a test owes the same pairing: an entry here without Cell::set_ucolored on the cell is a column the gated readers cannot see. (#531)

Trait Implementations§

Source§

impl Clone for Span

Source§

fn clone(&self) -> Span

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 Debug for Span

Source§

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

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

impl Eq for Span

Source§

impl PartialEq for Span

Source§

fn eq(&self, other: &Span) -> 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 Span

Auto Trait Implementations§

§

impl Freeze for Span

§

impl RefUnwindSafe for Span

§

impl Send for Span

§

impl Sync for Span

§

impl Unpin for Span

§

impl UnsafeUnpin for Span

§

impl UnwindSafe for Span

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.