1 | const csi = some => '\x1b[' + some;
|
2 | const csiSet = (...vec) => {
|
3 | let tx = '';
|
4 |
|
5 | for (let x of vec) tx += csi(x);
|
6 |
|
7 | return tx;
|
8 | };
|
9 |
|
10 | class Clear {
|
11 | static AFTER_CURSOR = csi('0J');
|
12 |
|
13 | static BEFORE_CURSOR = csi('1J');
|
14 |
|
15 | static ENTIRE_SCREEN = csi('2J');
|
16 |
|
17 | static ENTIRE_TERMINAL = csi('3J');
|
18 |
|
19 | static RIGHT_TO_CURSOR = csi('0K');
|
20 |
|
21 | static LEFT_TO_CURSOR = csi('1K');
|
22 |
|
23 | static ENTIRE_LINE = csi('2K');
|
24 |
|
25 | }
|
26 |
|
27 | class Cursor {
|
28 | static goto = (x, y) => csi(`${++x};${++y}H`);
|
29 | static up = d => csi(d + 'A');
|
30 | static down = d => csi(d + 'B');
|
31 | static right = d => csi(d + 'C');
|
32 | static left = d => csi(d + 'D');
|
33 | static prevLine = d => csi(d + 'E');
|
34 | static nextLine = d => csi(d + 'F');
|
35 | static charTo = d => csi(d + 'G');
|
36 | static QUERY_POS = csi("6n");
|
37 |
|
38 | static SHOW = csi("?25h");
|
39 |
|
40 | static HIDE = csi("?25l");
|
41 |
|
42 | static SAVE = csi("s");
|
43 |
|
44 | static RESTORE = csi("u");
|
45 |
|
46 | static BLINK_BLOCK = csi("\x31 q");
|
47 |
|
48 | static STEADY_BLOCK = csi("\x32 q");
|
49 |
|
50 | static BLINK_UNDERLINE = csi("\x33 q");
|
51 |
|
52 | static STEADY_UNDERLINE = csi("\x34 q");
|
53 |
|
54 | static BLINK_BAR = csi("\x35 q");
|
55 |
|
56 | static STEADY_BAR = csi("\x36 q");
|
57 |
|
58 | }
|
59 |
|
60 | class Scroll {
|
61 | static up = n => csi(`${n}S`);
|
62 | static down = n => csi(`${n}T`);
|
63 | }
|
64 |
|
65 | class DECSet {
|
66 | static WRAP_ON = csi('?7h');
|
67 | static WRAP_OFF = csi('?7l');
|
68 | }
|
69 |
|
70 | export { Clear, Cursor, DECSet, Scroll, Clear as clear, csi, csiSet, Cursor as cursor, DECSet as decset, Scroll as scroll };
|