Skip to main content

CellRow

Struct CellRow 

Source
pub struct CellRow {
    pub cells: Arc<[Cell]>,
    pub source_line: u32,
    pub inlay_offsets: Arc<[InlayOffset]>,
}
Expand description

One row of cells in the matrix. Immutable once built; cheap to share via Arc<CellRow> across panes and frames.

Fields§

§cells: Arc<[Cell]>

Body cells in left-to-right order, including any spliced inlay cells. Length is the rendered column count for this row (post-inlay).

§source_line: u32

Logical line in the source buffer (0-based, pre-fold). Stable across edits within the line; rebuilt when the line itself changes.

§inlay_offsets: Arc<[InlayOffset]>

Inlay positions for byte↔column remap (see InlayOffset). Empty when the row has no inlays.

Implementations§

Source§

impl CellRow

Source

pub fn new( cells: impl Into<Arc<[Cell]>>, source_line: u32, inlay_offsets: impl Into<Arc<[InlayOffset]>>, ) -> Self

Construct a row from already-built cells + metadata. The cell-builder worker (S2) is the production caller; tests use this directly.

Source

pub fn empty(source_line: u32) -> Self

Empty row at a given source line. Used for visually-empty lines (truly-empty source lines, or fold-marker placeholders).

Source

pub fn with_source_line(&self, new_source_line: u32) -> Self

Clone-with-shifted-source-line. The cells and inlay_offsets Arcs are reused (cheap refcount bump — the cell payload is shared); only the source_line field changes.

Used by the cell-builder’s incremental rebuild path (S2.4.b) to reuse cached row content when an edit shifts downstream lines without changing their contents. new_source_line is the row’s logical line in the post-edit document.

Source

pub fn col_count(&self) -> u32

Column count = post-inlay cell count.

Source

pub fn segment(&self, seg: u32, width: u32) -> &[Cell]

Soft-wrap (W.2/A2): the cell sub-slice for display segment seg when this row is wrapped at width columns. Segment 0 covers columns [0, width), segment 1 [width, 2·width), and so on. The last segment is short when col_count isn’t a multiple of width; out-of-range segments return an empty slice.

width == 0 means wrapping is off: segment 0 is the whole row, every other segment is empty. Pure borrow — no allocation, and the cells (with their resolved syntax colours/flags) are untouched, so highlighting is preserved verbatim. Shared by both renderers so segment geometry is defined in one place.

Source

pub fn is_empty(&self) -> bool

true when the row has no cells. Visually-empty source lines produce empty rows.

Source

pub fn byte_to_combined_col(&self, byte: u32) -> u32

Map a source-byte (already char-resolved, see note) → combined cell column for this row. Used by overlay decoration computation to position cursor / selection / diagnostic underline quads. Returns the column after any inlays spliced before byte.

Walks inlay_offsets linearly — fine for the typical 0–3 inlays per row. Pre-sort assumption: inlay_offsets must be sorted ascending by orig_byte. Construction in S2 maintains that invariant.

Note on byte vs char: the cell-grid renderer’s design target is ASCII source code where byte == char-column. For non-ASCII content the cell-builder pre-resolves byte → char position before calling overlays, so byte here is effectively a char-column count. This fn only adds inlay shifts.

Trait Implementations§

Source§

impl Clone for CellRow

Source§

fn clone(&self) -> CellRow

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 CellRow

Source§

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

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

impl Eq for CellRow

Source§

impl Hash for CellRow

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for CellRow

Source§

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

Auto Trait Implementations§

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more