pub struct TextTerminal<Backend>where
    Backend: TerminalBackend,{ /* private fields */ }
Expand description

A text-based terminal that supports the ANSI, xterm, VT100, and other standards.

The terminal’s text buffer (scrollback buffer) is simply a sequence of Units, in which each Unit contains one or more characters to be displayed. The scrollback buffer is logically a 2-D array of Units but is stored on a per-line basis, such that a Line is a Vec<Unit>, and the buffer itself is a Vec<Line>. This representation helps avoid huge contiguous dynamic memory allocations.

Implementations§

source§

impl<Backend: TerminalBackend> TextTerminal<Backend>

source

pub fn new(width: u16, height: u16, backend: Backend) -> TextTerminal<Backend>

Create an empty TextTerminal with no text content.

Arguments
  • (width, height): the size of the terminal’s backing screen in number of (columns, rows).
  • backend: the I/O stream to which data bytes will be written.

For example, a standard VGA text mode terminal is 80x25 (columns x rows).

source

pub fn handle_input<R: Read>(&mut self, reader: &mut R) -> Result<usize>

Pulls as many bytes as possible from the given [Read]er and handles that stream of bytes as input into this terminal.

Returns the number of bytes read from the given reader.

source

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

Flushes the entire viewable region of the terminal’s screen to the backend output stream.

No caching or performance optimizations are used.

source

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

Resizes this terminal’s screen to be width columns and height rows (lines), in units of number of characters.

Currently, this does not automatically flush the terminal, redisplay its output, or recalculate its cursor position.

Note: values will be adjusted to the minimum width and height of 2.

source

pub fn screen_size(&self) -> ScreenSize

Returns the size of this terminal’s screen.

Auto Trait Implementations§

§

impl<Backend> RefUnwindSafe for TextTerminal<Backend>where Backend: RefUnwindSafe,

§

impl<Backend> Send for TextTerminal<Backend>where Backend: Send,

§

impl<Backend> Sync for TextTerminal<Backend>where Backend: Sync,

§

impl<Backend> Unpin for TextTerminal<Backend>where Backend: Unpin,

§

impl<Backend> UnwindSafe for TextTerminal<Backend>where Backend: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.