Skip to main content

Crate lattice_ui_tui

Crate lattice_ui_tui 

Source
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§

pub use app::App;
pub use input::translate;
pub use runtime::run;

Modules§

actions
App-side action registrations – the CommandKind::Action peers 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_with calls.
app
Pure application state and transitions.
buffer_registry
Unified buffer registry (DESIGN.md §5.9).
buffers
Buffer kind + id + flags – moved from lattice-ui-tui to the renderer-agnostic substrate in Phase 5.2 first wave.
cells_render
B2.4 (2026-06-04): DisplayMatrix → ratatui span conversion.
chord
Crossterm → KeyChord adapter for the TUI renderer.
clipboard
CB.2 / CB.4 (docs/dev/architecture/clipboard.md §4): the TUI’s lattice_core::Clipboard backend. Two implementations composed by TuiClipboard::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_insert catalog. Production code moved to lattice-host in slice 5.4 / slice 4; the tests stay here because their ev() helper builds KeyChord values via crate::chord::from_event(&KeyEvent { ... }).
keymap_normal
Crossterm-coupled test harness for the renderer-neutral lattice_host::keymap_normal catalog. Slice 5.4 / slice 3 moved the production code to lattice-host; the tests stay here because their ev() helper builds KeyChord values via crate::chord::from_event(&KeyEvent { ... }), and the crossterm adapter only exists in this crate.
keymap_registry
Re-export shim — KeymapCapability, KeymapError, KeymapHandle, KeymapRegistry, LayerId, and PushLayerKind moved to lattice-keymap in K.3 (2026-06-07). KeymapReverseLookupHandle stays here because it implements lattice_completion::KeymapReverseLookup — lattice-keymap cannot depend on lattice-completion.
keymap_replace
Crossterm-coupled test harness for the renderer-neutral lattice_host::keymap_replace catalog. Production code moved to lattice-host in slice 5.4 / slice 4; the tests stay here because their ev() helper builds KeyChord values via crate::chord::from_event(&KeyEvent { ... }).
keymap_trie
Re-export shim — KeymapTrie, KeymapLayer, BoundCommand, and LookupResult moved to lattice-keymap in K.3 (2026-06-07). Existing use crate::keymap_trie::{...} callers in this crate continue to work unchanged.
keymap_visual
Crossterm-coupled test harness for the renderer-neutral lattice_host::keymap_visual catalog. Production code moved to lattice-host in slice 5.4 / slice 4; the tests stay here because their ev() helper builds KeyChord values via crate::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_sources first-party source catalog. Slice 5.7.B.0 moved the production code to lattice-picker; the tests stay here because their app_with(...) helper builds a real ui-tui App so each source’s init / accept can be exercised against a live PickerContext snapshot. The lattice_picker::picker_sources test module (in-tree, next to the source impls) covers the pure formatters and grep-line parser; those don’t need an App.
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_frame accepting a Frame).
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 KeymapEntry with the row’s source location captured at the macro invocation site. Forms:

Structs§

BufferEntry
One slot in the registry. The kind-specific data lives in BufferData; flags + id + name apply uniformly.
BufferFlags
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 listed populated (:bn / :bp / :ls skip unlisted buffers once the wiring lands) and hidden reserved for “keep loaded without a window” semantics. Both default to “normal buffer” (listed = true, hidden = false).
BufferId
Stable monotonic handle identifying one buffer instance. Two buffers with the same BufferKind still have distinct ids. The App allocates these via BufferId::next at buffer- creation time and stores them on each buffer + on every position-history entry.
BufferRegistry
The App’s buffer registry. Methods take &self and lock internally; the registry is Clone so the App’s BufferStore service impl can hold a clone for cross-thread access.
DocumentEntry
Per-document registry payload. Each entry carries the actor handle plus per-document tree-sitter Syntax state, fold list, and any other “lives with this buffer until it closes” state.
EchoMessage
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).
FileTreeMode
Major mode for file-tree buffers. Read-only contribution (ReadOnly = true); any buffer whose major is file-tree-mode rejects mutating operators.
HelpMode
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-mode is an OilBuffer; 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 by PaneId::next at split time.
PaneRect
Geometry rectangle in screen coordinates. Mirrors ratatui’s Rect shape so the renderer can hand the result straight to the layout routines without an extra conversion.
PaneState
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::scroll so motion code stays unchanged.
PaneTree
The pane tree owned by App (DESIGN.md §5.9, lives in lattice-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”).
StyledSpan
Byte-range span within one source line, carrying a semantic Style.
Syntax
TranslateContext
TuiRenderer

Enums§

Action
BufferData
BufferKind
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.).
EchoLevel
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.
ExCommandError
Lang
PaneDirection
<C-w>h/j/k/l cardinal navigation. Geometry-aware: walks the tree to find the spatial neighbour of the active pane.
PaneNode
Internal node of the pane tree. Leaves reference a PaneState by index in PaneTree::leaves; splits hold two children with an explicit orientation and a ratio. New splits start at DEFAULT_SPLIT_RATIO; PaneTree::resize_active_split and PaneTree::equalize_ratios adjust them.
SplitOrientation
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 BufferKind via 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::modes and register through lattice_mode::modes::register_foundation_modes alongside TextMode. This shim is kept as a no-op so existing register_buffer_kind_modes callers don’t break; the App’s boot path now calls register_foundation_modes directly and drops this helper in a follow-up.