Expand description
Presenter: state-tracked ANSI emission.
The Presenter transforms buffer diffs into minimal terminal output by tracking the current terminal state and only emitting sequences when changes are needed.
§Design Principles
- State tracking: Track current style, link, and cursor to avoid redundant output
- Run grouping: Use ChangeRuns to minimize cursor positioning
- Single write: Buffer all output and flush once per frame
- Synchronized output: Use DEC 2026 to prevent flicker on supported terminals
§Usage
ⓘ
use ftui_render::presenter::Presenter;
use ftui_render::buffer::Buffer;
use ftui_render::diff::BufferDiff;
use ftui_core::terminal_capabilities::TerminalCapabilities;
let caps = TerminalCapabilities::detect();
let mut presenter = Presenter::new(std::io::stdout(), caps);
let mut current = Buffer::new(80, 24);
let mut next = Buffer::new(80, 24);
// ... render widgets into `next` ...
let diff = BufferDiff::compute(¤t, &next);
presenter.present(&next, &diff)?;
std::mem::swap(&mut current, &mut next);Structs§
- Presenter
- State-tracked ANSI presenter.
- Terminal
Capabilities - Terminal capability model.