Expand description
Terminal renderer for lattice (DESIGN.md §5.6.1 TuiRenderer).
v1 status: a first-class peer of the GPU UI for headless / SSH / low-bandwidth use, with documented limitations bound to terminal capabilities (no variable fonts, monospace cells only, sprites degrade to fallback glyphs).
Phase 2 scope: a read-only viewer with cursor motion (hjkl, gg, G),
viewport scrolling, line-number gutter, mode line, and a stub
syntax highlighter (Rust keywords for .rs files). The stub highlighter
produces the same StyledSpan shape that real tree-sitter integration
(Phase 3) will feed; swapping in tree-sitter does not require rewiring
the renderer.
Phase 3+ replaces the stub with real tree-sitter queries; the modal
engine drives input through CommandInvocations instead of the
hardcoded Action enum used here.
Re-exports§
Modules§
- actions
- App-side action registrations – the
CommandKind::Actionpeers of the grammar’s built-in motions / operators / text- objects (lattice_grammar::builtins) and built-in ex-commands (lattice_grammar::ex_commands). - actor_
call_ counter - Per-thread counter for
App::read_editor/App::mutate_editor/App::mutate_editor_withcalls. - app
- Pure application state and transitions.
- buffer_
registry - Unified buffer registry (DESIGN.md §5.9).
- buffers
- Buffer kind + id + flags – moved from
lattice-ui-tuito the renderer-agnostic substrate in Phase 5.2 first wave. - cells_
render - B2.4 (2026-06-04):
DisplayMatrix→ ratatui span conversion. - chord
- Crossterm →
KeyChordadapter for the TUI renderer. - clipboard
- CB.2 / CB.4 (
docs/dev/architecture/clipboard.md§4): the TUI’slattice_core::Clipboardbackend. Two implementations composed byTuiClipboard::detect: - excommand
- Phase 2->3 ex-command parser.
- file_
tree - File-tree buffer model – re-exported from
lattice-file-tree. - folds
- Computed folds (DESIGN.md §5.1, §15:18; user-facing reference
at
docs/user/folding.md). - help
- Help buffer model – re-exported from
lattice-help. - help_
topics - Help topic registry – re-exported from
lattice-help::topics. - host_
generators - App-state-dependent completion generators.
- input
- Crossterm → KeyChord adapter shim for the host-side dispatch.
- keymap
- Re-export shim for the static keymap catalog +
keymap_entry!macro. - keymap_
entry - Static keymap catalog +
keymap_entry!macro (DESIGN.md §5.2.3). - keymap_
insert - Crossterm-coupled test harness for the renderer-neutral
lattice_host::keymap_insertcatalog. Production code moved to lattice-host in slice 5.4 / slice 4; the tests stay here because theirev()helper buildsKeyChordvalues viacrate::chord::from_event(&KeyEvent { ... }). - keymap_
normal - Crossterm-coupled test harness for the renderer-neutral
lattice_host::keymap_normalcatalog. Slice 5.4 / slice 3 moved the production code to lattice-host; the tests stay here because theirev()helper buildsKeyChordvalues viacrate::chord::from_event(&KeyEvent { ... }), and the crossterm adapter only exists in this crate. - keymap_
registry - Re-export shim —
KeymapCapability,KeymapError,KeymapHandle,KeymapRegistry,LayerId, andPushLayerKindmoved tolattice-keymapin K.3 (2026-06-07).KeymapReverseLookupHandlestays here because it implementslattice_completion::KeymapReverseLookup—lattice-keymapcannot depend onlattice-completion. - keymap_
replace - Crossterm-coupled test harness for the renderer-neutral
lattice_host::keymap_replacecatalog. Production code moved to lattice-host in slice 5.4 / slice 4; the tests stay here because theirev()helper buildsKeyChordvalues viacrate::chord::from_event(&KeyEvent { ... }). - keymap_
trie - Re-export shim —
KeymapTrie,KeymapLayer,BoundCommand, andLookupResultmoved tolattice-keymapin K.3 (2026-06-07). Existinguse crate::keymap_trie::{...}callers in this crate continue to work unchanged. - keymap_
visual - Crossterm-coupled test harness for the renderer-neutral
lattice_host::keymap_visualcatalog. Production code moved to lattice-host in slice 5.4 / slice 4; the tests stay here because theirev()helper buildsKeyChordvalues viacrate::chord::from_event(&KeyEvent { ... }). - modes
- Major modes for buffer kinds owned by the TUI layer.
- oil
- Oil buffer model – re-exported from
lattice-oil. - pane
- M.4 follow-up: pane geometry moved to
lattice-core::ui::pane. Re-exported here for transitional compatibility. - pane_
render - Mode-keyed pane render dispatch (M.4 follow-up).
- picker_
sources - TUI-coupled test harness for the renderer-neutral
lattice_picker::picker_sourcesfirst-party source catalog. Slice 5.7.B.0 moved the production code to lattice-picker; the tests stay here because theirapp_with(...)helper builds a real ui-tuiAppso each source’sinit/acceptcan be exercised against a livePickerContextsnapshot. Thelattice_picker::picker_sourcestest module (in-tree, next to the source impls) covers the pure formatters and grep-line parser; those don’t need anApp. - popup
- Popup placement model – re-exported from
lattice-core::ui::popup. - render
- Frame rendering. Pure where it can be (line composition is testable);
IO-bound where ratatui needs it (
draw_frameaccepting aFrame). - runtime
- Terminal IO loop. Sets up raw mode + alt screen, draws frames, polls events, restores terminal state on exit.
- theme
- UI theme (DESIGN.md §5.6, §5.12).
Macros§
- keymap_
entry - Construct a
KeymapEntrywith the row’s source location captured at the macro invocation site. Forms:
Structs§
- Buffer
Entry - One slot in the registry. The kind-specific data lives in
BufferData; flags + id + name apply uniformly. - Buffer
Flags - Vim-style per-buffer flags (DESIGN.md §5.9). The shape is fixed
now so additions don’t churn every call site; v1 ships with
listedpopulated (:bn/:bp/:lsskip unlisted buffers once the wiring lands) andhiddenreserved for “keep loaded without a window” semantics. Both default to “normal buffer” (listed = true, hidden = false). - Buffer
Id - Stable monotonic handle identifying one buffer instance. Two
buffers with the same
BufferKindstill have distinct ids. The App allocates these viaBufferId::nextat buffer- creation time and stores them on each buffer + on every position-history entry. - Buffer
Registry - The App’s buffer registry. Methods take
&selfand lock internally; the registry isCloneso the App’sBufferStoreservice impl can hold a clone for cross-thread access. - Document
Entry - Per-document registry payload. Each entry carries the actor
handle plus per-document tree-sitter
Syntaxstate, fold list, and any other “lives with this buffer until it closes” state. - Echo
Message - Single-line message rendered in the echo area below the mode
line (DESIGN.md §5.9.10). Replaced by the next call to
App::set_message(no timeout-based fade yet). - File
Tree Mode - Major mode for file-tree buffers. Read-only contribution
(
ReadOnly = true); any buffer whose major isfile-tree-moderejects mutating operators. - Help
Mode help-mode— the minor that makes a (markdown-major) buffer a help buffer: read-only, gutterless, no-file,<Esc>dismisses it, and its motions run through the read-only help invocation runner. Activated by the host on:help/:describe-*/:apropos/:keymap/ … views; see the module docs.- OilMode
- Major mode for oil-style directory-listing buffers. Any
buffer whose major is
oil-modeis anOilBuffer; the renderer dispatches accordingly. - PaneId
- Process-monotonic pane id. Distinct from
BufferId: a pane holds a buffer + viewport, but two panes can show the same buffer. Allocated byPaneId::nextat split time. - Pane
Rect - Geometry rectangle in screen coordinates. Mirrors ratatui’s
Rectshape so the renderer can hand the result straight to the layout routines without an extra conversion. - Pane
State - One leaf in the pane tree. Carries the per-pane viewport state
for its content buffer; switching the active pane swaps these
fields with
App::cursor/App::scrollso motion code stays unchanged. - Pane
Tree - The pane tree owned by
App(DESIGN.md §5.9, lives inlattice-ui-tui). v1 supports arbitrary recursive splits; the sole constraint is that the active pane must always exist (closing the last pane is a no-op so the App is never “paneless”). - Styled
Span - Byte-range span within one source line, carrying a semantic
Style. - Syntax
- Translate
Context - TuiRenderer
Enums§
- Action
- Buffer
Data - Buffer
Kind - Which kind of buffer the App’s input pipeline currently routes
to. The chord grammar, motions, and position history are shared;
kind only matters at a few discrete decision points: which cursor
a motion mutates, whether mutating actions are accepted (most
non-document kinds are read-only), and which buffer-local
bindings apply (Help binds
<CR>to follow-link, FileTree binds<CR>to follow-entry, etc.). - Echo
Level - Renderer-side display level for echo messages. Mirrors
lattice_grammar::EchoLevel(wire-typed) but kept separate so renderers can adopt their own display semantics around the shared wire levels. - ExCommand
Error - Lang
- Pane
Direction <C-w>h/j/k/lcardinal navigation. Geometry-aware: walks the tree to find the spatial neighbour of the active pane.- Pane
Node - Internal node of the pane tree. Leaves reference a
PaneStateby index inPaneTree::leaves; splits hold two children with an explicit orientation and a ratio. New splits start atDEFAULT_SPLIT_RATIO;PaneTree::resize_active_splitandPaneTree::equalize_ratiosadjust them. - Split
Orientation - Direction the user pressed after
<C-w>to navigate or split. - Style
- Semantic style category emitted by the tree-sitter highlighter.
Functions§
- major_
mode_ id_ for_ buffer_ kind - Resolve the default major-mode id for a
BufferKindvia the registry’s kind index (H.2). - register_
buffer_ kind_ modes - M.4 follow-up: the per-kind modes (HelpMode, HoverMode,
FileTreeMode, OilMode) moved to
lattice_mode::modesand register throughlattice_mode::modes::register_foundation_modesalongsideTextMode. This shim is kept as a no-op so existingregister_buffer_kind_modescallers don’t break; the App’s boot path now callsregister_foundation_modesdirectly and drops this helper in a follow-up.