Line data Source code
1 1 : export enum VT100Command {
2 1 : INSERT_CHARACTER = '@',
3 1 : CURSOR_UP = 'A',
4 1 : CURSOR_DOWN = 'B',
5 1 : CURSOR_FORWARD = 'C',
6 1 : CURSOR_BACKWARD = 'D',
7 1 : INSERT_LINE = 'L',
8 1 : DELETE_LINE = 'M',
9 1 : DELETE_CHARACTER = 'P',
10 1 : }
11 :
12 1 : export const VT100 = {
13 1 : ESCAPE: '\x1b',
14 1 : CSI: '\x1b[',
15 1 : CARRIAGE_RETURN: '\r',
16 1 : NEW_LINE: '\r\n',
17 1 : ERASE_ENTIRE_LINE: '\x1b[2K',
18 1 : SAVE_CURSOR: '\x1b[s',
19 1 : RESTORE_CURSOR: '\x1b[u',
20 1 : ENABLE_AUTO_WRAP: '\x1b[?7h',
21 1 : DISABLE_AUTO_WRAP: '\x1b[?7l',
22 1 : CLEAR_SCREEN: '\x1b[2J\x1b[H',
23 1 : RESET_ATTRIBUTES: '\x1b[0m',
24 1 : BOLD: '\x1b[1m',
25 1 : REVERSE_VIDEO: '\x1b[7m',
26 1 : FOREGROUND_BRIGHT_BLACK: '\x1b[90m',
27 1 : BOLD_FOREGROUND_PINK: '\x1b[1;38;2;255;122;178m',
28 1 : FOREGROUND_CORAL: '\x1b[38;2;255;129;112m',
29 1 : FOREGROUND_SILVER: '\x1b[38;2;201;209;217m',
30 1 : } as const;
31 :
32 : // Mirrors the shell core's parameterized CSI encoding for browser-side assertions and adapters.
33 1 : export function vt100Sequence(count: number, command: VT100Command): string {
34 1 : return `${VT100.CSI}${count}${command}`;
35 1 : }
|