Skip to main content

AnsiBackend

Struct AnsiBackend 

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

A backend that writes ANSI escape codes to any Write sink.

Implementations§

Source§

impl<W: Write> AnsiBackend<W>

Source

pub fn new(writer: W, width: u16, height: u16, heartbeat: bool) -> Self

Source

pub fn resize(&mut self, width: u16, height: u16)

Resize the backend dimensions. Caller must clear + redraw after.

Source

pub fn writer(&self) -> &W

Borrow the underlying writer (e.g. &Vec<u8> for off-screen rendering).

Trait Implementations§

Source§

impl<W: Write> Backend for AnsiBackend<W>

Source§

type Error = Error

Error type associated with this Backend.
Source§

fn draw<'a, I>(&mut self, content: I) -> Result<(), Self::Error>
where I: Iterator<Item = (u16, u16, &'a Cell)>,

Draw the given content to the terminal screen. Read more
Source§

fn hide_cursor(&mut self) -> Result<(), Self::Error>

Hide the cursor on the terminal screen. Read more
Source§

fn show_cursor(&mut self) -> Result<(), Self::Error>

Show the cursor on the terminal screen. Read more
Source§

fn get_cursor_position(&mut self) -> Result<Position, Self::Error>

Get the current cursor position on the terminal screen. Read more
Source§

fn set_cursor_position<P: Into<Position>>( &mut self, position: P, ) -> Result<(), Self::Error>

Set the cursor position on the terminal screen to the given x and y coordinates. Read more
Source§

fn clear(&mut self) -> Result<(), Self::Error>

Clears the whole terminal screen Read more
Source§

fn clear_region(&mut self, clear_type: ClearType) -> Result<(), Self::Error>

Clears a specific region of the terminal specified by the [ClearType] parameter Read more
Source§

fn size(&self) -> Result<Size, Self::Error>

Get the size of the terminal screen in columns/rows as a [Size]. Read more
Source§

fn window_size(&mut self) -> Result<WindowSize, Self::Error>

Get the size of the terminal screen in columns/rows and pixels as a [WindowSize]. Read more
Source§

fn flush(&mut self) -> Result<(), Self::Error>

Flush any buffered content to the terminal screen.
§

fn append_lines(&mut self, _n: u16) -> Result<(), Self::Error>

Insert n line breaks to the terminal screen. Read more
§

fn get_cursor(&mut self) -> Result<(u16, u16), Self::Error>

👎Deprecated:

use get_cursor_position() instead which returns Result<Position>

Get the current cursor position on the terminal screen. Read more
§

fn set_cursor(&mut self, x: u16, y: u16) -> Result<(), Self::Error>

👎Deprecated:

use set_cursor_position((x, y)) instead which takes impl Into<Position>

Set the cursor position on the terminal screen to the given x and y coordinates. Read more

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<W> UnsafeUnpin for AnsiBackend<W>
where W: UnsafeUnpin,

§

impl<W> UnwindSafe for AnsiBackend<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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
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.