pub struct Renderer<W: Write> { /* private fields */ }Expand description
Pure TUI renderer with frame diffing and terminal state management.
Uses relative cursor movement (MoveUp + \r) to navigate back to the
start of the managed region. This avoids absolute row tracking, which breaks
when the terminal scrolls content upward.
Cursor invariant: After every render or push_to_scrollback, the
cursor sits at the end of the last managed line unless explicitly
repositioned afterward.
Implementations§
Source§impl<W: Write> Renderer<W>
impl<W: Write> Renderer<W>
pub fn new(writer: W, theme: Theme, size: impl Into<Size>) -> Self
Sourcepub fn render_frame(
&mut self,
f: impl FnOnce(&ViewContext) -> Frame,
) -> Result<()>
pub fn render_frame( &mut self, f: impl FnOnce(&ViewContext) -> Frame, ) -> Result<()>
Render a frame using a closure.
The closure receives a ViewContext and returns a Frame.
pub fn clear_screen(&mut self) -> Result<()>
pub fn push_to_scrollback(&mut self, lines: &[Line]) -> Result<()>
pub fn on_resize(&mut self, size: impl Into<Size>)
pub fn context(&self) -> ViewContext
pub fn set_theme(&mut self, theme: Theme)
pub fn apply_commands(&mut self, commands: Vec<RendererCommand>) -> Result<()>
pub fn writer(&self) -> &W
pub fn test_writer_mut(&mut self) -> &mut W
Auto Trait Implementations§
impl<W> Freeze for Renderer<W>where
W: Freeze,
impl<W> RefUnwindSafe for Renderer<W>where
W: RefUnwindSafe,
impl<W> Send for Renderer<W>where
W: Send,
impl<W> Sync for Renderer<W>where
W: Sync,
impl<W> Unpin for Renderer<W>where
W: Unpin,
impl<W> UnsafeUnpin for Renderer<W>where
W: UnsafeUnpin,
impl<W> UnwindSafe for Renderer<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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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