Crate text_terminal
source ·Expand description
A text-mode terminal emulator.
This provides basic support for various standards of control codes and escape sequences:
- ANSI
- VT100
- xterm
This terminal emulator also supports Unicode characters;
see the unicode-segmentation crate.
This support stems from our usage of Rust String
s, which must be valid UTF-8.
The text terminal emulator has several main responsibilities:
- Managing the scrollback buffer, a string of characters that should be printed to the screen.
- Determining which parts of that buffer should be displayed and using the window manager to do so.
- Handling the command line user input.
- Displaying the cursor at the right position
- Handling events delivered from the window manager.
Resources
Structs
- The set of ASCII values that are non-printable characters and require special handling by a terminal emulator.
- A wrapper type around
Color
that is used incrate::AnsiStyleCodes
to set the background color (behind displayed text). - A column index or number of columns in the x-dimension of the screen viewport.
- A wrapper type around
Color
that is used incrate::AnsiStyleCodes
to set the foreground color (for displayed text). - The flags that describe the formatting of a given text character.
- An entire unbroken line of characters (
Unit
s) that has been written to a terminal. - An index of a
Line
in the scrollback buffer. - The set of “frequently-supported” commands to switch terminal modes.
- A row index or number of rows in the y-dimension of the screen viewport.
- A 2D position value that represents a point on the screen, in which
(0, 0)
represents the top-left corner. Thus, a validScreenPoint
must fit be the bounds of the currentScreenSize
. - The size of a terminal screen, expressed as the number of columns (x dimension) by the number of rows (y dimension).
- The scrollback buffer is stored as a row-major vector of
Line
s. - A 2D position value that represents a point in the scrollback buffer, in which
(0, 0)
represents theUnit
at the first column of the first line. - The style of text, including formatting and color choice, for the character(s) displayed in a
Unit
. - A representation of the difference between two
Style
s. - The set of options that determine terminal behavior.
- A text-based terminal that supports the ANSI, xterm, VT100, and other standards.
- A terminal backend that is simply a character device TTY endpoint (a full terminal emulator) on the other side, which only allows writing a stream of bytes to it.
- A wrapper type around
Color
that is used incrate::AnsiStyleCodes
to set the color of the underline for underlined text. - A
Unit
is a single character block displayed in the terminal. - An index of a
Unit
in aLine
in the scrollback buffer.
Enums
- The set of all possible ANSI escape codes for setting text style.
- Whether a Carriage Return subsequently issues a Line Feed (newline / new line).
- The character stored in each
Unit
of the terminal screen. - The set of colors that can be displayed by a terminal emulator.
- A pending action to display content from the terminal’s scrollback buffer on the screen.
- Whether text characters printed to the terminal will be inserted before other characters or will replace/overwrite existing characters.
- Whether a Line Feed (newline / new line) subsequently issues a Carriage Return.
- A pending action to scroll the screen up or down by a number of rows.
- The position (“viewport”) that the terminal is currently scrolled to.
- Whether the screen cursor is visible.
- Whether or not to wrap cursor movement or text display to the previous/next line or row.