pub struct PlainRenderer<W: Write + Send> { /* private fields */ }Expand description
Plain-text renderer for pipes, CI, dumb terminals, and TUI-incompatible
terminals (e.g. JetBrains JediTerm — see lib.rs JediTerm fallback).
No raw-mode dependencies, no DECSTBM, no cursor positioning.
Plain mode does support a few low-effort UX wins on top of bare
printf, all gated by TerminalCaps:
- Spinner via
\r— overwrites the same line during streaming, so users see “in progress” feedback without animation tearing (cooked-mode\ralways works; this is whatread-with-progress scripts have used for decades). - SGR colours — red errors, green/red ✓/✗, cyan tool-call names
when
caps.colorsis on. Pure inline SGR; no positioning required. ❯chevron — replaces>whencaps.unicode_symbolsis on, so the prompt visually matches the retained-mode chevron. Same two-cell width as>so layout math is unchanged.
Implementations§
Source§impl PlainRenderer<BufWriter<Stdout>>
impl PlainRenderer<BufWriter<Stdout>>
Source§impl<W: Write + Send> PlainRenderer<W>
impl<W: Write + Send> PlainRenderer<W>
Sourcepub fn with_writer(out: W) -> Self
pub fn with_writer(out: W) -> Self
Backwards-compat constructor used by older test paths. Probes
caps from the environment — fine for production, but tests that
want predictable behaviour should use with_writer_and_caps or
the explicit with_writer_caps_and_interactive.
Sourcepub fn with_writer_and_caps(out: W, caps: TerminalCaps) -> Self
pub fn with_writer_and_caps(out: W, caps: TerminalCaps) -> Self
Defaults interactive_terminal to caps.tty. Production
callers in lib.rs use with_writer_caps_and_interactive
instead because the force_plain branch needs to pass the
PRE-mutation tty value (caps.tty has already been zeroed by
then so the renderer would otherwise think it’s in pipe mode).
Sourcepub fn with_writer_caps_and_interactive(
out: W,
caps: TerminalCaps,
interactive_terminal: bool,
) -> Self
pub fn with_writer_caps_and_interactive( out: W, caps: TerminalCaps, interactive_terminal: bool, ) -> Self
Explicit constructor that decouples caps.tty from the
echo-handling decision. Used by lib.rs to pass the original
tty value alongside a force_plain-mutated caps.
Trait Implementations§
Source§impl<W: Write + Send> Renderer for PlainRenderer<W>
impl<W: Write + Send> Renderer for PlainRenderer<W>
Source§fn render(&mut self, line: UiLine)
fn render(&mut self, line: UiLine)
flush() to force.fn flush(&mut self)
Source§fn reset(&mut self)
fn reset(&mut self)
erase_footer at a position the terminal cursor is no
longer at, corrupting every subsequent ANSI cursor move.Source§fn clear_screen(&mut self)
fn clear_screen(&mut self)
\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).Source§fn suspend_for_external(&mut self)
fn suspend_for_external(&mut self)
/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.Source§fn resume_from_external(&mut self)
fn resume_from_external(&mut self)
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).Source§fn flush_deferred(&mut self)
fn flush_deferred(&mut self)
Source§fn pop_approval_prompt(&mut self)
fn pop_approval_prompt(&mut self)
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.Source§fn on_resize(&mut self, _cols: u16, _rows: u16)
fn on_resize(&mut self, _cols: u16, _rows: u16)
(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. Read moreSource§fn scroll_body(&mut self, _delta: i32)
fn scroll_body(&mut self, _delta: i32)
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). Read moreSource§fn scroll_body_to_top(&mut self)
fn scroll_body_to_top(&mut self)
fn scroll_body_to_bottom(&mut self)
Source§fn begin_selection(&mut self, _col: u16, _row: u16)
fn begin_selection(&mut self, _col: u16, _row: u16)
fn update_selection(&mut self, _col: u16, _row: u16)
fn end_selection(&mut self)
Source§fn copy_selection(&mut self) -> bool
fn copy_selection(&mut self) -> bool
true if a non-empty selection was copied. Read more/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. Read moreAuto Trait Implementations§
impl<W> Freeze for PlainRenderer<W>where
W: Freeze,
impl<W> RefUnwindSafe for PlainRenderer<W>where
W: RefUnwindSafe,
impl<W> Send for PlainRenderer<W>
impl<W> Sync for PlainRenderer<W>where
W: Sync,
impl<W> Unpin for PlainRenderer<W>where
W: Unpin,
impl<W> UnsafeUnpin for PlainRenderer<W>where
W: UnsafeUnpin,
impl<W> UnwindSafe for PlainRenderer<W>where
W: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more