Expand description
OpenTUI - High-performance terminal UI rendering engine
OpenTUI is a Rust port of the OpenTUI Zig core. It is a rendering engine, not a framework: you get precise control over buffers, cells, colors, and text without a prescribed widget tree or event loop.
§How This Crate Fits In
This repository is a single-crate system. The opentui crate is the core
engine that applications build on. You provide your own application loop
and input handling; OpenTUI provides the rendering, text, and terminal
primitives that make that loop fast and correct.
§Architecture At A Glance
renderer: Double-buffered rendering, diff detection, hit testingbuffer: Cell grids, scissor clipping, opacity stacking, compositingcell/style/color: The core visual primitives (Cell, Style, Rgba)ansi: ANSI escape emission with state tracking for minimal outputterminal: Raw mode and capability detection (mouse, sync output, color)text: Rope-backed text buffers, editing, wrapping, and viewsunicode: Grapheme iteration and display-width calculationinput: Parser that turns raw terminal bytes into structured eventshighlight: Tokenization and theming for syntax-highlighted buffersgrapheme_pool/link: Interned graphemes and OSC 8 hyperlink storageevent/error: Lightweight callbacks and error types
§Data Flow
App draws into OptimizedBuffer
-> Renderer diffs back vs front buffers
-> AnsiWriter emits minimal ANSI sequences
-> Terminal writes to stdout (optionally with sync output)This flow is intentionally simple: the rendering engine owns output timing and correctness, while your application owns structure and behavior.
Re-exports§
pub use cell::Cell;pub use cell::CellContent;pub use cell::GraphemeId;pub use color::Rgba;pub use error::Error;pub use error::Result;pub use event::LogLevel;pub use event::emit_event;pub use event::emit_log;pub use event::set_event_callback;pub use event::set_log_callback;pub use grapheme_pool::GraphemePool;pub use link::LinkPool;pub use style::Style;pub use style::TextAttributes;pub use input::Event;pub use input::InputParser;pub use input::KeyCode;pub use input::KeyEvent;pub use input::KeyModifiers;pub use input::MouseEvent;pub use ansi::ColorMode;pub use buffer::OptimizedBuffer;pub use highlight::HighlightedBuffer;pub use highlight::Theme;pub use highlight::ThemeRegistry;pub use highlight::Token;pub use highlight::TokenKind;pub use highlight::TokenizerRegistry;pub use renderer::RenderStats;pub use renderer::Renderer;pub use renderer::RendererOptions;pub use terminal::Capabilities;pub use terminal::ColorSupport;pub use terminal::RawModeGuard;pub use terminal::Terminal;pub use terminal::enable_raw_mode;pub use terminal::is_tty;pub use terminal::terminal_size;pub use text::EditBuffer;pub use text::EditorView;pub use text::TextBuffer;pub use text::TextBufferView;pub use text::VisualCursor;pub use text::WrapMode;pub use unicode::WidthMethod;pub use unicode::set_width_method;
Modules§
- ansi
- ANSI escape sequence generation and buffering.
- buffer
- Cell-based frame buffer with alpha blending and scissoring.
- cell
- Terminal cell type representing a single character position.
- color
- RGBA color type with alpha blending operations.
- error
- Error types for OpenTUI.
- event
- Event and log callback system.
- grapheme_
pool - Reference-counted grapheme pool for multi-codepoint character clusters.
- highlight
- Syntax highlighting and style management.
- input
- Input parsing for terminal events.
- link
- Hyperlink pool for OSC 8 link storage.
- renderer
- Double-buffered terminal renderer with diff detection.
- style
- Text styling with attributes and colors.
- terminal
- Terminal abstraction and capability detection.
- text
- Text storage and editing with styled segments.
- unicode
- Unicode utilities for grapheme handling and display width.