Skip to main content

lattice_cells/
lib.rs

1//! Cell-grid renderer substrate.
2//!
3//! Pure data types: [`Cell`], [`CellRow`], [`CellChunk`],
4//! [`CellMatrix`], [`MatrixVersion`]. No rendering, no I/O, no
5//! rope dependencies. Both renderer crates (`lattice-ui-tui`,
6//! `lattice-ui-gpui`) and the host substrate (`lattice-host`)
7//! depend on this.
8//!
9//! Construction logic — converting `(rope, syntax spans, inlay
10//! hints, folds, theme)` into `CellRow`s and chunks — lands in
11//! S2 as a tokio worker in `lattice-host`. This crate's
12//! responsibility ends at the type contracts.
13//!
14//! Design anchor:
15//! [`docs/dev/architecture/cell-grid-renderer.md`](../../../docs/dev/architecture/cell-grid-renderer.md).
16//!
17//! ## Module layout
18//!
19//! - [`cell`] — 16-byte [`Cell`] + the [`cell::flags`] bit table.
20//! - [`row`] — [`CellRow`] + the inlay byte↔column remap helper.
21//! - [`chunk`] — [`CellChunk`], the cache + rebuild unit.
22//! - [`matrix`] — [`CellMatrix`] + slicing iterators.
23//! - [`version`] — [`MatrixVersion`] vector that drives rebuild
24//!   decisions in the cell-builder worker.
25//!
26//! ## Slicing
27//!
28//! S1 (this crate) — types, slicing API, unit tests.
29//! S2 — cell-builder worker + RenderState integration.
30//! S3 — TUI cutover.
31//! S4 — GPU glyph atlas + `paint_cells`.
32//! S5 — bench + chunk-size + atlas tuning.
33//! S6 — cleanup (strip probes, retire shape_line on code path).
34
35pub mod cell;
36pub mod chunk;
37// H.1 (2026-08-29): source-byte → display-column, shared by every
38// carrier that holds an inlay table and a conceal list. See
39// `docs/dev/architecture/conceal.md`.
40pub mod coords;
41// Style types + ExcerptHighlighter trait. Defined here (not in
42// lattice-syntax) to break the lattice-syntax → lattice-mode →
43// lattice-runtime cycle that would block lattice-runtime's Document
44// trait from referencing them.
45pub mod style;
46// S2.4.b (2026-05-26): substrate-level edit delta consumed by the
47// cell-builder's incremental rebuild path.
48pub mod edit_delta;
49pub mod matrix;
50pub mod row;
51pub mod version;
52// D.0a (2026-05-28): virtual-row primitive for inline diff
53// deletion blocks, multibuffer excerpt headers, and future
54// inlay / code-lens consumers. See
55// `docs/dev/architecture/virtual-rows.md`.
56pub mod media;
57pub mod row_weights;
58pub mod virtual_rows;
59// Generic sticky headerline — the one mechanism for a buffer to pin a status
60// row above line 0. Tutor, multibuffer search, LSP status, VCS branch all use
61// this. See `docs/dev/architecture/headerline.md`.
62pub mod headerline;
63// TC.1: structural context scopes + the resolver that picks which of them
64// a pane pins above its text. Pure — the scope set is a function of the
65// parse tree, the resolution a function of the anchor line. See
66// `docs/dev/architecture/treesitter-context.md`.
67pub mod context;
68
69pub use cell::{Cell, flags as cell_flags};
70pub use chunk::CellChunk;
71pub use coords::{
72    ConcealRange, display_col_to_source_byte, source_byte_to_display_col, subtract_conceals,
73};
74pub use edit_delta::EditDelta;
75pub use headerline::{Headerline, HeaderlineProvider, HeaderlineRow, SimpleHeaderlineHandle};
76pub use matrix::{
77    CHUNK_SIZE_WHOLE_DOC, CellMatrix, CellSlice, CellSliceIter, DisplayRowEntry, DisplaySlice,
78    DisplaySliceIter, wrap_segments,
79};
80pub use media::{MediaBlock, MediaBlockRef, MediaFit, MediaSource};
81pub use row::{CellRow, InlayOffset};
82pub use row_weights::RowWeights;
83pub use style::{ExcerptHighlight, ExcerptHighlighter, RefineKind, RefineSpan, Style, StyledSpan};
84pub use version::MatrixVersion;
85pub use virtual_rows::{
86    AnchorPosition, BASE_SCALE, ProviderId, ScaleRun, VirtualRow, VirtualRowKind, VirtualRowMatrix,
87    VirtualRowProvider, VirtualRowVersion, coalesce_scales,
88};