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: u32Logical 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
impl CellRow
Sourcepub fn new(
cells: impl Into<Arc<[Cell]>>,
source_line: u32,
inlay_offsets: impl Into<Arc<[InlayOffset]>>,
) -> Self
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.
Sourcepub fn empty(source_line: u32) -> Self
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).
Sourcepub fn with_source_line(&self, new_source_line: u32) -> Self
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.
Sourcepub fn segment(&self, seg: u32, width: u32) -> &[Cell]
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.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
true when the row has no cells. Visually-empty source
lines produce empty rows.
Sourcepub fn byte_to_combined_col(&self, byte: u32) -> u32
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.