dsh-neotui 0.1.7 → 0.1.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/package.json +1 -1
- package/src/term.js +31 -0
package/package.json
CHANGED
package/src/term.js
CHANGED
|
@@ -35,6 +35,7 @@ export class Term {
|
|
|
35
35
|
this.buf = "";
|
|
36
36
|
this.started = false;
|
|
37
37
|
this.pasteBuf = null;
|
|
38
|
+
this.pasting = false; // inside a bracketed paste (200~ … 201~)
|
|
38
39
|
this.w = (output.columns || 80); this.h = (output.rows || 24);
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -108,8 +109,31 @@ export class Term {
|
|
|
108
109
|
|
|
109
110
|
#parse() {
|
|
110
111
|
const buf = this.buf;
|
|
112
|
+
const PASTE_END = "\x1b[201~";
|
|
111
113
|
let i = 0;
|
|
112
114
|
while (i < buf.length) {
|
|
115
|
+
// Inside a bracketed paste: collect raw content up to the END marker
|
|
116
|
+
// and emit it as ONE text event — otherwise a large paste arrives as
|
|
117
|
+
// many small text chunks and the input's two-stage paste never fires.
|
|
118
|
+
if (this.pasting) {
|
|
119
|
+
const end = buf.indexOf(PASTE_END, i);
|
|
120
|
+
if (end === -1) {
|
|
121
|
+
// keep any partial END-marker suffix in the buffer for reassembly
|
|
122
|
+
let keep = 0;
|
|
123
|
+
for (let k = 1; k < PASTE_END.length; k++) {
|
|
124
|
+
if (buf.length - k >= 0 && buf.endsWith(PASTE_END.slice(0, k))) keep = k;
|
|
125
|
+
}
|
|
126
|
+
this.pasteBuf += buf.slice(i, buf.length - keep);
|
|
127
|
+
i = buf.length - keep;
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
this.pasteBuf += buf.slice(i, end);
|
|
131
|
+
this.pasting = false;
|
|
132
|
+
this.#emit({ type: "text", text: this.pasteBuf });
|
|
133
|
+
this.pasteBuf = "";
|
|
134
|
+
i = end + PASTE_END.length;
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
113
137
|
const ch = buf[i];
|
|
114
138
|
if (ch === "\x1b") {
|
|
115
139
|
// escape sequence
|
|
@@ -262,6 +286,13 @@ export class Term {
|
|
|
262
286
|
return;
|
|
263
287
|
}
|
|
264
288
|
const [n = 0, mod = 1] = nums;
|
|
289
|
+
if (n === 200) { this.pasting = true; this.pasteBuf = ""; return; } // bracketed paste START
|
|
290
|
+
if (n === 201) { // bracketed paste END (normally consumed by the collector)
|
|
291
|
+
this.pasting = false;
|
|
292
|
+
if (this.pasteBuf !== "") this.#emit({ type: "text", text: this.pasteBuf });
|
|
293
|
+
this.pasteBuf = "";
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
265
296
|
const name = TILDE_NAMES[n];
|
|
266
297
|
if (!name) return;
|
|
267
298
|
const ctrl = !!(mod - 1 & 4), alt = !!(mod - 1 & 2), shift = !!(mod - 1 & 1);
|