terminal-pilot 0.0.18 → 0.0.19
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/cli.js +3467 -1463
- package/dist/cli.js.map +4 -4
- package/dist/commands/close-session.js +413 -98
- package/dist/commands/close-session.js.map +2 -2
- package/dist/commands/create-session.js +413 -98
- package/dist/commands/create-session.js.map +2 -2
- package/dist/commands/fill.js +413 -98
- package/dist/commands/fill.js.map +2 -2
- package/dist/commands/get-session.js +413 -98
- package/dist/commands/get-session.js.map +2 -2
- package/dist/commands/index.d.ts +224 -1
- package/dist/commands/index.js +1109 -264
- package/dist/commands/index.js.map +4 -4
- package/dist/commands/install.js +457 -107
- package/dist/commands/install.js.map +4 -4
- package/dist/commands/installer.d.ts +5 -0
- package/dist/commands/installer.js +127 -36
- package/dist/commands/installer.js.map +4 -4
- package/dist/commands/list-sessions.js +413 -98
- package/dist/commands/list-sessions.js.map +2 -2
- package/dist/commands/press-key.js +413 -98
- package/dist/commands/press-key.js.map +2 -2
- package/dist/commands/read-history.js +413 -98
- package/dist/commands/read-history.js.map +2 -2
- package/dist/commands/read-screen.js +413 -98
- package/dist/commands/read-screen.js.map +2 -2
- package/dist/commands/resize.js +413 -98
- package/dist/commands/resize.js.map +2 -2
- package/dist/commands/runtime.js +354 -87
- package/dist/commands/runtime.js.map +2 -2
- package/dist/commands/screenshot.js +648 -138
- package/dist/commands/screenshot.js.map +3 -3
- package/dist/commands/send-signal.js +413 -98
- package/dist/commands/send-signal.js.map +2 -2
- package/dist/commands/type.js +413 -98
- package/dist/commands/type.js.map +2 -2
- package/dist/commands/uninstall.js +213 -61
- package/dist/commands/uninstall.js.map +4 -4
- package/dist/commands/wait-for-exit.js +413 -98
- package/dist/commands/wait-for-exit.js.map +2 -2
- package/dist/commands/wait-for.js +413 -98
- package/dist/commands/wait-for.js.map +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +318 -80
- package/dist/index.js.map +3 -3
- package/dist/terminal-buffer.d.ts +18 -0
- package/dist/terminal-buffer.js +234 -43
- package/dist/terminal-buffer.js.map +2 -2
- package/dist/terminal-pilot.js +312 -73
- package/dist/terminal-pilot.js.map +2 -2
- package/dist/terminal-session.d.ts +2 -2
- package/dist/terminal-session.js +306 -68
- package/dist/terminal-session.js.map +2 -2
- package/dist/testing/cli-repl.js +3463 -1459
- package/dist/testing/cli-repl.js.map +4 -4
- package/dist/testing/qa-cli.js +3486 -1482
- package/dist/testing/qa-cli.js.map +4 -4
- package/package.json +6 -2
package/dist/terminal-buffer.js
CHANGED
|
@@ -1,26 +1,52 @@
|
|
|
1
1
|
// src/terminal-buffer.ts
|
|
2
2
|
var RESET_SGR = "\x1B[0m";
|
|
3
|
+
var DEC_SPECIAL_GRAPHICS = {
|
|
4
|
+
j: "\u2518",
|
|
5
|
+
k: "\u2510",
|
|
6
|
+
l: "\u250C",
|
|
7
|
+
m: "\u2514",
|
|
8
|
+
n: "\u253C",
|
|
9
|
+
q: "\u2500",
|
|
10
|
+
t: "\u251C",
|
|
11
|
+
u: "\u2524",
|
|
12
|
+
v: "\u2534",
|
|
13
|
+
w: "\u252C",
|
|
14
|
+
x: "\u2502"
|
|
15
|
+
};
|
|
3
16
|
var TerminalBuffer = class {
|
|
4
17
|
_cols;
|
|
5
18
|
_rows;
|
|
6
19
|
_screen;
|
|
20
|
+
_primaryScreen = null;
|
|
7
21
|
_cursorX = 0;
|
|
8
22
|
_cursorY = 0;
|
|
9
|
-
_savedCursor
|
|
23
|
+
_savedCursor;
|
|
10
24
|
_scrollTop = 0;
|
|
11
25
|
_scrollBottom;
|
|
12
26
|
_state = 0 /* Normal */;
|
|
13
27
|
_csiParams = "";
|
|
14
28
|
_csiPrivate = "";
|
|
15
29
|
_autoWrap = true;
|
|
30
|
+
_pendingWrap = false;
|
|
31
|
+
_originMode = false;
|
|
32
|
+
_insertMode = false;
|
|
33
|
+
_tabStops;
|
|
34
|
+
_lastPrintedChar = null;
|
|
16
35
|
_style = createDefaultStyleState();
|
|
17
36
|
_styleSequence = "";
|
|
37
|
+
_stringState = 0 /* Normal */;
|
|
38
|
+
_charsetTarget = null;
|
|
39
|
+
_g0Charset = "ascii";
|
|
40
|
+
_g1Charset = "ascii";
|
|
41
|
+
_shiftOut = false;
|
|
18
42
|
displayBuffer;
|
|
19
43
|
constructor(cols, rows) {
|
|
20
44
|
this._cols = cols;
|
|
21
45
|
this._rows = rows;
|
|
22
46
|
this._scrollBottom = rows - 1;
|
|
23
47
|
this._screen = this._makeScreen(cols, rows);
|
|
48
|
+
this._tabStops = this._createDefaultTabStops(cols);
|
|
49
|
+
this._savedCursor = this._createSavedCursorState();
|
|
24
50
|
this.displayBuffer = Object.defineProperties(
|
|
25
51
|
{},
|
|
26
52
|
{
|
|
@@ -76,8 +102,12 @@ var TerminalBuffer = class {
|
|
|
76
102
|
}
|
|
77
103
|
this._cols = cols;
|
|
78
104
|
this._rows = rows;
|
|
79
|
-
this._scrollTop = 0;
|
|
80
|
-
this._scrollBottom = rows - 1;
|
|
105
|
+
this._scrollTop = this._clamp(this._scrollTop, 0, rows - 1);
|
|
106
|
+
this._scrollBottom = this._clamp(this._scrollBottom, 0, rows - 1);
|
|
107
|
+
if (this._scrollTop >= this._scrollBottom) {
|
|
108
|
+
this._scrollTop = 0;
|
|
109
|
+
this._scrollBottom = rows - 1;
|
|
110
|
+
}
|
|
81
111
|
this._cursorX = this._clamp(this._cursorX, 0, cols - 1);
|
|
82
112
|
this._cursorY = this._clamp(this._cursorY, 0, rows - 1);
|
|
83
113
|
}
|
|
@@ -87,13 +117,96 @@ var TerminalBuffer = class {
|
|
|
87
117
|
_makeRow(cols) {
|
|
88
118
|
return Array(cols).fill(null);
|
|
89
119
|
}
|
|
120
|
+
_createDefaultTabStops(cols) {
|
|
121
|
+
const tabStops = /* @__PURE__ */ new Set();
|
|
122
|
+
for (let column = 8; column < cols; column += 8) {
|
|
123
|
+
tabStops.add(column);
|
|
124
|
+
}
|
|
125
|
+
return tabStops;
|
|
126
|
+
}
|
|
90
127
|
_clamp(value, min, max) {
|
|
91
128
|
return Math.max(min, Math.min(max, value));
|
|
92
129
|
}
|
|
130
|
+
_createSavedCursorState() {
|
|
131
|
+
return {
|
|
132
|
+
x: this._cursorX,
|
|
133
|
+
y: this._cursorY,
|
|
134
|
+
autoWrap: this._autoWrap,
|
|
135
|
+
style: { ...this._style, fg: this._style.fg?.slice(), bg: this._style.bg?.slice() },
|
|
136
|
+
styleSequence: this._styleSequence
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
_saveCursor() {
|
|
140
|
+
this._savedCursor = this._createSavedCursorState();
|
|
141
|
+
}
|
|
142
|
+
_restoreCursor() {
|
|
143
|
+
this._cursorX = this._clamp(this._savedCursor.x, 0, this._cols - 1);
|
|
144
|
+
this._cursorY = this._clamp(this._savedCursor.y, 0, this._rows - 1);
|
|
145
|
+
this._autoWrap = this._savedCursor.autoWrap;
|
|
146
|
+
this._style = {
|
|
147
|
+
...this._savedCursor.style,
|
|
148
|
+
fg: this._savedCursor.style.fg?.slice(),
|
|
149
|
+
bg: this._savedCursor.style.bg?.slice()
|
|
150
|
+
};
|
|
151
|
+
this._styleSequence = this._savedCursor.styleSequence;
|
|
152
|
+
}
|
|
153
|
+
_resetModes() {
|
|
154
|
+
this._autoWrap = true;
|
|
155
|
+
this._originMode = false;
|
|
156
|
+
this._insertMode = false;
|
|
157
|
+
this._pendingWrap = false;
|
|
158
|
+
this._tabStops = this._createDefaultTabStops(this._cols);
|
|
159
|
+
this._g0Charset = "ascii";
|
|
160
|
+
this._g1Charset = "ascii";
|
|
161
|
+
this._shiftOut = false;
|
|
162
|
+
this._resetStyle();
|
|
163
|
+
}
|
|
164
|
+
_writePrintable(ch) {
|
|
165
|
+
const width = this._cellWidth(ch);
|
|
166
|
+
if (this._autoWrap && this._pendingWrap) {
|
|
167
|
+
this._cursorX = 0;
|
|
168
|
+
this._newline();
|
|
169
|
+
} else if (this._autoWrap && this._cursorX + width > this._cols) {
|
|
170
|
+
this._cursorX = 0;
|
|
171
|
+
this._newline();
|
|
172
|
+
}
|
|
173
|
+
if (this._insertMode) {
|
|
174
|
+
const row = this._screen[this._cursorY];
|
|
175
|
+
if (row) {
|
|
176
|
+
row.splice(this._cursorX, 0, ...Array(width).fill(null));
|
|
177
|
+
row.splice(this._cols);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
this._setChar(this._cursorY, this._cursorX, ch);
|
|
181
|
+
for (let column = 1; column < width && this._cursorX + column < this._cols; column += 1) {
|
|
182
|
+
const row = this._screen[this._cursorY];
|
|
183
|
+
if (row) row[this._cursorX + column] = null;
|
|
184
|
+
}
|
|
185
|
+
this._lastPrintedChar = ch;
|
|
186
|
+
if (!this._autoWrap) {
|
|
187
|
+
this._cursorX = Math.min(this._cursorX + width, this._cols - 1);
|
|
188
|
+
this._pendingWrap = false;
|
|
189
|
+
} else if (this._cursorX + width >= this._cols) {
|
|
190
|
+
this._cursorX = this._cols - 1;
|
|
191
|
+
this._pendingWrap = true;
|
|
192
|
+
} else {
|
|
193
|
+
this._cursorX += width;
|
|
194
|
+
this._pendingWrap = false;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
_cellWidth(ch) {
|
|
198
|
+
const codePoint = ch.codePointAt(0);
|
|
199
|
+
if (codePoint === void 0) return 0;
|
|
200
|
+
if (codePoint >= 4352 && codePoint <= 4447 || codePoint === 9001 || codePoint === 9002 || codePoint >= 11904 && codePoint <= 12350 || codePoint >= 12353 && codePoint <= 13247 || codePoint >= 13312 && codePoint <= 19903 || codePoint >= 19968 && codePoint <= 42191 || codePoint >= 44032 && codePoint <= 55215 || codePoint >= 63744 && codePoint <= 64255 || codePoint >= 65040 && codePoint <= 65049 || codePoint >= 65072 && codePoint <= 65135 || codePoint >= 65280 && codePoint <= 65376 || codePoint >= 65504 && codePoint <= 65510 || codePoint >= 127488 && codePoint <= 131069 || codePoint >= 131072 && codePoint <= 262141) {
|
|
201
|
+
return Math.min(2, this._cols);
|
|
202
|
+
}
|
|
203
|
+
return 1;
|
|
204
|
+
}
|
|
93
205
|
_setChar(y, x, ch) {
|
|
94
206
|
const row = this._screen[y];
|
|
95
207
|
if (row && x >= 0 && x < this._cols) {
|
|
96
|
-
const
|
|
208
|
+
const renderedChar = this._style.conceal ? " " : ch;
|
|
209
|
+
const cell = [renderedChar.charCodeAt(0), renderedChar];
|
|
97
210
|
if (this._styleSequence.length > 0) {
|
|
98
211
|
Object.defineProperty(cell, "style", {
|
|
99
212
|
value: this._styleSequence,
|
|
@@ -124,6 +237,7 @@ var TerminalBuffer = class {
|
|
|
124
237
|
}
|
|
125
238
|
}
|
|
126
239
|
_newline() {
|
|
240
|
+
this._pendingWrap = false;
|
|
127
241
|
if (this._cursorY === this._scrollBottom) {
|
|
128
242
|
this._scrollUp(1);
|
|
129
243
|
} else {
|
|
@@ -132,7 +246,11 @@ var TerminalBuffer = class {
|
|
|
132
246
|
}
|
|
133
247
|
_parseCsiParams() {
|
|
134
248
|
if (!this._csiParams) return [];
|
|
135
|
-
|
|
249
|
+
const values = this._csiParams.split(";").flatMap((segment) => segment.split(":")).map((segment) => segment === "" ? 0 : parseInt(segment, 10));
|
|
250
|
+
if ((values[0] === 38 || values[0] === 48) && values[1] === 2 && values[2] === 0) {
|
|
251
|
+
values.splice(2, 1);
|
|
252
|
+
}
|
|
253
|
+
return values;
|
|
136
254
|
}
|
|
137
255
|
_execCsi(final) {
|
|
138
256
|
const params = this._parseCsiParams();
|
|
@@ -143,21 +261,45 @@ var TerminalBuffer = class {
|
|
|
143
261
|
if (params.includes(7)) {
|
|
144
262
|
this._autoWrap = final === "h";
|
|
145
263
|
}
|
|
264
|
+
if (params.includes(6)) {
|
|
265
|
+
this._originMode = final === "h";
|
|
266
|
+
this._cursorX = 0;
|
|
267
|
+
this._cursorY = this._originMode ? this._scrollTop : 0;
|
|
268
|
+
}
|
|
146
269
|
if (params.includes(1049)) {
|
|
147
270
|
if (final === "h") {
|
|
271
|
+
this._primaryScreen = {
|
|
272
|
+
screen: this._screen,
|
|
273
|
+
cursorX: this._cursorX,
|
|
274
|
+
cursorY: this._cursorY,
|
|
275
|
+
pendingWrap: this._pendingWrap,
|
|
276
|
+
style: { ...this._style, fg: this._style.fg?.slice(), bg: this._style.bg?.slice() },
|
|
277
|
+
styleSequence: this._styleSequence
|
|
278
|
+
};
|
|
148
279
|
this._screen = this._makeScreen(this._cols, this._rows);
|
|
149
280
|
this._cursorX = 0;
|
|
150
281
|
this._cursorY = 0;
|
|
282
|
+
this._pendingWrap = false;
|
|
151
283
|
} else {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
284
|
+
if (this._primaryScreen !== null) {
|
|
285
|
+
this._screen = this._primaryScreen.screen;
|
|
286
|
+
this._cursorX = this._primaryScreen.cursorX;
|
|
287
|
+
this._cursorY = this._primaryScreen.cursorY;
|
|
288
|
+
this._pendingWrap = this._primaryScreen.pendingWrap;
|
|
289
|
+
this._style = this._primaryScreen.style;
|
|
290
|
+
this._styleSequence = this._primaryScreen.styleSequence;
|
|
291
|
+
this._primaryScreen = null;
|
|
292
|
+
}
|
|
155
293
|
}
|
|
156
|
-
this._resetStyle();
|
|
294
|
+
if (final === "h") this._resetStyle();
|
|
157
295
|
}
|
|
158
296
|
}
|
|
159
297
|
return;
|
|
160
298
|
}
|
|
299
|
+
if ((final === "h" || final === "l") && params.includes(4)) {
|
|
300
|
+
this._insertMode = final === "h";
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
161
303
|
switch (final) {
|
|
162
304
|
case "A":
|
|
163
305
|
this._cursorY = this._clamp(this._cursorY - Math.max(1, p0), 0, this._rows - 1);
|
|
@@ -189,7 +331,7 @@ var TerminalBuffer = class {
|
|
|
189
331
|
case "H":
|
|
190
332
|
// cursor position
|
|
191
333
|
case "f":
|
|
192
|
-
this._cursorY = this._clamp(Math.max(1, p0) - 1, 0, this._rows - 1);
|
|
334
|
+
this._cursorY = this._originMode ? this._clamp(this._scrollTop + Math.max(1, p0) - 1, this._scrollTop, this._scrollBottom) : this._clamp(Math.max(1, p0) - 1, 0, this._rows - 1);
|
|
193
335
|
this._cursorX = this._clamp(Math.max(1, p1) - 1, 0, this._cols - 1);
|
|
194
336
|
break;
|
|
195
337
|
case "I":
|
|
@@ -204,7 +346,7 @@ var TerminalBuffer = class {
|
|
|
204
346
|
} else if (p0 === 1) {
|
|
205
347
|
for (let y = 0; y < this._cursorY; y++) this._eraseLine(y, 0, this._cols - 1);
|
|
206
348
|
this._eraseLine(this._cursorY, 0, this._cursorX);
|
|
207
|
-
} else if (p0 === 2
|
|
349
|
+
} else if (p0 === 2) {
|
|
208
350
|
for (let y = 0; y < this._rows; y++) this._eraseLine(y, 0, this._cols - 1);
|
|
209
351
|
}
|
|
210
352
|
break;
|
|
@@ -217,6 +359,9 @@ var TerminalBuffer = class {
|
|
|
217
359
|
this._eraseLine(this._cursorY, this._cursorX, this._cursorX + Math.max(1, p0) - 1);
|
|
218
360
|
break;
|
|
219
361
|
case "L": {
|
|
362
|
+
if (this._cursorY < this._scrollTop || this._cursorY > this._scrollBottom) {
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
220
365
|
const n = Math.max(1, p0);
|
|
221
366
|
for (let i = 0; i < n; i++) {
|
|
222
367
|
this._screen.splice(this._scrollBottom, 1);
|
|
@@ -225,6 +370,9 @@ var TerminalBuffer = class {
|
|
|
225
370
|
break;
|
|
226
371
|
}
|
|
227
372
|
case "M": {
|
|
373
|
+
if (this._cursorY < this._scrollTop || this._cursorY > this._scrollBottom) {
|
|
374
|
+
break;
|
|
375
|
+
}
|
|
228
376
|
const n = Math.max(1, p0);
|
|
229
377
|
for (let i = 0; i < n; i++) {
|
|
230
378
|
this._screen.splice(this._cursorY, 1);
|
|
@@ -263,6 +411,13 @@ var TerminalBuffer = class {
|
|
|
263
411
|
}
|
|
264
412
|
break;
|
|
265
413
|
}
|
|
414
|
+
case "b":
|
|
415
|
+
if (this._lastPrintedChar !== null) {
|
|
416
|
+
for (let index = 0; index < Math.max(1, p0); index += 1) {
|
|
417
|
+
this._writePrintable(this._lastPrintedChar);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
break;
|
|
266
421
|
case "d":
|
|
267
422
|
this._cursorY = this._clamp(Math.max(1, p0) - 1, 0, this._rows - 1);
|
|
268
423
|
break;
|
|
@@ -277,15 +432,19 @@ var TerminalBuffer = class {
|
|
|
277
432
|
this._scrollBottom = bottom;
|
|
278
433
|
}
|
|
279
434
|
this._cursorX = 0;
|
|
280
|
-
this._cursorY = 0;
|
|
435
|
+
this._cursorY = this._originMode ? this._scrollTop : 0;
|
|
281
436
|
break;
|
|
282
437
|
}
|
|
283
438
|
case "s":
|
|
284
|
-
this.
|
|
439
|
+
this._saveCursor();
|
|
285
440
|
break;
|
|
286
441
|
case "u":
|
|
287
|
-
this.
|
|
288
|
-
|
|
442
|
+
this._restoreCursor();
|
|
443
|
+
break;
|
|
444
|
+
case "p":
|
|
445
|
+
if (this._csiPrivate === "!") {
|
|
446
|
+
this._resetModes();
|
|
447
|
+
}
|
|
289
448
|
break;
|
|
290
449
|
case "m":
|
|
291
450
|
this._applySgr(params);
|
|
@@ -296,6 +455,14 @@ var TerminalBuffer = class {
|
|
|
296
455
|
}
|
|
297
456
|
_feed(ch) {
|
|
298
457
|
const code = ch.charCodeAt(0);
|
|
458
|
+
if (this._state !== 0 /* Normal */ && (code === 24 || code === 26)) {
|
|
459
|
+
this._state = 0 /* Normal */;
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
if (this._state === 2 /* Csi */ && code === 27) {
|
|
463
|
+
this._state = 1 /* Escape */;
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
299
466
|
switch (this._state) {
|
|
300
467
|
case 0 /* Normal */:
|
|
301
468
|
this._feedNormal(ch, code);
|
|
@@ -310,20 +477,37 @@ var TerminalBuffer = class {
|
|
|
310
477
|
if (code === 7 || code === 156) {
|
|
311
478
|
this._state = 0 /* Normal */;
|
|
312
479
|
} else if (code === 27) {
|
|
313
|
-
this.
|
|
480
|
+
this._stringState = 3 /* Osc */;
|
|
481
|
+
this._state = 5 /* StringEscape */;
|
|
314
482
|
}
|
|
315
483
|
break;
|
|
316
484
|
case 4 /* Str */:
|
|
317
|
-
if (code === 156
|
|
485
|
+
if (code === 156) {
|
|
318
486
|
this._state = 0 /* Normal */;
|
|
319
487
|
} else if (code === 27) {
|
|
320
|
-
this.
|
|
488
|
+
this._stringState = 4 /* Str */;
|
|
489
|
+
this._state = 5 /* StringEscape */;
|
|
321
490
|
}
|
|
322
491
|
break;
|
|
323
|
-
case 5 /*
|
|
492
|
+
case 5 /* StringEscape */:
|
|
493
|
+
this._state = ch === "\\" ? 0 /* Normal */ : this._stringState;
|
|
494
|
+
break;
|
|
495
|
+
case 6 /* EscCharset */:
|
|
496
|
+
if (this._charsetTarget === "g0") this._g0Charset = ch === "0" ? "graphics" : "ascii";
|
|
497
|
+
if (this._charsetTarget === "g1") this._g1Charset = ch === "0" ? "graphics" : "ascii";
|
|
498
|
+
this._charsetTarget = null;
|
|
324
499
|
this._state = 0 /* Normal */;
|
|
325
500
|
break;
|
|
326
|
-
case
|
|
501
|
+
case 7 /* EscHash */:
|
|
502
|
+
if (ch === "8") {
|
|
503
|
+
for (let row = 0; row < this._rows; row += 1) {
|
|
504
|
+
for (let column = 0; column < this._cols; column += 1) {
|
|
505
|
+
this._setChar(row, column, "E");
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
this._cursorX = 0;
|
|
509
|
+
this._cursorY = 0;
|
|
510
|
+
}
|
|
327
511
|
this._state = 0 /* Normal */;
|
|
328
512
|
break;
|
|
329
513
|
}
|
|
@@ -339,32 +523,28 @@ var TerminalBuffer = class {
|
|
|
339
523
|
this._state = 3 /* Osc */;
|
|
340
524
|
} else if (code === 144 || code === 152 || code === 158 || code === 159) {
|
|
341
525
|
this._state = 4 /* Str */;
|
|
526
|
+
} else if (code === 133) {
|
|
527
|
+
this._cursorX = 0;
|
|
528
|
+
this._newline();
|
|
529
|
+
} else if (code === 156) {
|
|
342
530
|
} else if (code === 7 || code === 5 || code === 6) {
|
|
343
531
|
} else if (code === 8) {
|
|
532
|
+
this._pendingWrap = false;
|
|
344
533
|
if (this._cursorX > 0) this._cursorX--;
|
|
345
534
|
} else if (code === 127) {
|
|
346
|
-
if (this._cursorX > 0) {
|
|
347
|
-
this._cursorX--;
|
|
348
|
-
this._setChar(this._cursorY, this._cursorX, " ");
|
|
349
|
-
}
|
|
350
535
|
} else if (code === 9) {
|
|
351
|
-
|
|
536
|
+
const nextTabStop = [...this._tabStops].sort((left, right) => left - right).find((tabStop) => tabStop > this._cursorX);
|
|
537
|
+
this._cursorX = nextTabStop ?? this._cols - 1;
|
|
352
538
|
} else if (code === 10 || code === 11 || code === 12) {
|
|
353
539
|
this._newline();
|
|
354
540
|
} else if (code === 13) {
|
|
541
|
+
this._pendingWrap = false;
|
|
355
542
|
this._cursorX = 0;
|
|
356
543
|
} else if (code === 14 || code === 15) {
|
|
544
|
+
this._shiftOut = code === 14;
|
|
357
545
|
} else if (code >= 32 && code !== 127) {
|
|
358
|
-
this.
|
|
359
|
-
this.
|
|
360
|
-
if (!this._autoWrap) {
|
|
361
|
-
this._cursorX = Math.min(this._cursorX, this._cols - 1);
|
|
362
|
-
return;
|
|
363
|
-
}
|
|
364
|
-
if (this._cursorX >= this._cols) {
|
|
365
|
-
this._cursorX = 0;
|
|
366
|
-
this._newline();
|
|
367
|
-
}
|
|
546
|
+
const charset = this._shiftOut ? this._g1Charset : this._g0Charset;
|
|
547
|
+
this._writePrintable(charset === "graphics" ? DEC_SPECIAL_GRAPHICS[ch] ?? ch : ch);
|
|
368
548
|
}
|
|
369
549
|
}
|
|
370
550
|
_feedEscape(ch, code) {
|
|
@@ -378,14 +558,14 @@ var TerminalBuffer = class {
|
|
|
378
558
|
} else if (code === 80 || code === 88 || code === 94 || code === 95) {
|
|
379
559
|
this._state = 4 /* Str */;
|
|
380
560
|
} else if (code === 40 || code === 41 || code === 42 || code === 43 || code === 45 || code === 46) {
|
|
381
|
-
this.
|
|
561
|
+
this._charsetTarget = code === 40 ? "g0" : code === 41 ? "g1" : null;
|
|
562
|
+
this._state = 6 /* EscCharset */;
|
|
382
563
|
} else if (code === 35) {
|
|
383
|
-
this._state =
|
|
564
|
+
this._state = 7 /* EscHash */;
|
|
384
565
|
} else if (code === 55) {
|
|
385
|
-
this.
|
|
566
|
+
this._saveCursor();
|
|
386
567
|
} else if (code === 56) {
|
|
387
|
-
this.
|
|
388
|
-
this._cursorY = this._clamp(this._savedCursor.y, 0, this._rows - 1);
|
|
568
|
+
this._restoreCursor();
|
|
389
569
|
} else if (code === 68) {
|
|
390
570
|
this._newline();
|
|
391
571
|
} else if (code === 69) {
|
|
@@ -398,14 +578,15 @@ var TerminalBuffer = class {
|
|
|
398
578
|
this._cursorY = Math.max(0, this._cursorY - 1);
|
|
399
579
|
}
|
|
400
580
|
} else if (code === 72) {
|
|
581
|
+
this._tabStops.add(this._cursorX);
|
|
401
582
|
} else if (code === 99) {
|
|
402
583
|
this._screen = this._makeScreen(this._cols, this._rows);
|
|
403
584
|
this._cursorX = 0;
|
|
404
585
|
this._cursorY = 0;
|
|
405
|
-
this._savedCursor = { x: 0, y: 0 };
|
|
406
586
|
this._scrollTop = 0;
|
|
407
587
|
this._scrollBottom = this._rows - 1;
|
|
408
|
-
this.
|
|
588
|
+
this._resetModes();
|
|
589
|
+
this._savedCursor = this._createSavedCursorState();
|
|
409
590
|
}
|
|
410
591
|
}
|
|
411
592
|
_feedCsi(ch, code) {
|
|
@@ -414,7 +595,7 @@ var TerminalBuffer = class {
|
|
|
414
595
|
this._state = 0 /* Normal */;
|
|
415
596
|
} else if (code === 63 || code === 33 || code === 62 || code === 32) {
|
|
416
597
|
this._csiPrivate = ch;
|
|
417
|
-
} else if (code >= 48 && code <= 57 || code === 59) {
|
|
598
|
+
} else if (code >= 48 && code <= 57 || code === 59 || code === 58) {
|
|
418
599
|
this._csiParams += ch;
|
|
419
600
|
}
|
|
420
601
|
}
|
|
@@ -445,6 +626,9 @@ var TerminalBuffer = class {
|
|
|
445
626
|
case 7:
|
|
446
627
|
this._style.inverse = true;
|
|
447
628
|
break;
|
|
629
|
+
case 8:
|
|
630
|
+
this._style.conceal = true;
|
|
631
|
+
break;
|
|
448
632
|
case 9:
|
|
449
633
|
this._style.strikethrough = true;
|
|
450
634
|
break;
|
|
@@ -462,6 +646,9 @@ var TerminalBuffer = class {
|
|
|
462
646
|
case 27:
|
|
463
647
|
this._style.inverse = false;
|
|
464
648
|
break;
|
|
649
|
+
case 28:
|
|
650
|
+
this._style.conceal = false;
|
|
651
|
+
break;
|
|
465
652
|
case 29:
|
|
466
653
|
this._style.strikethrough = false;
|
|
467
654
|
break;
|
|
@@ -516,6 +703,7 @@ function createDefaultStyleState() {
|
|
|
516
703
|
italic: false,
|
|
517
704
|
underline: false,
|
|
518
705
|
inverse: false,
|
|
706
|
+
conceal: false,
|
|
519
707
|
strikethrough: false
|
|
520
708
|
};
|
|
521
709
|
}
|
|
@@ -536,6 +724,9 @@ function serializeStyleState(state) {
|
|
|
536
724
|
if (state.inverse) {
|
|
537
725
|
codes.push(7);
|
|
538
726
|
}
|
|
727
|
+
if (state.conceal) {
|
|
728
|
+
codes.push(8);
|
|
729
|
+
}
|
|
539
730
|
if (state.strikethrough) {
|
|
540
731
|
codes.push(9);
|
|
541
732
|
}
|