Expand description
Terminal rendering system for TUI applications
Double buffering and efficient diff-based updates for optimal performance.
§Architecture
The rendering system is composed of:
| Component | Description | Module |
|---|---|---|
| Backend | Low-level terminal I/O abstraction | backend |
| Buffer | Double-buffered screen state | (see Buffer) |
| Cell | Individual terminal cell (char, colors, modifiers) | (see Cell) |
| Terminal | High-level diff-based renderer | (see Terminal) |
| Diff | Efficient buffer diffing algorithm | (see diff) |
| Images | Kitty, iTerm2, and Sixel graphics | Available with image feature |
§Quick Start
ⓘ
use revue::render::{Terminal, Buffer};
// Create terminal
let mut terminal = Terminal::new()?;
// Create buffer matching terminal size
let mut buffer = Buffer::new(terminal.size()?);
// Draw to buffer
buffer.set_string(0, 0, "Hello, World!", style);
// Render with diffing
terminal.draw(&buffer)?;§Double Buffering
Revue uses double buffering for efficient rendering:
- Two buffers of the same size are allocated
- Each frame renders to the “back” buffer
- Buffers are compared to find minimal changes
- Only changed cells are written to the terminal
- Buffers are swapped for the next frame
§Cell Rendering
ⓘ
use revue::render::{Cell, Modifier};
// Create a styled cell
let cell = Cell::new('A')
.fg(Color::Blue)
.bg(Color::Black)
.modifier(Modifier::BOLD);§Image Support
ⓘ
use revue::render::image_protocol::KittyImage;
// Detect image support
if let Some(protocol) = KittyImage::detect() {
// Render image
protocol.draw_image(x, y, &image_data)?;
}§Performance
- Diff-based updates minimize terminal writes
- Batch operations group multiple cell updates
- ANSI escape sequences are cached
- Terminal capabilities are detected once
Re-exports§
pub use backend::Backend;pub use backend::BackendCapabilities;pub use backend::CrosstermBackend;
Modules§
- backend
- Terminal backend abstraction
Structs§
- Batch
Stats - Statistics for render batches
- Buffer
- A buffer holding the terminal state
- Cell
- A single cell in the terminal buffer
- Change
- A change to be applied to the terminal
- Modifier
- Modifier flags for cell styling (1 byte instead of 5)
- Render
Batch - Batched render operations
- Terminal
- Terminal backend for rendering
Enums§
- Buffer
Error - Error type for buffer creation failures
- Render
Op - A single render operation
Functions§
- diff
- Compute the differences between two buffers within specified dirty regions.
- stdout_
terminal - Create a terminal with stdout