Skip to main content

lattice_ui_tui/
lib.rs

1// Glob imports (`use super::*;`) and other dead `use` items have caused
2// observable rendering glitches in editors with diagnostics overlays --
3// the unused-imports warning's underline + the way some editors composite
4// diagnostic underlines with tree-sitter spans interacted badly enough
5// that lines after the flagged `use` rendered without their syntax colours.
6// Promoting `unused_imports` from warning to deny means every test mod's
7// `use ...::*;` either pays its way or fails the build, so the class of
8// glitch can't slip back in. `cargo check --all-targets` was clean at the
9// time this was added.
10#![deny(unused_imports)]
11
12//! Terminal renderer for `lattice` (DESIGN.md §5.6.1 `TuiRenderer`).
13//!
14//! v1 status: a first-class peer of the GPU UI for headless / SSH /
15//! low-bandwidth use, with documented limitations bound to terminal
16//! capabilities (no variable fonts, monospace cells only, sprites degrade
17//! to fallback glyphs).
18//!
19//! Phase 2 scope: a read-only viewer with cursor motion (hjkl, gg, G),
20//! viewport scrolling, line-number gutter, mode line, and a stub
21//! syntax highlighter (Rust keywords for `.rs` files). The stub highlighter
22//! produces the same `StyledSpan` shape that real tree-sitter integration
23//! (Phase 3) will feed; swapping in tree-sitter does not require rewiring
24//! the renderer.
25//!
26//! Phase 3+ replaces the stub with real tree-sitter queries; the modal
27//! engine drives input through `CommandInvocation`s instead of the
28//! hardcoded `Action` enum used here.
29
30pub mod actor_call_counter;
31pub mod app;
32// S3.b (2026-05-26): cell-grid → ratatui span converter. The
33// substrate→TUI translation layer that turns `lattice_cells::Cell`
34// payloads (fg + bg + modifier flags from the cell-builder
35// worker) into ratatui spans. Anchor:
36// `docs/dev/architecture/cell-grid-renderer.md`.
37pub mod cells_render;
38// CB.2 (docs/dev/architecture/clipboard.md): the TUI's Clipboard backend
39// (native arboard + OSC52 fallback), bound at boot over CB.0's default
40// FakeClipboard.
41pub mod clipboard;
42// Phase 5.2: HOST modules migrated to `lattice-host`. The
43// `pub use` here preserves every existing
44// `lattice_ui_tui::<module>::*` import in downstream crates +
45// this crate's tests + benches; no call-site changes needed.
46pub use lattice_host::{
47    actions, buffer_registry, buffers, excommand, file_tree, folds, help, help_topics,
48    host_generators, keymap, keymap_registry, keymap_trie, modes, oil, pane, popup,
49};
50// Re-export the `keymap_entry!` macro (defined with `#[macro_export]`
51// in lattice-host) at this crate's root so the catalog files
52// (keymap_normal/insert/visual/replace -- still in this crate
53// because their `dispatch_*` functions are crossterm-coupled)
54// keep invoking it as `keymap_entry!` without a path prefix.
55pub use lattice_host::keymap_entry;
56pub mod chord;
57pub mod input;
58pub mod keymap_insert;
59pub mod keymap_normal;
60pub mod keymap_replace;
61pub mod keymap_visual;
62pub mod pane_render;
63pub mod picker_sources;
64pub mod render;
65pub mod runtime;
66pub mod theme;
67// Phase 5.5.E.6: the renderer-neutral typed-option declarations
68// previously in `tui_options` (ui.dim_inactive, ui.separator,
69// ui.separator_color, ui.statusline_*_fg, ui.nerd_fonts) relocated
70// to `lattice_host::ui::theme_options` so the host can read the
71// values directly when synchronising `host_theme` from config
72// (`Editor::sync_host_theme_from_config`). `linkme` self-registers
73// the entries regardless of which crate emitted them, so the boot
74// path's `init_from_linkme()` picks them up unchanged.
75
76pub use app::{Action, App, EchoLevel, EchoMessage};
77
78// Phase 5.B.2: TuiRenderer marker type implementing
79// `lattice_host::Renderer`. The App struct in `app.rs` is now
80// generic over `R: Renderer` with `R = TuiRenderer` as the
81// default, so every existing `App` reference in this crate +
82// downstream consumers keeps resolving via the default. When
83// the App struct moves to lattice-host (Phase 5.B.3),
84// `App` becomes a type alias `pub type App =
85// lattice_host::App<TuiRenderer>;` and this marker stays here
86// as the renderer's identity.
87#[derive(Debug, Clone, Copy, PartialEq, Eq)]
88pub struct TuiRenderer;
89
90impl lattice_host::Renderer for TuiRenderer {
91    type Theme = crate::theme::Theme;
92    type PaneRenderRegistry = crate::pane_render::PaneRenderRegistry;
93}
94pub use buffer_registry::{BufferData, BufferEntry, BufferRegistry, DocumentEntry};
95pub use buffers::{BufferFlags, BufferId, BufferKind};
96pub use excommand::ExCommandError;
97pub use input::{TranslateContext, translate};
98pub use lattice_syntax::{Lang, Style, StyledSpan, Syntax};
99pub use modes::{
100    FileTreeMode, HelpMode, OilMode, major_mode_id_for_buffer_kind, register_buffer_kind_modes,
101};
102pub use pane::{PaneDirection, PaneId, PaneNode, PaneRect, PaneState, PaneTree, SplitOrientation};
103pub use runtime::run;