Skip to main content

Presenter

Struct Presenter 

Source
pub struct Presenter<W: Write> { /* private fields */ }
Expand description

State-tracked ANSI presenter.

Transforms buffer diffs into minimal terminal output by tracking the current terminal state and only emitting necessary escape sequences.

Implementations§

Source§

impl<W: Write> Presenter<W>

Source

pub fn new(writer: W, capabilities: TerminalCapabilities) -> Self

Create a new presenter with the given writer and capabilities.

Source

pub fn capabilities(&self) -> &TerminalCapabilities

Get the terminal capabilities.

Source

pub fn present( &mut self, buffer: &Buffer, diff: &BufferDiff, ) -> Result<PresentStats>

Present a frame using the given buffer and diff.

This is the main entry point for rendering. It:

  1. Begins synchronized output (if supported)
  2. Emits changes based on the diff
  3. Resets style and closes links
  4. Ends synchronized output
  5. Flushes all buffered output
Source

pub fn present_with_pool( &mut self, buffer: &Buffer, diff: &BufferDiff, pool: Option<&GraphemePool>, links: Option<&LinkRegistry>, ) -> Result<PresentStats>

Present a frame with grapheme pool and link registry.

Source

pub fn clear_screen(&mut self) -> Result<()>

Clear the entire screen.

Source

pub fn clear_line(&mut self, y: u16) -> Result<()>

Clear a single line.

Source

pub fn hide_cursor(&mut self) -> Result<()>

Hide the cursor.

Source

pub fn show_cursor(&mut self) -> Result<()>

Show the cursor.

Source

pub fn position_cursor(&mut self, x: u16, y: u16) -> Result<()>

Position the cursor at the specified coordinates.

Source

pub fn reset(&mut self)

Reset the presenter state.

Useful after resize or when terminal state is unknown.

Source

pub fn flush(&mut self) -> Result<()>

Flush any buffered output.

Source

pub fn into_inner(self) -> Result<W, Error>

Get the inner writer (consuming the presenter).

Flushes any buffered data before returning the writer.

Auto Trait Implementations§

§

impl<W> Freeze for Presenter<W>
where W: Freeze,

§

impl<W> RefUnwindSafe for Presenter<W>
where W: RefUnwindSafe,

§

impl<W> Send for Presenter<W>
where W: Send,

§

impl<W> Sync for Presenter<W>
where W: Sync,

§

impl<W> Unpin for Presenter<W>
where W: Unpin,

§

impl<W> UnwindSafe for Presenter<W>
where W: UnwindSafe,

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.