@teaui/core 1.3.8 → 1.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dist/Buffer.d.ts +9 -4
- package/.dist/Buffer.js +19 -16
- package/.dist/Buffer.js.map +1 -1
- package/.dist/Color.js +8 -12
- package/.dist/Color.js.map +1 -1
- package/.dist/Container.d.ts +4 -4
- package/.dist/Container.js +6 -10
- package/.dist/Container.js.map +1 -1
- package/.dist/Screen.d.ts +41 -11
- package/.dist/Screen.js +149 -94
- package/.dist/Screen.js.map +1 -1
- package/.dist/StringTerminal.d.ts +21 -0
- package/.dist/StringTerminal.js +100 -0
- package/.dist/StringTerminal.js.map +1 -0
- package/.dist/Style.d.ts +1 -1
- package/.dist/Style.js +24 -32
- package/.dist/Style.js.map +1 -1
- package/.dist/System.d.ts +2 -2
- package/.dist/System.js +2 -7
- package/.dist/System.js.map +1 -1
- package/.dist/TestTerminal.d.ts +100 -0
- package/.dist/TestTerminal.js +290 -0
- package/.dist/TestTerminal.js.map +1 -0
- package/.dist/Theme.d.ts +5 -3
- package/.dist/Theme.js +14 -16
- package/.dist/Theme.js.map +1 -1
- package/.dist/UI.d.ts +1 -1
- package/.dist/UI.js +4 -6
- package/.dist/UI.js.map +1 -1
- package/.dist/View.d.ts +19 -8
- package/.dist/View.js +35 -22
- package/.dist/View.js.map +1 -1
- package/.dist/Viewport.d.ts +6 -6
- package/.dist/Viewport.js +26 -30
- package/.dist/Viewport.js.map +1 -1
- package/.dist/ansi.js +25 -43
- package/.dist/ansi.js.map +1 -1
- package/.dist/components/Accordion.d.ts +8 -9
- package/.dist/components/Accordion.js +32 -40
- package/.dist/components/Accordion.js.map +1 -1
- package/.dist/components/Box.d.ts +3 -3
- package/.dist/components/Box.js +27 -31
- package/.dist/components/Box.js.map +1 -1
- package/.dist/components/Button.d.ts +8 -8
- package/.dist/components/Button.js +22 -24
- package/.dist/components/Button.js.map +1 -1
- package/.dist/components/Checkbox.d.ts +7 -7
- package/.dist/components/Checkbox.js +15 -20
- package/.dist/components/Checkbox.js.map +1 -1
- package/.dist/components/Collapsible.d.ts +6 -6
- package/.dist/components/Collapsible.js +16 -20
- package/.dist/components/Collapsible.js.map +1 -1
- package/.dist/components/CollapsibleText.d.ts +6 -6
- package/.dist/components/CollapsibleText.js +22 -26
- package/.dist/components/CollapsibleText.js.map +1 -1
- package/.dist/components/Digits.d.ts +5 -5
- package/.dist/components/Digits.js +7 -11
- package/.dist/components/Digits.js.map +1 -1
- package/.dist/components/Drawer.d.ts +9 -7
- package/.dist/components/Drawer.js +43 -39
- package/.dist/components/Drawer.js.map +1 -1
- package/.dist/components/Dropdown.d.ts +6 -6
- package/.dist/components/Dropdown.js +21 -25
- package/.dist/components/Dropdown.js.map +1 -1
- package/.dist/components/Header.d.ts +5 -5
- package/.dist/components/Header.js +14 -24
- package/.dist/components/Header.js.map +1 -1
- package/.dist/components/HotKey.d.ts +6 -4
- package/.dist/components/HotKey.js +12 -11
- package/.dist/components/HotKey.js.map +1 -1
- package/.dist/components/Input.d.ts +7 -7
- package/.dist/components/Input.js +38 -42
- package/.dist/components/Input.js.map +1 -1
- package/.dist/components/Log.d.ts +5 -5
- package/.dist/components/Log.js +26 -31
- package/.dist/components/Log.js.map +1 -1
- package/.dist/components/Progress.d.ts +4 -4
- package/.dist/components/Progress.js +11 -15
- package/.dist/components/Progress.js.map +1 -1
- package/.dist/components/Scrollable.d.ts +4 -4
- package/.dist/components/Scrollable.js +21 -25
- package/.dist/components/Scrollable.js.map +1 -1
- package/.dist/components/ScrollableList.d.ts +5 -5
- package/.dist/components/ScrollableList.js +13 -17
- package/.dist/components/ScrollableList.js.map +1 -1
- package/.dist/components/Separator.d.ts +5 -5
- package/.dist/components/Separator.js +6 -10
- package/.dist/components/Separator.js.map +1 -1
- package/.dist/components/Slider.d.ts +5 -5
- package/.dist/components/Slider.js +35 -41
- package/.dist/components/Slider.js.map +1 -1
- package/.dist/components/Space.d.ts +5 -5
- package/.dist/components/Space.js +6 -10
- package/.dist/components/Space.js.map +1 -1
- package/.dist/components/Spinner.d.ts +4 -4
- package/.dist/components/Spinner.js +5 -9
- package/.dist/components/Spinner.js.map +1 -1
- package/.dist/components/Stack.d.ts +6 -6
- package/.dist/components/Stack.js +16 -20
- package/.dist/components/Stack.js.map +1 -1
- package/.dist/components/Tabs.d.ts +7 -7
- package/.dist/components/Tabs.js +30 -34
- package/.dist/components/Tabs.js.map +1 -1
- package/.dist/components/Text.d.ts +6 -6
- package/.dist/components/Text.js +19 -23
- package/.dist/components/Text.js.map +1 -1
- package/.dist/components/ToggleGroup.d.ts +7 -7
- package/.dist/components/ToggleGroup.js +28 -27
- package/.dist/components/ToggleGroup.js.map +1 -1
- package/.dist/components/Tree.d.ts +4 -4
- package/.dist/components/Tree.js +17 -21
- package/.dist/components/Tree.js.map +1 -1
- package/.dist/components/Window.d.ts +2 -2
- package/.dist/components/Window.js +2 -6
- package/.dist/components/Window.js.map +1 -1
- package/.dist/components/fonts.d.ts +1 -1
- package/.dist/components/fonts.js +1 -4
- package/.dist/components/fonts.js.map +1 -1
- package/.dist/components/index.d.ts +28 -27
- package/.dist/components/index.js +28 -47
- package/.dist/components/index.js.map +1 -1
- package/.dist/components/types.js +1 -4
- package/.dist/components/types.js.map +1 -1
- package/.dist/components/utility/TrackMouse.d.ts +5 -5
- package/.dist/components/utility/TrackMouse.js +14 -18
- package/.dist/components/utility/TrackMouse.js.map +1 -1
- package/.dist/components/utility/index.d.ts +1 -1
- package/.dist/components/utility/index.js +1 -5
- package/.dist/components/utility/index.js.map +1 -1
- package/.dist/events/index.d.ts +9 -10
- package/.dist/events/index.js +3 -19
- package/.dist/events/index.js.map +1 -1
- package/.dist/events/key.d.ts +17 -3
- package/.dist/events/key.js +6 -13
- package/.dist/events/key.js.map +1 -1
- package/.dist/events/mouse.d.ts +3 -3
- package/.dist/events/mouse.js +12 -24
- package/.dist/events/mouse.js.map +1 -1
- package/.dist/events/translate.d.ts +4 -0
- package/.dist/events/translate.js +84 -0
- package/.dist/events/translate.js.map +1 -0
- package/.dist/events/window.js +1 -2
- package/.dist/geometry.js +4 -11
- package/.dist/geometry.js.map +1 -1
- package/.dist/iTerm2.d.ts +8 -4
- package/.dist/iTerm2.js +5 -9
- package/.dist/iTerm2.js.map +1 -1
- package/.dist/index.d.ts +23 -19
- package/.dist/index.js +21 -37
- package/.dist/index.js.map +1 -1
- package/.dist/inspect.js +23 -28
- package/.dist/inspect.js.map +1 -1
- package/.dist/log.js +9 -17
- package/.dist/log.js.map +1 -1
- package/.dist/managers/FocusManager.d.ts +2 -2
- package/.dist/managers/FocusManager.js +17 -11
- package/.dist/managers/FocusManager.js.map +1 -1
- package/.dist/managers/ModalManager.d.ts +4 -4
- package/.dist/managers/ModalManager.js +5 -9
- package/.dist/managers/ModalManager.js.map +1 -1
- package/.dist/managers/MouseManager.d.ts +4 -4
- package/.dist/managers/MouseManager.js +11 -14
- package/.dist/managers/MouseManager.js.map +1 -1
- package/.dist/managers/TickManager.d.ts +1 -1
- package/.dist/managers/TickManager.js +1 -5
- package/.dist/managers/TickManager.js.map +1 -1
- package/.dist/renderToAnsi.d.ts +19 -0
- package/.dist/renderToAnsi.js +45 -0
- package/.dist/renderToAnsi.js.map +1 -0
- package/.dist/terminal.d.ts +8 -3
- package/.dist/terminal.js +1 -2
- package/.dist/testing.d.ts +44 -0
- package/.dist/testing.js +164 -0
- package/.dist/testing.js.map +1 -0
- package/.dist/util.js +17 -25
- package/.dist/util.js.map +1 -1
- package/LICENSE +0 -3
- package/package.json +10 -33
- package/.dist/sys/alias.d.ts +0 -470
- package/.dist/sys/alias.js +0 -487
- package/.dist/sys/alias.js.map +0 -1
- package/.dist/sys/colors.d.ts +0 -10
- package/.dist/sys/colors.js +0 -285
- package/.dist/sys/colors.js.map +0 -1
- package/.dist/sys/gpmclient.d.ts +0 -11
- package/.dist/sys/gpmclient.js +0 -193
- package/.dist/sys/gpmclient.js.map +0 -1
- package/.dist/sys/index.d.ts +0 -4
- package/.dist/sys/index.js +0 -41
- package/.dist/sys/index.js.map +0 -1
- package/.dist/sys/keys.d.ts +0 -4
- package/.dist/sys/keys.js +0 -531
- package/.dist/sys/keys.js.map +0 -1
- package/.dist/sys/program.d.ts +0 -356
- package/.dist/sys/program.js +0 -3739
- package/.dist/sys/program.js.map +0 -1
- package/.dist/sys/tput.d.ts +0 -297
- package/.dist/sys/tput.js +0 -2708
- package/.dist/sys/tput.js.map +0 -1
- package/.dist/sys/unicode.d.ts +0 -25
- package/.dist/sys/unicode.js +0 -593
- package/.dist/sys/unicode.js.map +0 -1
- package/.dist/sys/usr/linux +0 -0
- package/.dist/sys/usr/windows-ansi +0 -0
- package/.dist/sys/usr/xterm +0 -0
- package/.dist/sys/usr/xterm-256color +0 -0
- package/.dist/sys/usr/xterm.termcap +0 -243
- package/.dist/sys/usr/xterm.terminfo +0 -1977
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import * as unicode from '@teaui/term';
|
|
2
|
+
import { Style } from './Style.js';
|
|
3
|
+
/**
|
|
4
|
+
* A headless SGRTerminal for testing. Stores characters and parsed Style objects
|
|
5
|
+
* in a 2D grid, providing readable query methods for assertions:
|
|
6
|
+
*
|
|
7
|
+
* expect(term.charAt(0, 0)).toBe('H')
|
|
8
|
+
* expect(term.styleAt(0, 0).bold).toBe(true)
|
|
9
|
+
* expect(term.textAt(0, 0, 5)).toBe('Hello')
|
|
10
|
+
* expect(term.textContent()).toContain('Hello')
|
|
11
|
+
*/
|
|
12
|
+
export class TestTerminal {
|
|
13
|
+
cols;
|
|
14
|
+
rows;
|
|
15
|
+
#grid;
|
|
16
|
+
#cursorX = 0;
|
|
17
|
+
#cursorY = 0;
|
|
18
|
+
#pendingSgr = '';
|
|
19
|
+
#currentStyle = Style.NONE;
|
|
20
|
+
constructor({ cols, rows }) {
|
|
21
|
+
this.cols = cols;
|
|
22
|
+
this.rows = rows;
|
|
23
|
+
this.#grid = this.#createGrid();
|
|
24
|
+
}
|
|
25
|
+
#createGrid() {
|
|
26
|
+
const grid = [];
|
|
27
|
+
for (let y = 0; y < this.rows; y++) {
|
|
28
|
+
const row = [];
|
|
29
|
+
for (let x = 0; x < this.cols; x++) {
|
|
30
|
+
row.push({ char: ' ', style: Style.NONE });
|
|
31
|
+
}
|
|
32
|
+
grid.push(row);
|
|
33
|
+
}
|
|
34
|
+
return grid;
|
|
35
|
+
}
|
|
36
|
+
move(x, y) {
|
|
37
|
+
this.#cursorX = x;
|
|
38
|
+
this.#cursorY = y;
|
|
39
|
+
}
|
|
40
|
+
write(str) {
|
|
41
|
+
let i = 0;
|
|
42
|
+
while (i < str.length) {
|
|
43
|
+
if (str[i] === '\x1b' && i + 1 < str.length && str[i + 1] === '[') {
|
|
44
|
+
// ANSI escape sequence
|
|
45
|
+
let j = i + 2;
|
|
46
|
+
while (j < str.length && !isAnsiTerminator(str[j])) {
|
|
47
|
+
j++;
|
|
48
|
+
}
|
|
49
|
+
if (j < str.length) {
|
|
50
|
+
j++; // include the terminator
|
|
51
|
+
}
|
|
52
|
+
const sgr = str.slice(i, j);
|
|
53
|
+
this.#pendingSgr += sgr;
|
|
54
|
+
i = j;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
// Visible character — may be multi-code-unit (emoji, CJK)
|
|
58
|
+
const codePoint = str.codePointAt(i);
|
|
59
|
+
const char = String.fromCodePoint(codePoint);
|
|
60
|
+
const width = unicode.charWidth(char);
|
|
61
|
+
// Apply any pending SGR to current style
|
|
62
|
+
if (this.#pendingSgr) {
|
|
63
|
+
this.#currentStyle = this.#parseAccumulatedSGR(this.#pendingSgr);
|
|
64
|
+
this.#pendingSgr = '';
|
|
65
|
+
}
|
|
66
|
+
if (this.#cursorY >= 0 &&
|
|
67
|
+
this.#cursorY < this.rows &&
|
|
68
|
+
this.#cursorX >= 0 &&
|
|
69
|
+
this.#cursorX < this.cols) {
|
|
70
|
+
this.#grid[this.#cursorY][this.#cursorX] = {
|
|
71
|
+
char,
|
|
72
|
+
style: this.#currentStyle,
|
|
73
|
+
};
|
|
74
|
+
// Wide characters occupy 2 cells
|
|
75
|
+
if (width === 2 && this.#cursorX + 1 < this.cols) {
|
|
76
|
+
this.#grid[this.#cursorY][this.#cursorX + 1] = {
|
|
77
|
+
char: '',
|
|
78
|
+
style: this.#currentStyle,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
this.#cursorX += Math.max(width, 1);
|
|
83
|
+
i += char.length;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
flush() { }
|
|
88
|
+
/**
|
|
89
|
+
* Parse accumulated SGR sequences into a Style.
|
|
90
|
+
* Multiple SGR codes may have been concatenated (e.g. "\x1b[1m\x1b[38;5;196m").
|
|
91
|
+
* A reset (\x1b[0m) clears everything.
|
|
92
|
+
*
|
|
93
|
+
* Note: Style.fromSGR's prevStyle param is used as the "reset target" — e.g.
|
|
94
|
+
* code 22 (!bold) resets to prevStyle.bold. We pass Style.NONE so resets
|
|
95
|
+
* correctly turn attributes off rather than copying the current state.
|
|
96
|
+
*/
|
|
97
|
+
#parseAccumulatedSGR(sgr) {
|
|
98
|
+
const sequences = sgr.match(/\x1b\[[\d;]*m/g) ?? [];
|
|
99
|
+
let style = this.#currentStyle;
|
|
100
|
+
for (const seq of sequences) {
|
|
101
|
+
if (seq === '\x1b[0m' || seq === '\x1b[m') {
|
|
102
|
+
style = Style.NONE;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
style = style.merge(Style.fromSGR(seq, Style.NONE));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return style;
|
|
109
|
+
}
|
|
110
|
+
// --- Query API for tests ---
|
|
111
|
+
/**
|
|
112
|
+
* Get the character at (x, y). Returns ' ' for empty cells.
|
|
113
|
+
*/
|
|
114
|
+
charAt(x, y) {
|
|
115
|
+
if (x < 0 || x >= this.cols || y < 0 || y >= this.rows)
|
|
116
|
+
return '';
|
|
117
|
+
return this.#grid[y][x].char;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Get the Style at (x, y).
|
|
121
|
+
*/
|
|
122
|
+
styleAt(x, y) {
|
|
123
|
+
if (x < 0 || x >= this.cols || y < 0 || y >= this.rows)
|
|
124
|
+
return Style.NONE;
|
|
125
|
+
return this.#grid[y][x].style;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Read `length` characters starting at (x, y) on the same row.
|
|
129
|
+
* Skips empty cells from wide characters.
|
|
130
|
+
*/
|
|
131
|
+
textAt(x, y, length) {
|
|
132
|
+
let result = '';
|
|
133
|
+
let count = 0;
|
|
134
|
+
for (let cx = x; cx < this.cols && count < length; cx++) {
|
|
135
|
+
const char = this.#grid[y]?.[cx]?.char ?? '';
|
|
136
|
+
if (char === '')
|
|
137
|
+
continue; // skip wide char continuation cells
|
|
138
|
+
result += char;
|
|
139
|
+
count++;
|
|
140
|
+
}
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Get all text on a row (trimmed of trailing spaces).
|
|
145
|
+
*/
|
|
146
|
+
textAtRow(y) {
|
|
147
|
+
if (y < 0 || y >= this.rows)
|
|
148
|
+
return '';
|
|
149
|
+
let line = '';
|
|
150
|
+
for (let x = 0; x < this.cols; x++) {
|
|
151
|
+
const char = this.#grid[y][x].char;
|
|
152
|
+
if (char === '')
|
|
153
|
+
continue; // skip wide char continuation cells
|
|
154
|
+
line += char;
|
|
155
|
+
}
|
|
156
|
+
return line.trimEnd();
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Get all visible text content (rows joined by newlines, trailing spaces trimmed).
|
|
160
|
+
*/
|
|
161
|
+
textContent() {
|
|
162
|
+
const lines = [];
|
|
163
|
+
for (let y = 0; y < this.rows; y++) {
|
|
164
|
+
lines.push(this.textAtRow(y));
|
|
165
|
+
}
|
|
166
|
+
// Trim trailing empty lines
|
|
167
|
+
while (lines.length > 0 && lines[lines.length - 1] === '') {
|
|
168
|
+
lines.pop();
|
|
169
|
+
}
|
|
170
|
+
return lines.join('\n');
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Find the first position of a substring on the screen.
|
|
174
|
+
* Returns {x, y} or null if not found.
|
|
175
|
+
*/
|
|
176
|
+
find(text) {
|
|
177
|
+
for (let y = 0; y < this.rows; y++) {
|
|
178
|
+
const row = this.textAtRow(y);
|
|
179
|
+
const x = row.indexOf(text);
|
|
180
|
+
if (x !== -1) {
|
|
181
|
+
return { x, y };
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Get the Style of the first character of a found substring.
|
|
188
|
+
* Useful for asserting styles on specific text.
|
|
189
|
+
*/
|
|
190
|
+
styleOf(text) {
|
|
191
|
+
const pos = this.find(text);
|
|
192
|
+
if (!pos)
|
|
193
|
+
return null;
|
|
194
|
+
return this.styleAt(pos.x, pos.y);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Get a row as a string, optionally sliced. NOT trimmed.
|
|
198
|
+
* Wide char continuation cells are skipped.
|
|
199
|
+
*/
|
|
200
|
+
getRow(y, from, to) {
|
|
201
|
+
if (y < 0 || y >= this.rows)
|
|
202
|
+
return '';
|
|
203
|
+
from ??= 0;
|
|
204
|
+
to ??= this.cols;
|
|
205
|
+
let line = '';
|
|
206
|
+
for (let x = from; x < to && x < this.cols; x++) {
|
|
207
|
+
const char = this.#grid[y][x].char;
|
|
208
|
+
if (char === '')
|
|
209
|
+
continue;
|
|
210
|
+
line += char;
|
|
211
|
+
}
|
|
212
|
+
return line;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Extract a rectangular region as a multi-line string (lines joined by \n).
|
|
216
|
+
* Trailing spaces on each line are preserved. Use for exact grid assertions:
|
|
217
|
+
*
|
|
218
|
+
* expect(term.textRect(0, 0, 5, 3)).toBe(
|
|
219
|
+
* '┌───┐\n' +
|
|
220
|
+
* '│ │\n' +
|
|
221
|
+
* '└───┘'
|
|
222
|
+
* )
|
|
223
|
+
*/
|
|
224
|
+
textRect(x, y, width, height) {
|
|
225
|
+
const lines = [];
|
|
226
|
+
for (let row = y; row < y + height && row < this.rows; row++) {
|
|
227
|
+
lines.push(this.getRow(row, x, x + width));
|
|
228
|
+
}
|
|
229
|
+
return lines.join('\n');
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Assert that all cells in a range satisfy a style predicate.
|
|
233
|
+
* Returns true if every cell in the range matches.
|
|
234
|
+
*
|
|
235
|
+
* term.stylesMatch(0, 0, 5, style => style.bold === true)
|
|
236
|
+
*/
|
|
237
|
+
stylesMatch(x, y, width, predicate, height = 1) {
|
|
238
|
+
for (let row = y; row < y + height && row < this.rows; row++) {
|
|
239
|
+
for (let col = x; col < x + width && col < this.cols; col++) {
|
|
240
|
+
if (!predicate(this.#grid[row][col].style)) {
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Compare full screen content against a template string. Each line
|
|
249
|
+
* of the expected string is compared against the corresponding row.
|
|
250
|
+
* Trailing spaces in the template are significant — use '·' for
|
|
251
|
+
* explicit space if needed.
|
|
252
|
+
* Trailing empty lines in the template are not required to match.
|
|
253
|
+
*/
|
|
254
|
+
contentEquals(expected) {
|
|
255
|
+
const expectedLines = expected.split('\n');
|
|
256
|
+
for (let y = 0; y < expectedLines.length; y++) {
|
|
257
|
+
const expectedLine = expectedLines[y];
|
|
258
|
+
const actual = this.getRow(y, 0, expectedLine.length);
|
|
259
|
+
if (actual !== expectedLine) {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Like contentEquals but returns a diff-friendly string for assertion messages.
|
|
267
|
+
* Use with expect().toBe() for readable failures:
|
|
268
|
+
*
|
|
269
|
+
* expect(term.frameContent()).toBe(
|
|
270
|
+
* '┌───┐\n' +
|
|
271
|
+
* '│Hi │\n' +
|
|
272
|
+
* '└───┘'
|
|
273
|
+
* )
|
|
274
|
+
*/
|
|
275
|
+
frameContent() {
|
|
276
|
+
return this.textContent();
|
|
277
|
+
}
|
|
278
|
+
reset() {
|
|
279
|
+
this.#grid = this.#createGrid();
|
|
280
|
+
this.#cursorX = 0;
|
|
281
|
+
this.#cursorY = 0;
|
|
282
|
+
this.#pendingSgr = '';
|
|
283
|
+
this.#currentStyle = Style.NONE;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
function isAnsiTerminator(ch) {
|
|
287
|
+
const code = ch.charCodeAt(0);
|
|
288
|
+
return (code >= 65 && code <= 90) || (code >= 97 && code <= 122);
|
|
289
|
+
}
|
|
290
|
+
//# sourceMappingURL=TestTerminal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TestTerminal.js","sourceRoot":"","sources":["../lib/TestTerminal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,aAAa,CAAA;AAGtC,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAA;AAOhC;;;;;;;;GAQG;AACH,MAAM,OAAO,YAAY;IACvB,IAAI,CAAQ;IACZ,IAAI,CAAQ;IACZ,KAAK,CAAU;IACf,QAAQ,GAAG,CAAC,CAAA;IACZ,QAAQ,GAAG,CAAC,CAAA;IACZ,WAAW,GAAG,EAAE,CAAA;IAChB,aAAa,GAAG,KAAK,CAAC,IAAI,CAAA;IAE1B,YAAY,EAAC,IAAI,EAAE,IAAI,EAA+B;QACpD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAA;IACjC,CAAC;IAED,WAAW;QACT,MAAM,IAAI,GAAa,EAA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AAI,IAAI,EAAE,IAAI,IAAI,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,IAAI,IAAI,IAAI,GAAG,CAAC,CAAA;AAClE,CAAC"}
|
package/.dist/Theme.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Color } from './Color';
|
|
2
|
-
import { Style } from './Style';
|
|
1
|
+
import type { Color } from './Color.js';
|
|
2
|
+
import { Style } from './Style.js';
|
|
3
3
|
export type Purpose = 'primary' | 'blue' | 'secondary' | 'orange' | 'proceed' | 'green' | 'cancel' | 'red' | 'selected' | 'plain';
|
|
4
4
|
interface Props {
|
|
5
5
|
text?: Color;
|
|
@@ -10,6 +10,7 @@ interface Props {
|
|
|
10
10
|
textBackground?: Color;
|
|
11
11
|
highlight: Color;
|
|
12
12
|
darken: Color;
|
|
13
|
+
emoji?: boolean;
|
|
13
14
|
}
|
|
14
15
|
export declare class Theme {
|
|
15
16
|
textColor: Color;
|
|
@@ -20,6 +21,7 @@ export declare class Theme {
|
|
|
20
21
|
textBackgroundColor: Color;
|
|
21
22
|
highlightColor: Color;
|
|
22
23
|
darkenColor: Color;
|
|
24
|
+
emoji: boolean;
|
|
23
25
|
static plain: Theme;
|
|
24
26
|
static primary: Theme;
|
|
25
27
|
static secondary: Theme;
|
|
@@ -30,7 +32,7 @@ export declare class Theme {
|
|
|
30
32
|
static green: Theme;
|
|
31
33
|
static blue: Theme;
|
|
32
34
|
static orange: Theme;
|
|
33
|
-
constructor({ text, brightText, dimText, dimBackground, background, textBackground, highlight, darken, }: Props);
|
|
35
|
+
constructor({ text, brightText, dimText, dimBackground, background, textBackground, highlight, darken, emoji, }: Props);
|
|
34
36
|
/**
|
|
35
37
|
* "Ornament" is meant to draw decorative characters that disappear on hover/press
|
|
36
38
|
*/
|
package/.dist/Theme.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Theme = void 0;
|
|
4
|
-
const Style_1 = require("./Style");
|
|
1
|
+
import { Style } from './Style.js';
|
|
5
2
|
const defaultText = '#E2E2E2(253)';
|
|
6
3
|
const defaultBrightText = '#FFF(16)';
|
|
7
4
|
const defaultDimText = '#808080(239)';
|
|
8
5
|
const defaultDimBackground = '#434343(238)';
|
|
9
|
-
class Theme {
|
|
6
|
+
export class Theme {
|
|
10
7
|
textColor;
|
|
11
8
|
brightTextColor;
|
|
12
9
|
dimTextColor;
|
|
@@ -15,6 +12,7 @@ class Theme {
|
|
|
15
12
|
textBackgroundColor;
|
|
16
13
|
highlightColor;
|
|
17
14
|
darkenColor;
|
|
15
|
+
emoji;
|
|
18
16
|
static plain = new Theme({
|
|
19
17
|
background: '#4F4F4F(239)',
|
|
20
18
|
textBackground: 'default',
|
|
@@ -68,7 +66,7 @@ class Theme {
|
|
|
68
66
|
static green = Theme.proceed;
|
|
69
67
|
static blue = Theme.primary;
|
|
70
68
|
static orange = Theme.secondary;
|
|
71
|
-
constructor({ text, brightText, dimText, dimBackground, background, textBackground, highlight, darken, }) {
|
|
69
|
+
constructor({ text, brightText, dimText, dimBackground, background, textBackground, highlight, darken, emoji, }) {
|
|
72
70
|
this.textColor = text ?? defaultText;
|
|
73
71
|
this.brightTextColor = brightText ?? defaultBrightText;
|
|
74
72
|
this.dimTextColor = dimText ?? defaultDimText;
|
|
@@ -77,31 +75,32 @@ class Theme {
|
|
|
77
75
|
this.textBackgroundColor = textBackground ?? background;
|
|
78
76
|
this.highlightColor = highlight;
|
|
79
77
|
this.darkenColor = darken;
|
|
78
|
+
this.emoji = emoji ?? true;
|
|
80
79
|
}
|
|
81
80
|
/**
|
|
82
81
|
* "Ornament" is meant to draw decorative characters that disappear on hover/press
|
|
83
82
|
*/
|
|
84
83
|
ui({ isPressed, isHover, isOrnament, } = {}) {
|
|
85
84
|
if (isPressed) {
|
|
86
|
-
return new
|
|
85
|
+
return new Style({
|
|
87
86
|
foreground: isOrnament ? this.darkenColor : this.textColor,
|
|
88
87
|
background: this.darkenColor,
|
|
89
88
|
});
|
|
90
89
|
}
|
|
91
90
|
else if (isHover) {
|
|
92
|
-
return new
|
|
91
|
+
return new Style({
|
|
93
92
|
foreground: isOrnament ? this.highlightColor : this.textColor,
|
|
94
93
|
background: this.highlightColor,
|
|
95
94
|
});
|
|
96
95
|
}
|
|
97
96
|
else if (isOrnament) {
|
|
98
|
-
return new
|
|
97
|
+
return new Style({
|
|
99
98
|
foreground: this.darkenColor,
|
|
100
99
|
background: this.backgroundColor,
|
|
101
100
|
});
|
|
102
101
|
}
|
|
103
102
|
else {
|
|
104
|
-
return new
|
|
103
|
+
return new Style({
|
|
105
104
|
foreground: this.textColor,
|
|
106
105
|
background: this.backgroundColor,
|
|
107
106
|
});
|
|
@@ -115,7 +114,7 @@ class Theme {
|
|
|
115
114
|
*/
|
|
116
115
|
text({ isPressed, isHover, isSelected, isPlaceholder, hasFocus, } = {}) {
|
|
117
116
|
if (isPlaceholder) {
|
|
118
|
-
return new
|
|
117
|
+
return new Style({
|
|
119
118
|
foreground: isPressed ? this.textColor : this.dimTextColor,
|
|
120
119
|
background: isHover
|
|
121
120
|
? this.dimBackgroundColor
|
|
@@ -124,7 +123,7 @@ class Theme {
|
|
|
124
123
|
});
|
|
125
124
|
}
|
|
126
125
|
if (isPressed) {
|
|
127
|
-
return new
|
|
126
|
+
return new Style({
|
|
128
127
|
foreground: this.highlightColor,
|
|
129
128
|
background: this.textBackgroundColor,
|
|
130
129
|
inverse: hasFocus && isSelected,
|
|
@@ -132,7 +131,7 @@ class Theme {
|
|
|
132
131
|
});
|
|
133
132
|
}
|
|
134
133
|
if (isHover) {
|
|
135
|
-
return new
|
|
134
|
+
return new Style({
|
|
136
135
|
foreground: this.brightTextColor,
|
|
137
136
|
background: this.textBackgroundColor,
|
|
138
137
|
inverse: hasFocus && isSelected,
|
|
@@ -140,12 +139,12 @@ class Theme {
|
|
|
140
139
|
});
|
|
141
140
|
}
|
|
142
141
|
if (isSelected && !hasFocus) {
|
|
143
|
-
return new
|
|
142
|
+
return new Style({
|
|
144
143
|
foreground: this.dimTextColor,
|
|
145
144
|
background: this.dimBackgroundColor,
|
|
146
145
|
});
|
|
147
146
|
}
|
|
148
|
-
return new
|
|
147
|
+
return new Style({
|
|
149
148
|
foreground: this.textColor,
|
|
150
149
|
background: this.textBackgroundColor,
|
|
151
150
|
inverse: hasFocus && isSelected,
|
|
@@ -153,5 +152,4 @@ class Theme {
|
|
|
153
152
|
});
|
|
154
153
|
}
|
|
155
154
|
}
|
|
156
|
-
exports.Theme = Theme;
|
|
157
155
|
//# sourceMappingURL=Theme.js.map
|
package/.dist/Theme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Theme.js","sourceRoot":"","sources":["../lib/Theme.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Theme.js","sourceRoot":"","sources":["../lib/Theme.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAA;AAchC,MAAM,WAAW,GAAG,cAAc,CAAA;AAClC,MAAM,iBAAiB,GAAG,UAAU,CAAA;AACpC,MAAM,cAAc,GAAG,cAAc,CAAA;AACrC,MAAM,oBAAoB,GAAG,cAAc,CAAA;AAc3C,MAAM,OAAO,KAAK;IAChB,SAAS,CAAO;IAChB,eAAe,CAAO;IACtB,YAAY,CAAO;IACnB,kBAAkB,CAAO;IACzB,eAAe,CAAO;IACtB,mBAAmB,CAAO;IAC1B,cAAc,CAAO;IACrB,WAAW,CAAO;IAClB,KAAK,CAAS;IAEd,MAAM,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC;QACvB,UAAU,EAAE,cAAc;QAC1B,cAAc,EAAE,SAAS;QACzB,SAAS,EAAE,cAAc;QACzB,MAAM,EAAE,cAAc;KACvB,CAAC,CAAA;IACF,MAAM,CAAC,OAAO,GAAG,IAAI,KAAK,CAAC;QACzB,UAAU,EAAE,SAAS;QACrB,cAAc,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B,UAAU,EAAE,IAAI,CAAC,kBAAkB;aACpC,CAAC,CAAA;QACJ,CAAC;QAED,OAAO,IAAI,KAAK,CAAC;YACf,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,UAAU,EAAE,IAAI,CAAC,mBAAmB;YACpC,OAAO,EAAE,QAAQ,IAAI,UAAU;YAC/B,IAAI,EAAE,QAAQ;SACf,CAAC,CAAA;IACJ,CAAC"}
|
package/.dist/UI.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Theme } from './Theme';
|
|
1
|
+
import { Theme } from './Theme.js';
|
|
2
2
|
export declare function childTheme(theme: Theme, isPressed?: boolean, isHover?: boolean): Theme;
|
package/.dist/UI.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const Theme_1 = require("./Theme");
|
|
5
|
-
function childTheme(theme, isPressed = false, isHover = false) {
|
|
6
|
-
return new Theme_1.Theme({
|
|
1
|
+
import { Theme } from './Theme.js';
|
|
2
|
+
export function childTheme(theme, isPressed = false, isHover = false) {
|
|
3
|
+
return new Theme({
|
|
7
4
|
background: isPressed
|
|
8
5
|
? theme.darkenColor
|
|
9
6
|
: isHover
|
|
@@ -23,6 +20,7 @@ function childTheme(theme, isPressed = false, isHover = false) {
|
|
|
23
20
|
text: theme.textColor,
|
|
24
21
|
brightText: theme.brightTextColor,
|
|
25
22
|
dimText: theme.dimTextColor,
|
|
23
|
+
emoji: theme.emoji,
|
|
26
24
|
});
|
|
27
25
|
}
|
|
28
26
|
//# sourceMappingURL=UI.js.map
|
package/.dist/UI.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UI.js","sourceRoot":"","sources":["../lib/UI.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UI.js","sourceRoot":"","sources":["../lib/UI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAA;AAEhC,MAAM,UAAU,UAAU,CAAC,KAAY,EAAE,SAAS,GAAG,KAAK,EAAE,OAAO,GAAG,KAAK;IACzE,OAAO,IAAI,KAAK,CAAC;QACf,UAAU,EAAE,SAAS;YACnB,CAAC,CAAC,KAAK,CAAC,WAAW;YACnB,CAAC,CAAC,OAAO;gBACP,CAAC,CAAC,KAAK,CAAC,cAAc;gBACtB,CAAC,CAAC,KAAK,CAAC,eAAe;QAC3B,cAAc,EAAE,SAAS;YACvB,CAAC,CAAC,KAAK,CAAC,WAAW;YACnB,CAAC,CAAC,OAAO;gBACP,CAAC,CAAC,KAAK,CAAC,cAAc;gBACtB,CAAC,CAAC,KAAK,CAAC,eAAe;QAC3B,SAAS,EAAE,KAAK,CAAC,cAAc;QAC/B,MAAM,EAAE,SAAS;YACf,CAAC,CAAC,KAAK,CAAC,WAAW;YACnB,CAAC,CAAC,OAAO;gBACP,CAAC,CAAC,KAAK,CAAC,cAAc;gBACtB,CAAC,CAAC,KAAK,CAAC,WAAW;QACvB,IAAI,EAAE,KAAK,CAAC,SAAS;QACrB,UAAU,EAAE,KAAK,CAAC,eAAe;QACjC,OAAO,EAAE,KAAK,CAAC,YAAY;QAC3B,KAAK,EAAE,KAAK,CAAC,KAAK;KACnB,CAAC,CAAA;AACJ,CAAC"}
|
package/.dist/View.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { Viewport } from './Viewport';
|
|
2
|
-
import type { Screen } from './Screen';
|
|
3
|
-
import type { Purpose } from './Theme';
|
|
4
|
-
import { Theme } from './Theme';
|
|
5
|
-
import { Container } from './Container';
|
|
6
|
-
import { System } from './System';
|
|
7
|
-
import { type KeyEvent, type MouseEvent } from './events';
|
|
8
|
-
import { Size } from './geometry';
|
|
1
|
+
import type { Viewport } from './Viewport.js';
|
|
2
|
+
import type { Screen } from './Screen.js';
|
|
3
|
+
import type { Purpose } from './Theme.js';
|
|
4
|
+
import { Theme } from './Theme.js';
|
|
5
|
+
import { Container } from './Container.js';
|
|
6
|
+
import { System } from './System.js';
|
|
7
|
+
import { type KeyEvent, type MouseEvent } from './events/index.js';
|
|
8
|
+
import { Size } from './geometry.js';
|
|
9
9
|
export type Dimension = number | 'fill' | 'shrink' | 'natural';
|
|
10
10
|
export type FlexSize = 'natural' | number;
|
|
11
11
|
export type FlexShorthand = FlexSize | `flex${number}`;
|
|
@@ -49,6 +49,7 @@ export declare abstract class View {
|
|
|
49
49
|
get contentSize(): Size;
|
|
50
50
|
get isHover(): boolean;
|
|
51
51
|
get isPressed(): boolean;
|
|
52
|
+
get hasFocus(): boolean;
|
|
52
53
|
get width(): Dimension | undefined;
|
|
53
54
|
get height(): Dimension | undefined;
|
|
54
55
|
abstract naturalSize(available: Size): Size;
|
|
@@ -78,6 +79,16 @@ export declare abstract class View {
|
|
|
78
79
|
* screen).
|
|
79
80
|
*/
|
|
80
81
|
didUnmount(screen: Screen): void;
|
|
82
|
+
/**
|
|
83
|
+
* Called when this view gains keyboard focus. Only called on views that call
|
|
84
|
+
* `viewport.registerFocus()` in their render method.
|
|
85
|
+
*/
|
|
86
|
+
didFocus(): void;
|
|
87
|
+
/**
|
|
88
|
+
* Called when this view loses keyboard focus. Only called on views that previously
|
|
89
|
+
* had focus (i.e. `didFocus()` was called).
|
|
90
|
+
*/
|
|
91
|
+
didBlur(): void;
|
|
81
92
|
removeFromParent(): void;
|
|
82
93
|
moveToScreen(screen: Screen | undefined): void;
|
|
83
94
|
/**
|