Skip to main content

Module display_matrix

Module display_matrix 

Source
Expand description

Per-line display cache — the substrate that retires the per-character lattice_cells::CellMatrix.

See docs/dev/architecture/display-line.md (design) and docs/dev/operations/slice-plans/display-line.md (slices).

§What this is

A DisplayLine is the renderer-agnostic, fully-resolved display form of one source line: the final display text (inlay hints spliced in, tabs expanded to display width, whitespace markers substituted), the style runs over it ([RowRun], style tags resolved to colour by each renderer at paint), a col_map from source bytes to inserted display columns (cursor / selection / overlay coordinate translation), the display col_count (for soft-wrap segment geometry), and an optional FoldHead when the line heads a closed fold.

DisplayMatrix is the chunked, viewport-windowed, incrementally-rebuilt cache of DisplayLines — the exact machinery of CellMatrix (chunking, windowing, MatrixVersion, row reuse via Arc) with the payload swapped from Vec<Cell> to DisplayLine. Both renderers consume it directly: TUI maps text + runs to ratatui cells; GPU shapes text once (shape_line, LineLayoutCache) with per-run colours — no per-char intermediate, no un-bake.

§B1 scope

Types + machinery only (empty / whole_doc / chunked, row_at_source_line, coverage, segment_count, shifted_by). The worker build path, the shared incremental-reuse, the always-current synchronous rebuild, and the renderer cutovers land in B2–B4. Not consumed by any renderer yet.

Structs§

DisplayChunk
Contiguous range of display rows covering a slice of the buffer. Same invariants as CellChunk: rows sorted ascending by source_line, folded lines absent (row count is post-fold), start_source_line is the first source line the chunk’s [start, start + chunk_size) logical range could contain.
DisplayLine
The fully-resolved display form of one source line. Fields are Arc-shared so Self::with_source_line (the incremental-reuse shift) is a refcount bump, not a copy — mirroring CellRow.
DisplayMatrix
Chunked, viewport-windowed cache of DisplayLines. Mirrors CellMatrix exactly; only the row payload differs.
DisplayRun
A style-tagged run within a DisplayLine’s text — the per-line analogue of a Cell, one per contiguous run instead of per char. The renderer resolves style → foreground colour + modifiers via the per-frame theme; flags carries the non-style bits the cell model baked: lattice_cells::cell_flags::INLAY for spliced inlay text, WS_MARKER for a whitespace-marker glyph. Run lengths (len, utf-8 bytes) sum to text.len().
FoldHead
Closed-fold head marker carried by the first visible line of a folded region. folded_lines is how many source lines the fold collapses (for the ┄ N lines folded gutter / inline suffix).