|
AquilaOS documentation
How it works, and its code
|
The terminal emulator of the virtual terminals. More...
Go to the source code of this file.
Data Structures | |
| struct | [struct].unicode_extra |
Macros | |
| #define | DEFAULT_FG 7 |
| #define | DEFAULT_BG 0 |
Enumerations | |
| enum | { S_GROUND , S_ESC , S_CHARSET , S_HASH , S_PERCENT , S_CSI , S_OSC , S_PALETTE , S_STRING , S_STRING_ESC } |
Functions | |
| static uint8_t | unicode_glyph (uint32_t u) |
| Returns the code page 437 glyph that shows a character best, or '? | |
| static uint8_t | rgb_color (int r, int g, int b) |
| Returns the closest colour of the palette's 6 x 6 x 6 cube or greys, for a 24-bit colour. | |
| static struct vt_cell * | cell (struct vt *vt, int row, int col) |
| Returns a cell of the screen. | |
| static struct vt_cell | blank (struct vt *vt) |
| Returns an erased cell: it takes the current colours, as the Linux console does ("bce"). | |
| static void | erase (struct vt *vt, int row, int from, int to) |
| Erases the cells of a row from column from up to to. | |
| static void | scroll_up (struct vt *vt, int top, int bottom, int n) |
| Scrolls rows top to bottom up by n rows: n erased rows come at the bottom. | |
| static void | scroll_down (struct vt *vt, int top, int bottom, int n) |
| Scrolls rows top to bottom down by n rows: n erased rows come at the top. | |
| static void | move_to (struct vt *vt, int row, int col) |
| Moves the cursor, within the screen, or within the scrolling region in origin mode. | |
| static void | move_rows (struct vt *vt, int n) |
| Moves the cursor up or down n rows. | |
| static void | linefeed (struct vt *vt) |
| Moves the cursor down a row, scrolling at the region's bottom. | |
| static void | reverse_index (struct vt *vt) |
| Moves the cursor up a row, scrolling at the region's top. | |
| static int | tab_stop (struct vt *vt, int col) |
| Returns whether there is a tab stop at a column. | |
| static void | tab_set (struct vt *vt, int col, int set) |
| Sets or clears the tab stop at a column. | |
| static void | tab (struct vt *vt, int n) |
| Moves the cursor n tab stops forward, or back if n is negative. | |
| static void | put_glyph (struct vt *vt, uint8_t ch) |
| Puts a glyph at the cursor, in the current colours and attributes, and moves the cursor on, wrapping at the end of the line. | |
| static void | put_char (struct vt *vt, uint32_t u) |
| Puts a character at the cursor, through the character set in use. | |
| static void | reply (struct vt *vt, const char *s) |
| Queues a reply to a request (DSR, DA), which vt.c gives the terminal as input. | |
| static void | save_cursor (struct vt *vt, struct vt_cursor *save) |
| Saves the cursor: its position, colours, character sets and modes. | |
| static void | restore_cursor (struct vt *vt, struct vt_cursor *save) |
| Restores a saved cursor, within the screen. | |
| static void | clear_screen (struct vt *vt) |
| Erases the whole screen. | |
| static void | alt_screen (struct vt *vt, int on) |
| Shows the alternate screen (xterm's), cleared, or the main one again. | |
| static void | soft_reset (struct vt *vt) |
| Sets the modes and the pen back to the defaults, but not the screen (DECSTR, a soft reset). | |
| void | vt_term_reset (struct vt *vt) |
| Resets a terminal (RIS, ESC c): the defaults, the tab stops every 8 columns, the main screen cleared, and the cursor at the top left. | |
| int | vt_term_init (struct vt *vt, int rows, int cols) |
| Sets a terminal's screens up, the main one and the alternate one, both cleared, and resets it. | |
| static int | param (struct vt *vt, int i, int def) |
| Returns a sequence's parameter i, or def if it is 0 or missing. | |
| static void | sgr (struct vt *vt) |
| Sets the pen's colours and attributes (SGR, CSI ... m). | |
| static void | decset (struct vt *vt, int set) |
| Sets or resets DEC private modes. | |
| static void | csi (struct vt *vt, char f) |
| Runs a CSI sequence whose final character is f, with its parameters. | |
| static void | esc (struct vt *vt, char c) |
| Runs an escape sequence, ESC c, or starts a longer one. | |
| static void | control (struct vt *vt, char c) |
| Runs a control character. | |
| static void | utf8 (struct vt *vt, uint8_t c) |
| Decodes UTF-8, a byte at a time, and puts each character. | |
| static int | hexdigit (char c) |
| Returns a hex digit's value, or -1. | |
| static void | term_char (struct vt *vt, uint8_t c) |
| Takes one byte of what programs write, in the state of the sequence it may be in. | |
| void | vt_term_write (struct vt *vt, const char *buf, size_t size) |
| Takes what programs write to a terminal, and changes its screen. | |
Variables | |
| static const uint8_t | dec_graphics [] |
| static const uint16_t | cp437 [128] |
| static const uint16_t | cp437_symbols [32] |
| static const struct | unicode_extra [] |
The terminal emulator of the virtual terminals.
It does with what programs write what the Linux console does (TERM=linux): control characters, escape and CSI sequences, colours and attributes, scrolling regions, character sets. It also has the parts of xterm that programs commonly use: the alternate screen, and 256 colours. Characters are shown with the 256 glyphs of code page 437: UTF-8 is decoded, and each character is shown with the closest glyph. The emulator only changes the terminal's screen in memory; vt.c draws it.
Definition in file term.c.
| #define DEFAULT_BG 0 |
Definition at line 36 of file term.c.
Referenced by sgr(), soft_reset(), term_char(), and vt_term_init().
| #define DEFAULT_FG 7 |
Definition at line 35 of file term.c.
Referenced by sgr(), soft_reset(), term_char(), and vt_term_init().
| anonymous enum |
|
static |
Shows the alternate screen (xterm's), cleared, or the main one again.
Definition at line 354 of file term.c.
References vt::alt, alt_screen(), clear_screen(), vt::main, and vt::screen.
Referenced by alt_screen(), and decset().
Returns an erased cell: it takes the current colours, as the Linux console does ("bce").
Definition at line 130 of file term.c.
References vt_cell::bg, blank(), vt_cell::fg, and vt::pen.
Returns a cell of the screen.
Definition at line 123 of file term.c.
References vt::cols, and vt::screen.
Referenced by csi(), erase(), put_glyph(), scroll_down(), scroll_up(), and term_char().
|
static |
Erases the whole screen.
Definition at line 347 of file term.c.
References clear_screen(), vt::cols, erase(), and vt::rows.
Referenced by alt_screen(), clear_screen(), csi(), vt_term_init(), and vt_term_reset().
|
static |
Runs a control character.
Definition at line 769 of file term.c.
References vt::col, vt::gl, linefeed(), vt::newline, S_ESC, S_GROUND, vt::state, tab(), and vt::wrap_pending.
Referenced by term_char().
|
static |
Runs a CSI sequence whose final character is f, with its parameters.
Definition at line 557 of file term.c.
References vt::bottom, cell(), clear_screen(), vt::col, vt::cols, csi(), decset(), erase(), vt::insert, vt::intermediate, vt::last, MAX, memmove(), MIN, move_rows(), move_to(), vt::newline, vt::nparams, vt::origin, param(), vt::params, vt::private, put_glyph(), reply(), restore_cursor(), vt::row, vt::rows, save_cursor(), scroll_down(), scroll_up(), sgr(), snprintf(), soft_reset(), tab(), tab_set(), vt::top, and vt::wrap_pending.
Referenced by csi(), and term_char().
|
static |
Sets or resets DEC private modes.
These are the CSI ? n h and CSI ? n l sequences.
Definition at line 520 of file term.c.
References alt_screen(), vt::autowrap, vt::cursor_keys, vt::cursor_visible, decset(), move_to(), vt::nparams, vt::origin, vt::params, restore_cursor(), vt::reverse_screen, save_cursor(), vt::saved_alt, and vt::top.
|
static |
Erases the cells of a row from column from up to to.
Definition at line 136 of file term.c.
References blank(), cell(), and erase().
Referenced by clear_screen(), csi(), erase(), scroll_down(), and scroll_up().
|
static |
Runs an escape sequence, ESC c, or starts a longer one.
Definition at line 720 of file term.c.
References vt::col, esc(), vt::intermediate, vt::keypad, linefeed(), vt::nparams, vt::params, vt::private, reply(), restore_cursor(), reverse_index(), S_CHARSET, S_CSI, S_GROUND, S_HASH, S_OSC, S_PERCENT, S_STRING, save_cursor(), vt::state, tab_set(), and vt_term_reset().
Referenced by esc(), and term_char().
|
static |
Returns a hex digit's value, or -1.
Definition at line 846 of file term.c.
References hexdigit().
Referenced by hexdigit(), and term_char().
|
static |
Moves the cursor down a row, scrolling at the region's bottom.
Definition at line 202 of file term.c.
References vt::bottom, linefeed(), vt::row, vt::rows, scroll_up(), vt::top, and vt::wrap_pending.
Referenced by control(), esc(), linefeed(), and put_glyph().
|
static |
Moves the cursor up or down n rows.
It stops at the scrolling region's margins, if it starts within them.
Definition at line 186 of file term.c.
References vt::bottom, move_rows(), vt::row, vt::rows, vt::top, and vt::wrap_pending.
Referenced by csi(), and move_rows().
|
static |
Moves the cursor, within the screen, or within the scrolling region in origin mode.
Definition at line 174 of file term.c.
References vt::bottom, vt::col, vt::cols, move_to(), vt::origin, vt::row, vt::rows, vt::top, and vt::wrap_pending.
Referenced by csi(), decset(), move_to(), and term_char().
|
static |
Returns a sequence's parameter i, or def if it is 0 or missing.
Definition at line 447 of file term.c.
References vt::nparams, param(), and vt::params.
Puts a character at the cursor, through the character set in use.
Definition at line 284 of file term.c.
References vt::charset, dec_graphics, vt::gl, put_char(), put_glyph(), and unicode_glyph().
Referenced by put_char(), and utf8().
Puts a glyph at the cursor, in the current colours and attributes, and moves the cursor on, wrapping at the end of the line.
Definition at line 261 of file term.c.
References vt::autowrap, cell(), vt_cell::ch, vt::col, vt::cols, vt::insert, vt::last, linefeed(), memmove(), vt::pen, put_glyph(), vt::row, and vt::wrap_pending.
Referenced by csi(), put_char(), put_glyph(), and utf8().
|
static |
Restores a saved cursor, within the screen.
Definition at line 332 of file term.c.
References vt::autowrap, vt::charset, vt_cursor::charset, vt::col, vt_cursor::col, vt::cols, vt::gl, vt_cursor::gl, vt::origin, vt_cursor::origin, vt::pen, vt_cursor::pen, restore_cursor(), vt::row, vt_cursor::row, vt::rows, vt_cursor::wrap, and vt::wrap_pending.
Referenced by csi(), decset(), esc(), and restore_cursor().
|
static |
Moves the cursor up a row, scrolling at the region's top.
Definition at line 213 of file term.c.
References vt::bottom, reverse_index(), vt::row, scroll_down(), vt::top, and vt::wrap_pending.
Referenced by esc(), and reverse_index().
|
static |
Returns the closest colour of the palette's 6 x 6 x 6 cube or greys, for a 24-bit colour.
Definition at line 106 of file term.c.
References rgb_color().
Referenced by rgb_color(), and sgr().
Saves the cursor: its position, colours, character sets and modes.
Definition at line 319 of file term.c.
References vt::autowrap, vt::charset, vt_cursor::charset, vt::col, vt_cursor::col, vt::gl, vt_cursor::gl, vt::origin, vt_cursor::origin, vt::pen, vt_cursor::pen, vt::row, vt_cursor::row, save_cursor(), and vt_cursor::wrap.
Referenced by csi(), decset(), esc(), save_cursor(), and soft_reset().
|
static |
Scrolls rows top to bottom down by n rows: n erased rows come at the top.
Definition at line 160 of file term.c.
References cell(), vt::cols, erase(), memmove(), and scroll_down().
Referenced by csi(), reverse_index(), and scroll_down().
|
static |
Scrolls rows top to bottom up by n rows: n erased rows come at the bottom.
Definition at line 146 of file term.c.
References cell(), vt::cols, erase(), memmove(), and scroll_up().
Referenced by csi(), linefeed(), and scroll_up().
|
static |
Sets the pen's colours and attributes (SGR, CSI ... m).
Definition at line 453 of file term.c.
References vt_cell::attr, vt_cell::bg, DEFAULT_BG, DEFAULT_FG, vt_cell::fg, vt::nparams, vt::params, vt::pen, rgb_color(), sgr(), VT_BLINK, VT_BOLD, VT_DIM, VT_INVISIBLE, VT_ITALIC, VT_REVERSE, and VT_UNDERLINE.
|
static |
Sets the modes and the pen back to the defaults, but not the screen (DECSTR, a soft reset).
Definition at line 366 of file term.c.
References vt::autowrap, vt::bottom, vt_cell::ch, vt::charset, vt::col, vt::cursor_keys, vt::cursor_visible, DEFAULT_BG, DEFAULT_FG, vt::gl, vt::insert, vt::keypad, vt::newline, vt::origin, vt::pen, vt::row, vt::rows, save_cursor(), vt::saved_alt, soft_reset(), vt::top, and vt::wrap_pending.
Referenced by csi(), soft_reset(), and vt_term_reset().
|
static |
Moves the cursor n tab stops forward, or back if n is negative.
Definition at line 242 of file term.c.
References vt::col, vt::cols, tab(), tab_stop(), and vt::wrap_pending.
|
static |
|
static |
Returns whether there is a tab stop at a column.
Definition at line 224 of file term.c.
References tab_stop(), and vt::tabs.
Referenced by tab(), and tab_stop().
Takes one byte of what programs write, in the state of the sequence it may be in.
Definition at line 855 of file term.c.
References cell(), vt_cell::ch, vt::charset, vt::cols, control(), csi(), DEFAULT_BG, DEFAULT_FG, esc(), hexdigit(), vt::intermediate, move_to(), vt::nparams, vt::params, vt::private, vt::rows, S_CHARSET, S_CSI, S_ESC, S_GROUND, S_HASH, S_OSC, S_PALETTE, S_PERCENT, S_STRING, S_STRING_ESC, vt::state, term_char(), and utf8().
Referenced by term_char(), and vt_term_write().
Returns the code page 437 glyph that shows a character best, or '?
'.
Definition at line 84 of file term.c.
References cp437, cp437_symbols, unicode_extra, and unicode_glyph().
Referenced by put_char(), and unicode_glyph().
Decodes UTF-8, a byte at a time, and puts each character.
A broken sequence shows '?'.
Definition at line 809 of file term.c.
References put_char(), put_glyph(), utf8(), vt::utf8, and vt::utf8_left.
Referenced by term_char(), and utf8().
| int vt_term_init | ( | struct vt * | vt, |
| int | rows, | ||
| int | cols ) |
Sets a terminal's screens up, the main one and the alternate one, both cleared, and resets it.
| vt | the terminal |
| rows | the screen's rows |
| cols | the screen's columns |
Definition at line 420 of file term.c.
References vt::alt, vt_cell::ch, clear_screen(), vt::cols, DEFAULT_BG, DEFAULT_FG, kfree(), kmalloc(), vt::main, NULL, vt::pen, vt::rows, vt::screen, vt_term_init(), and vt_term_reset().
Referenced by vt_setup(), and vt_term_init().
| void vt_term_reset | ( | struct vt * | vt | ) |
Resets a terminal (RIS, ESC c): the defaults, the tab stops every 8 columns, the main screen cleared, and the cursor at the top left.
| vt | the terminal |
Definition at line 395 of file term.c.
References clear_screen(), vt::col, vt::last, vt::main, vt::reverse_screen, vt::row, S_GROUND, vt::screen, soft_reset(), vt::state, tab_set(), vt::utf8_left, and vt_term_reset().
Referenced by esc(), vt_term_init(), and vt_term_reset().
Takes what programs write to a terminal, and changes its screen.
| vt | the terminal |
| buf | what was written |
| size | its size, in bytes |
Definition at line 957 of file term.c.
References term_char(), and vt_term_write().
Referenced by vt_kmsg(), vt_term_write(), and vt_tty_output().
|
static |
Definition at line 47 of file term.c.
Referenced by unicode_glyph().
|
static |
Definition at line 67 of file term.c.
Referenced by unicode_glyph().
|
static |
Definition at line 39 of file term.c.
Referenced by put_char().
| const struct [struct].unicode_extra unicode_extra[] |
Referenced by unicode_glyph().