Struct text_terminal::TextTerminal
source · 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 Unit
s,
in which each Unit
contains one or more characters to be displayed.
The scrollback buffer is logically a 2-D array of Unit
s 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>
impl<Backend: TerminalBackend> TextTerminal<Backend>
sourcepub fn new(width: u16, height: u16, backend: Backend) -> TextTerminal<Backend>
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).
sourcepub fn handle_input<R: Read>(&mut self, reader: &mut R) -> Result<usize>
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.
sourcepub fn flush(&mut self) -> Result<usize>
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.
sourcepub fn resize_screen(&mut self, width: u16, height: u16)
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
.
sourcepub fn screen_size(&self) -> ScreenSize
pub fn screen_size(&self) -> ScreenSize
Returns the size of this terminal’s screen.