Skip to main content

OutputBuffer

Struct OutputBuffer 

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

Pre-allocated buffer for building ANSI escape sequences.

All output is accumulated here, then flushed in a single write() syscall to prevent terminal flickering.

Implementations§

Source§

impl OutputBuffer

Source

pub fn with_capacity(capacity: usize) -> Self

Create a new output buffer with the given capacity.

Source

pub fn new() -> Self

Create a buffer sized for a typical terminal (4KB).

Source

pub fn clear(&mut self)

Clear the buffer for reuse.

Source

pub fn as_bytes(&self) -> &[u8]

Get the buffer contents.

Source

pub const fn len(&self) -> usize

Get the buffer length.

Source

pub const fn is_empty(&self) -> bool

Check if buffer is empty.

Source

pub fn write_raw(&mut self, bytes: &[u8])

Write raw bytes.

Source

pub fn write_str(&mut self, s: &str)

Write a string.

Source

pub fn cursor_move(&mut self, x: u16, y: u16)

Move cursor to (x, y) position (1-indexed for ANSI).

Source

pub fn cursor_hide(&mut self)

Hide cursor.

Source

pub fn cursor_show(&mut self)

Show cursor.

Source

pub fn set_fg(&mut self, color: Rgb)

Set foreground color (true color).

Source

pub fn set_bg(&mut self, color: Rgb)

Set background color (true color).

Source

pub fn reset_attrs(&mut self)

Reset all attributes.

Source

pub fn clear_screen(&mut self)

Clear the entire screen.

Source

pub fn flush_to<W: Write>(&self, writer: &mut W) -> Result<()>

Flush to a writer in a single syscall.

§Errors

Returns an error if the underlying writer fails.

Trait Implementations§

Source§

impl Default for OutputBuffer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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.