pub struct VirtualRowMatrix {
pub rows: Arc<[VirtualRow]>,
pub line_index: Arc<[u32]>,
pub source_line_count: u32,
pub version: VirtualRowVersion,
}Expand description
The published virtual-row lane for one document.
Immutable once built; the publisher replaces the Arc<…>
when providers mutate. Cheap to clone (Arc bump).
rows is sorted by (anchor_line, position) with
Above < Below at the same line. line_index[i] is the
index of the first row in rows whose anchor_line >= i;
length is source_line_count + 1. The line index turns
“how many virtual rows are anchored before line L” into a
constant-time array lookup, which the
crate::DisplaySliceIter uses to fast-forward past
scrolled-off virtual rows in O(1) instead of O(V).
Fields§
§rows: Arc<[VirtualRow]>§line_index: Arc<[u32]>§source_line_count: u32§version: VirtualRowVersionImplementations§
Source§impl VirtualRowMatrix
impl VirtualRowMatrix
Sourcepub fn empty() -> Self
pub fn empty() -> Self
The empty matrix. The initial published value before any provider has emitted.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
true when no virtual rows are present. The
crate::CellMatrix::display_slice fast path detects
this to skip interleaver overhead entirely.
pub fn len(&self) -> usize
Sourcepub fn build(
rows: Vec<VirtualRow>,
source_line_count: u32,
version: VirtualRowVersion,
) -> Self
pub fn build( rows: Vec<VirtualRow>, source_line_count: u32, version: VirtualRowVersion, ) -> Self
Build a VirtualRowMatrix from an unsorted list. The
rows are sorted by (anchor_line, position) and the
line_index is computed.
source_line_count should match the document’s line
count (so the line-index sentinel covers EOF). If a
virtual row anchors past source_line_count, it is
clamped to anchor at source_line_count (treated as
“past EOF” by the interleaver, which emits it after
the last document row).
Sourcepub fn first_row_at_or_after(&self, line: u32) -> u32
pub fn first_row_at_or_after(&self, line: u32) -> u32
Index of the first row in rows whose anchor_line >= line. Returns rows.len() as u32 when every row
anchors strictly below line.
O(1) array lookup when line <= source_line_count;
returns rows.len() for queries past EOF.
Sourcepub fn virtual_rows_in_line_range(&self, lo: u32, hi: u32) -> u32
pub fn virtual_rows_in_line_range(&self, lo: u32, hi: u32) -> u32
Number of virtual rows whose anchor sits in the inclusive
document-line range [lo, hi], regardless of
AnchorPosition. Returns 0 when lo > hi.
O(1) — two Self::first_row_at_or_after lookups. This is
the geometry primitive the host’s scroll model uses to
answer “how many display rows does the document-line span
[lo, hi] occupy”, since each interleaved virtual row
consumes a display row without being a document line. The
count is position-agnostic on purpose: a bottom-anchored
scroll over-reserves by at most the cursor line’s own
Below rows, which is the safe direction (the last line is
guaranteed clear of the modeline rather than flush against
it).
VirtualRowKind::Sticky rows are excluded — they are
rendered at the pane top outside the scroll window and do
not displace content rows.
Sourcepub fn media_row_weights(&self, draws_media: bool) -> RowWeights
pub fn media_row_weights(&self, draws_media: bool) -> RowWeights
Iterator over all pinned rows in the matrix (see
VirtualRowKind::is_pinned — Sticky headerlines + the
BrandingBlock masthead). Used by renderers to paint the fixed top
strip before the scrollable content window.
IM.5: the RowWeights implied by this matrix’s
media blocks.
A source line carrying a media block costs its own row plus the block’s DRAWN height, which is fractional and generally differs from the rows the block reserved. Everything else is absent from the map and therefore costs exactly what it always did.
draws_media is the renderer’s answer to “do I paint pixels”. The TUI
passes false and gets a uniform map, so its scroll arithmetic is
untouched — it renders the block’s alt-text cells in the reserved rows
and those rows are one line tall, which is the truth for a terminal.
Only one renderer runs in a process, so the two answers never collide.
pub fn sticky_rows(&self) -> impl Iterator<Item = &VirtualRow>
Trait Implementations§
Source§impl Clone for VirtualRowMatrix
impl Clone for VirtualRowMatrix
Source§fn clone(&self) -> VirtualRowMatrix
fn clone(&self) -> VirtualRowMatrix
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more