Skip to main content

VirtualRowMatrix

Struct VirtualRowMatrix 

Source
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: VirtualRowVersion

Implementations§

Source§

impl VirtualRowMatrix

Source

pub fn empty() -> Self

The empty matrix. The initial published value before any provider has emitted.

Source

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.

Source

pub fn len(&self) -> usize

Source

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

Source

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.

Source

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.

Source

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.

Source

pub fn sticky_rows(&self) -> impl Iterator<Item = &VirtualRow>

Trait Implementations§

Source§

impl Clone for VirtualRowMatrix

Source§

fn clone(&self) -> VirtualRowMatrix

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 VirtualRowMatrix

Source§

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

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

impl Default for VirtualRowMatrix

Source§

fn default() -> Self

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

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