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>
impl<W: Write> Presenter<W>
Sourcepub fn new(writer: W, capabilities: TerminalCapabilities) -> Self
pub fn new(writer: W, capabilities: TerminalCapabilities) -> Self
Create a new presenter with the given writer and capabilities.
Sourcepub fn capabilities(&self) -> &TerminalCapabilities
pub fn capabilities(&self) -> &TerminalCapabilities
Get the terminal capabilities.
Sourcepub fn present(
&mut self,
buffer: &Buffer,
diff: &BufferDiff,
) -> Result<PresentStats>
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:
- Begins synchronized output (if supported)
- Emits changes based on the diff
- Resets style and closes links
- Ends synchronized output
- Flushes all buffered output
Sourcepub fn present_with_pool(
&mut self,
buffer: &Buffer,
diff: &BufferDiff,
pool: Option<&GraphemePool>,
links: Option<&LinkRegistry>,
) -> Result<PresentStats>
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.
Sourcepub fn clear_screen(&mut self) -> Result<()>
pub fn clear_screen(&mut self) -> Result<()>
Clear the entire screen.
Sourcepub fn clear_line(&mut self, y: u16) -> Result<()>
pub fn clear_line(&mut self, y: u16) -> Result<()>
Clear a single line.
Sourcepub fn hide_cursor(&mut self) -> Result<()>
pub fn hide_cursor(&mut self) -> Result<()>
Hide the cursor.
Sourcepub fn show_cursor(&mut self) -> Result<()>
pub fn show_cursor(&mut self) -> Result<()>
Show the cursor.
Sourcepub fn position_cursor(&mut self, x: u16, y: u16) -> Result<()>
pub fn position_cursor(&mut self, x: u16, y: u16) -> Result<()>
Position the cursor at the specified coordinates.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Reset the presenter state.
Useful after resize or when terminal state is unknown.
Sourcepub fn into_inner(self) -> Result<W, Error>
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> 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