Skip to main content

Crate lattice_terminal

Crate lattice_terminal 

Source
Expand description

lattice-terminal: PTY-backed terminal-buffer substrate.

Issue #40 / Terminal-mode T1 (2026-05-22). See docs/dev/architecture/terminal-mode.md for the design and docs/dev/operations/slice-plans/terminal-mode.md for the slice breakdown.

§Surface (T1)

  • PtyHandle: writer + resize + kill for the master pty side. Cheap to clone (Arc-backed).
  • TerminalSnapshot: renderer-facing immutable view of the cell grid + cursor + title. Read via ArcSwap::load() on the hot paint path.
  • spawn: spawns a child process under a fresh PTY, returns the writer handle + the published snapshot cell. The reader task is spawned automatically and runs until the child exits or the handle is dropped.

Input encoding (<C-c> → \x03 etc.) is wired in T2. Scrollback navigation + Visual yank land in T3.

Re-exports§

pub use buffer::TerminalBuffer;
pub use buffer::TerminalVisualState;
pub use buffer::VisualKind;
pub use cell::Cell;
pub use cell::CellAttrs;
pub use cell::CursorShape;
pub use cell::NamedColor;
pub use cell::TerminalColor;
pub use handle::PtyHandle;
pub use handle::PtyHandleError;
pub use install::install;
pub use modes::TerminalInsertMode;
pub use modes::TerminalMode;
pub use modes::TerminalNormalMode;
pub use modes::TerminalNormalModeGuard;
pub use modes::register_terminal_modes;
pub use reader::GridSearchHit;
pub use reader::SearchDir;
pub use reader::SharedTerm;
pub use reader::TerminalScrollKind;
pub use snapshot::TerminalSnapshot;
pub use spawner::SpawnConfig;
pub use spawner::SpawnError;
pub use spawner::spawn;
pub use synthetic::SyntheticDoc;
pub use synthetic::TerminalStore;
pub use synthetic::TerminalStoreHandle;

Modules§

buffer
cell
Cell + color + attribute types — the renderer-facing representation of a terminal grid position.
handle
PtyHandle — writer + resize for the master PTY side. Cheaply clonable (Arc-backed); fire-and-forget semantics so host code can write keystrokes synchronously without await.
install
BC.4: the crate-owned install(boot) entry point.
modes
reader
Reader task — drains the master PTY’s read side into the published TerminalSnapshot cell.
snapshot
TerminalSnapshot — the immutable per-frame view the renderer paints. Published via ArcSwap from the reader task; loaded wait-free by the paint hot path.
spawner
spawn — fork a child process under a fresh pseudo-tty. Returns the PtyHandle (writer + resize) and the published Arc<ArcSwap<TerminalSnapshot>> cell the renderer reads from.
synthetic
T-snap-1 (2026-05-27): synthetic, read-only Document built from the alacritty scrollback + visible grid. The central vim grammar operates on this Document during the Normal / Visual sub-state of a terminal buffer; the renderer continues to paint the cell grid. A coord adapter (T-paint-1) translates document-space selection ranges back to cell coordinates at publish time so renderer paths stay buffer-kind-agnostic.