|
ginnOS
The reference: libc, the libraries and the kernel
|
libvt: the parser, the screens and the scrollback. More...
Macros | |
| #define | PARAMS_MAX 16 |
| #define | OSC_MAX 512 |
| #define | PARAM_MAX 9999 |
Enumerations | |
| enum | { GROUND , ESCAPE , ESCAPE_INTER , CSI , CSI_IGNORE , OSC , OSC_ESCAPE , STRING , STRING_ESCAPE } |
| enum | { CHARSET_ASCII , CHARSET_GRAPHICS } |
Functions | |
| vt_t * | vt_new (int cols, int rows, int scrollback) |
| a terminal of a size, with room for so many lines of scrollback. | |
| void | vt_free (vt_t *vt) |
| void | vt_set_reply (vt_t *vt, vt_reply_t fn, void *user) |
| where the answers go (without it, they are dropped). | |
| void | vt_write (vt_t *vt, const void *data, size_t length) |
| the bytes the program wrote. | |
| void | vt_resize (vt_t *vt, int cols, int rows) |
| a new size. | |
| const vt_line_t * | vt_line (const vt_t *vt, int y) |
| a line of the screen (0 to rows - 1), or of the scrollback (-1 is the newest line, down to -vt_scrollback_lines). | |
| int | vt_scrollback_lines (const vt_t *vt) |
| the lines in the scrollback now | |
| bool | vt_line_dirty (const vt_t *vt, int y) |
| true if the screen line y changed since vt_clean | |
| void | vt_clean (vt_t *vt) |
| forget what changed: the app drew it | |
| size_t | vt_text (const vt_t *vt, int x0, int y0, int x1, int y1, char *out, size_t size) |
| the text from (x0, y0) to (x1, y1), both included, as UTF-8; y as for vt_line. | |
| uint32_t | vt_palette (int index) |
| the RGB colour of palette entry 0 to 255: the 16 colours of xterm, the 6x6x6 cube and the grey ramp. | |
| int | vt_key (const vt_t *vt, vt_key_t key, int mods, char *out) |
| the bytes a key sends, as xterm sends them (the arrows follow DECCKM; with modifiers, ESC [ 1 ; m A). | |
| int | vt_text_key (const char *text, int mods, char *out) |
| the bytes typed text sends: Ctrl with a letter or one of []^_ and space gives the control character, Alt puts ESC in front. | |
| int | vt_mouse (const vt_t *vt, vt_mouse_t kind, int button, int x, int y, int mods, char *out) |
| a mouse report for the program, if its mode asks for this one. | |
| const char * | vt_paste_begin (const vt_t *vt) |
| what goes before and after pasted text: the bracketed paste marks when the program asked for them, else "". | |
| const char * | vt_paste_end (const vt_t *vt) |
libvt: the parser, the screens and the scrollback.
the parser is a state machine after the DEC one (vt100.net): text, ESC, CSI with its parameters, OSC strings, and the strings it ignores (DCS, APC, PM, SOS). control characters act inside a sequence too.
a screen is an array of line pointers, so a scroll moves pointers and not cells. the lines that scroll off the top of the main screen go to the scrollback, a ring of lines.
| #define PARAMS_MAX 16 |
| #define OSC_MAX 512 |
| #define PARAM_MAX 9999 |
| anonymous enum |
| vt_t * vt_new | ( | int | cols, |
| int | rows, | ||
| int | scrollback ) |
a terminal of a size, with room for so many lines of scrollback.
| void vt_free | ( | vt_t * | vt | ) |
| void vt_set_reply | ( | vt_t * | vt, |
| vt_reply_t | fn, | ||
| void * | user ) |
where the answers go (without it, they are dropped).
the bytes the program wrote.
UTF-8 and escape sequences can be split between calls.
| void vt_resize | ( | vt_t * | vt, |
| int | cols, | ||
| int | rows ) |
a new size.
the lines keep their text (cut, or filled with empty cells); when the screen gets lower, the lines above the cursor go into the scrollback so the cursor stays on the screen.
a line of the screen (0 to rows - 1), or of the scrollback (-1 is the newest line, down to -vt_scrollback_lines).
NULL past the ends. a line of the scrollback can be narrower or wider than the screen.
| int vt_scrollback_lines | ( | const vt_t * | vt | ) |
the lines in the scrollback now
| void vt_clean | ( | vt_t * | vt | ) |
forget what changed: the app drew it
the text from (x0, y0) to (x1, y1), both included, as UTF-8; y as for vt_line.
lines end with "\n" unless they wrapped; the empty cells at the end of a line are left out.
| uint32_t vt_palette | ( | int | index | ) |
the RGB colour of palette entry 0 to 255: the 16 colours of xterm, the 6x6x6 cube and the grey ramp.
the app can use its own 16 colours.
the bytes a key sends, as xterm sends them (the arrows follow DECCKM; with modifiers, ESC [ 1 ; m A).
| out | room for 16 bytes. |
| int vt_text_key | ( | const char * | text, |
| int | mods, | ||
| char * | out ) |
the bytes typed text sends: Ctrl with a letter or one of []^_ and space gives the control character, Alt puts ESC in front.
| text | UTF-8, as the keyboard layout made it. |
| out | room for 16 bytes. |
| int vt_mouse | ( | const vt_t * | vt, |
| vt_mouse_t | kind, | ||
| int | button, | ||
| int | x, | ||
| int | y, | ||
| int | mods, | ||
| char * | out ) |
a mouse report for the program, if its mode asks for this one.
| button | 0 left, 1 middle, 2 right, -1 none (motion). |
| x,y | the cell, from 0. |
| out | room for 32 bytes. |
| const char * vt_paste_begin | ( | const vt_t * | vt | ) |
what goes before and after pasted text: the bracketed paste marks when the program asked for them, else "".
| const char * vt_paste_end | ( | const vt_t * | vt | ) |