pub trait Renderer: Send {
Show 18 methods
// Required methods
fn render(&mut self, line: UiLine);
fn flush(&mut self);
fn shutdown(&mut self);
fn reset(&mut self);
fn clear_screen(&mut self);
fn suspend_for_external(&mut self);
fn resume_from_external(&mut self);
fn flush_deferred(&mut self);
// Provided methods
fn pop_approval_prompt(&mut self) { ... }
fn on_resize(&mut self, _cols: u16, _rows: u16) { ... }
fn scroll_body(&mut self, _delta: i32) { ... }
fn scroll_body_to_top(&mut self) { ... }
fn scroll_body_to_bottom(&mut self) { ... }
fn begin_selection(&mut self, _col: u16, _row: u16) { ... }
fn update_selection(&mut self, _col: u16, _row: u16) { ... }
fn end_selection(&mut self) { ... }
fn copy_selection(&mut self) -> bool { ... }
fn refresh_welcome_banner(&mut self, _model: &str, _working_dir: &str) { ... }
}Required Methods§
Sourcefn render(&mut self, line: UiLine)
fn render(&mut self, line: UiLine)
Emit one UiLine. Implementations may batch internally; call flush() to force.
fn flush(&mut self)
Sourcefn reset(&mut self)
fn reset(&mut self)
Forget all cached rendering state (footer rows, last footer snapshot,
assistant-text mid-line buffer, markdown parser) AND clear the
physical terminal screen. Used by callers that hand control back
to a non-TUI process (e.g. the blocking OAuth flow in /login)
and then want a clean slate — without this, the next render
tries to erase_footer at a position the terminal cursor is no
longer at, corrupting every subsequent ANSI cursor move.
Sourcefn clear_screen(&mut self)
fn clear_screen(&mut self)
Wipe the physical terminal with \x1b[2J\x1b[H and flush.
Does not touch cached footer/stream state — callers that want a
full state wipe should call reset() instead. Use this when only
the visible scrollback should be cleared (e.g. the /clear
command after which the footer immediately redraws).
Sourcefn suspend_for_external(&mut self)
fn suspend_for_external(&mut self)
Hand the terminal off to a non-TUI child process (blocking OAuth
flow, /shell, etc.): disable raw mode + bracketed paste, finish
any pending writes. After this returns, the child is free to use
the terminal in cooked mode; resume_from_external() must be
called before any further render() calls.
Sourcefn resume_from_external(&mut self)
fn resume_from_external(&mut self)
Take the terminal back after suspend_for_external(): re-enable
raw mode + bracketed paste AND call reset() to wipe the cached
state (the child wrote to stdout in cooked mode, so our cursor
tracking is now lying).
Sourcefn flush_deferred(&mut self)
fn flush_deferred(&mut self)
Paint any throttled payload that’s been sitting in the deferred queue past its throttle window. Called from the event loop on a ~50fps timer so the “trailing edge” of a burst of input renders actually lands — without this tick a lone stale payload would stay invisible until the next unrelated render arrived.
Implementations without throttling (e.g. PlainRenderer) can treat this as a flush.
Provided Methods§
Sourcefn pop_approval_prompt(&mut self)
fn pop_approval_prompt(&mut self)
Remove the most recent ApprovalPrompt body row, if the tail
row is one. Called by the event loop after the user responds
Y/A/N so the prompt stops sitting in the body above the footer.
Default: no-op — implementations that stream body lines to
stdout (plain/pipe mode) can’t retract them.
Sourcefn on_resize(&mut self, _cols: u16, _rows: u16)
fn on_resize(&mut self, _cols: u16, _rows: u16)
Terminal window was resized to (cols, rows). DECSTBM-based
renderers must re-issue the scroll region (\x1b[1;H-N r) so
the fixed footer stays pinned to the new bottom. Non-DECSTBM
renderers can treat this as a redraw hint or a no-op.
Default is no-op — backends that don’t care about geometry (Plain, tests) don’t need to override.
Sourcefn scroll_body(&mut self, _delta: i32)
fn scroll_body(&mut self, _delta: i32)
Scroll the body viewport up (negative delta) or down
(positive delta) by delta rows. Used by AltScreenRenderer
to support PageUp / PageDown / arrow-up scrollback navigation
inside the alt-screen (where the host terminal’s native
scrollback is unavailable).
Default no-op for renderers that delegate scrollback to the host terminal (RetainedRenderer’s DECSTBM path; PlainRenderer streaming to stdout).
Sourcefn scroll_body_to_top(&mut self)
fn scroll_body_to_top(&mut self)
Jump the body viewport to the absolute top / bottom of scrollback. Used for Home / End key handling.
fn scroll_body_to_bottom(&mut self)
Sourcefn begin_selection(&mut self, _col: u16, _row: u16)
fn begin_selection(&mut self, _col: u16, _row: u16)
Mouse text-selection hooks. Backends that own mouse capture can override these; streaming/native-scrollback backends keep host terminal selection behavior and no-op here.
fn update_selection(&mut self, _col: u16, _row: u16)
fn end_selection(&mut self)
Sourcefn copy_selection(&mut self) -> bool
fn copy_selection(&mut self) -> bool
Copy the current mouse-selection text to the system clipboard
(using arboard, not OSC 52) and clear the selection highlight.
Returns true if a non-empty selection was copied.
This is the Ctrl+C fallback for terminals (Windows Terminal,
conhost) that ignore OSC 52 — the user selects text with the
mouse, then presses Ctrl+C to copy it. AltScreenRenderer
implements this; other backends return false (they use the
host terminal’s native selection).
Update the cached welcome banner’s model / working_dir fields in
place and trigger a repaint of the banner rows. Used after the
QR-onboarding /codingplan claim finishes: the banner was
painted at the top of scrollback with model="" (the claim
hadn’t picked a default provider yet) — once the claim writes
ctx.model_name, this hook splices the resolved model into the
existing banner rows so the user doesn’t see a permanently
blank model bullet.
Default no-op: renderers without a retained body buffer can’t edit already-emitted rows in place.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".