Skip to main content

Renderer

Struct Renderer 

Source
pub struct Renderer { /* private fields */ }
Expand description

Differential terminal renderer.

Tracks the previous frame to enable efficient redrawing. The strategy is automatically reset to Diff after each render.

Implementations§

Source§

impl Renderer

Source

pub fn render( &mut self, term: &mut dyn Terminal, rendered: &Rendered, ) -> Result<()>

Write the rendered output to the terminal using the current strategy.

This implementation closely follows the original TypeScript TUI renderer:

  • FirstRender: outputs all lines without clearing (assumes clean alternate screen).
  • FullRedraw: clears screen + scrollback, then outputs all lines.
  • Diff: computes first/last changed line, moves cursor there, and only rewrites the changed region using \x1b[2K per line.
Source§

impl Renderer

Source

pub fn new() -> Self

Create a new renderer with no previous frame and FirstRender strategy.

Source

pub fn set_strategy(&mut self, strategy: RenderStrategy)

Override the strategy for the next render call.

Source

pub fn previous(&self) -> Option<&Rendered>

Access the previously rendered frame, if any.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.