@opentui/core 0.0.0-20251106-788e97e4 → 0.0.0-20251112-a24ada2d
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/3d.js +140 -140
- package/3d.js.map +2 -2
- package/Renderable.d.ts +1 -3
- package/console.d.ts +2 -2
- package/{index-pb1pm3hk.js → index-kj9k00yt.js} +669 -441
- package/index-kj9k00yt.js.map +58 -0
- package/index.js +174 -95
- package/index.js.map +6 -6
- package/lib/KeyHandler.d.ts +4 -9
- package/lib/keymapping.d.ts +1 -0
- package/lib/stdin-buffer.d.ts +8 -6
- package/lib/terminal-capability-detection.d.ts +30 -0
- package/package.json +8 -8
- package/renderables/Code.d.ts +4 -7
- package/renderables/ScrollBox.d.ts +3 -1
- package/renderables/Textarea.d.ts +2 -1
- package/renderables/__tests__/renderable-test-utils.d.ts +7 -0
- package/renderer.d.ts +9 -0
- package/testing/mock-keys.d.ts +5 -1
- package/testing/test-renderer.d.ts +2 -0
- package/testing.js +162 -27
- package/testing.js.map +4 -4
- package/text-buffer.d.ts +2 -0
- package/zig-structs.d.ts +8 -0
- package/zig.d.ts +2 -0
- package/index-pb1pm3hk.js.map +0 -57
|
@@ -27,7 +27,7 @@ var __export = (target, all) => {
|
|
|
27
27
|
};
|
|
28
28
|
var __require = import.meta.require;
|
|
29
29
|
|
|
30
|
-
// ../../node_modules
|
|
30
|
+
// ../../node_modules/yoga-layout/dist/src/index.js
|
|
31
31
|
var exports_src = {};
|
|
32
32
|
__export(exports_src, {
|
|
33
33
|
default: () => src_default,
|
|
@@ -51,7 +51,7 @@ __export(exports_src, {
|
|
|
51
51
|
Align: () => Align
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
-
// ../../node_modules
|
|
54
|
+
// ../../node_modules/yoga-layout/dist/binaries/yoga-wasm-base64-esm.js
|
|
55
55
|
var loadYoga = (() => {
|
|
56
56
|
var _scriptDir = import.meta.url;
|
|
57
57
|
return function(loadYoga2) {
|
|
@@ -1356,7 +1356,7 @@ var loadYoga = (() => {
|
|
|
1356
1356
|
})();
|
|
1357
1357
|
var yoga_wasm_base64_esm_default = loadYoga;
|
|
1358
1358
|
|
|
1359
|
-
// ../../node_modules
|
|
1359
|
+
// ../../node_modules/yoga-layout/dist/src/generated/YGEnums.js
|
|
1360
1360
|
var Align = /* @__PURE__ */ function(Align2) {
|
|
1361
1361
|
Align2[Align2["Auto"] = 0] = "Auto";
|
|
1362
1362
|
Align2[Align2["FlexStart"] = 1] = "FlexStart";
|
|
@@ -1559,7 +1559,7 @@ var constants = {
|
|
|
1559
1559
|
};
|
|
1560
1560
|
var YGEnums_default = constants;
|
|
1561
1561
|
|
|
1562
|
-
// ../../node_modules
|
|
1562
|
+
// ../../node_modules/yoga-layout/dist/src/wrapAssembly.js
|
|
1563
1563
|
function wrapAssembly(lib) {
|
|
1564
1564
|
function patch(prototype, name, fn) {
|
|
1565
1565
|
const original = prototype[name];
|
|
@@ -1661,7 +1661,7 @@ function wrapAssembly(lib) {
|
|
|
1661
1661
|
};
|
|
1662
1662
|
}
|
|
1663
1663
|
|
|
1664
|
-
// ../../node_modules
|
|
1664
|
+
// ../../node_modules/yoga-layout/dist/src/index.js
|
|
1665
1665
|
var Yoga = wrapAssembly(await yoga_wasm_base64_esm_default());
|
|
1666
1666
|
var src_default = Yoga;
|
|
1667
1667
|
|
|
@@ -2079,6 +2079,7 @@ var isShiftKey = (code) => {
|
|
|
2079
2079
|
var isCtrlKey = (code) => {
|
|
2080
2080
|
return ["Oa", "Ob", "Oc", "Od", "Oe", "[2^", "[3^", "[5^", "[6^", "[7^", "[8^"].includes(code);
|
|
2081
2081
|
};
|
|
2082
|
+
var modifyOtherKeysRe = /^\x1b\[27;(\d+);(\d+)~$/;
|
|
2082
2083
|
var parseKeypress = (s = "", options = {}) => {
|
|
2083
2084
|
let parts;
|
|
2084
2085
|
if (Buffer2.isBuffer(s)) {
|
|
@@ -2099,6 +2100,27 @@ var parseKeypress = (s = "", options = {}) => {
|
|
|
2099
2100
|
if (s.startsWith("\x1B[M") && s.length >= 6) {
|
|
2100
2101
|
return null;
|
|
2101
2102
|
}
|
|
2103
|
+
if (/^\x1b\[\d+;\d+;\d+t$/.test(s)) {
|
|
2104
|
+
return null;
|
|
2105
|
+
}
|
|
2106
|
+
if (/^\x1b\[\d+;\d+R$/.test(s)) {
|
|
2107
|
+
return null;
|
|
2108
|
+
}
|
|
2109
|
+
if (/^\x1b\[\?[\d;]+c$/.test(s)) {
|
|
2110
|
+
return null;
|
|
2111
|
+
}
|
|
2112
|
+
if (/^\x1b\[\?[\d;]+\$y$/.test(s)) {
|
|
2113
|
+
return null;
|
|
2114
|
+
}
|
|
2115
|
+
if (s === "\x1B[I" || s === "\x1B[O") {
|
|
2116
|
+
return null;
|
|
2117
|
+
}
|
|
2118
|
+
if (/^\x1b\][\d;].*(\x1b\\|\x07)$/.test(s)) {
|
|
2119
|
+
return null;
|
|
2120
|
+
}
|
|
2121
|
+
if (s === "\x1B[200~" || s === "\x1B[201~") {
|
|
2122
|
+
return null;
|
|
2123
|
+
}
|
|
2102
2124
|
const key = {
|
|
2103
2125
|
name: "",
|
|
2104
2126
|
ctrl: false,
|
|
@@ -2118,6 +2140,29 @@ var parseKeypress = (s = "", options = {}) => {
|
|
|
2118
2140
|
return kittyResult;
|
|
2119
2141
|
}
|
|
2120
2142
|
}
|
|
2143
|
+
const modifyOtherKeysMatch = modifyOtherKeysRe.exec(s);
|
|
2144
|
+
if (modifyOtherKeysMatch) {
|
|
2145
|
+
const modifier = parseInt(modifyOtherKeysMatch[1], 10) - 1;
|
|
2146
|
+
const charCode = parseInt(modifyOtherKeysMatch[2], 10);
|
|
2147
|
+
key.ctrl = !!(modifier & 4);
|
|
2148
|
+
key.meta = !!(modifier & 10);
|
|
2149
|
+
key.shift = !!(modifier & 1);
|
|
2150
|
+
key.option = !!(modifier & 2);
|
|
2151
|
+
if (charCode === 13) {
|
|
2152
|
+
key.name = "return";
|
|
2153
|
+
} else if (charCode === 27) {
|
|
2154
|
+
key.name = "escape";
|
|
2155
|
+
} else if (charCode === 9) {
|
|
2156
|
+
key.name = "tab";
|
|
2157
|
+
} else if (charCode === 32) {
|
|
2158
|
+
key.name = "space";
|
|
2159
|
+
} else if (charCode === 127 || charCode === 8) {
|
|
2160
|
+
key.name = "backspace";
|
|
2161
|
+
} else {
|
|
2162
|
+
key.name = String.fromCharCode(charCode);
|
|
2163
|
+
}
|
|
2164
|
+
return key;
|
|
2165
|
+
}
|
|
2121
2166
|
if (s === "\r" || s === "\x1B\r") {
|
|
2122
2167
|
key.name = "return";
|
|
2123
2168
|
key.meta = s.length === 2;
|
|
@@ -2190,201 +2235,8 @@ var parseKeypress = (s = "", options = {}) => {
|
|
|
2190
2235
|
return key;
|
|
2191
2236
|
};
|
|
2192
2237
|
|
|
2193
|
-
// src/lib/stdin-buffer.ts
|
|
2194
|
-
import { EventEmitter } from "events";
|
|
2195
|
-
var ESC = "\x1B";
|
|
2196
|
-
function isCompleteSequence(data) {
|
|
2197
|
-
if (!data.startsWith(ESC)) {
|
|
2198
|
-
return "not-escape";
|
|
2199
|
-
}
|
|
2200
|
-
if (data.length === 1) {
|
|
2201
|
-
return "incomplete";
|
|
2202
|
-
}
|
|
2203
|
-
const afterEsc = data.slice(1);
|
|
2204
|
-
if (afterEsc.startsWith("[")) {
|
|
2205
|
-
if (afterEsc.startsWith("[M")) {
|
|
2206
|
-
return data.length >= 6 ? "complete" : "incomplete";
|
|
2207
|
-
}
|
|
2208
|
-
return isCompleteCsiSequence(data);
|
|
2209
|
-
}
|
|
2210
|
-
if (afterEsc.startsWith("]")) {
|
|
2211
|
-
return isCompleteOscSequence(data);
|
|
2212
|
-
}
|
|
2213
|
-
if (afterEsc.startsWith("O")) {
|
|
2214
|
-
return afterEsc.length >= 2 ? "complete" : "incomplete";
|
|
2215
|
-
}
|
|
2216
|
-
if (afterEsc.length === 1) {
|
|
2217
|
-
return "complete";
|
|
2218
|
-
}
|
|
2219
|
-
return "complete";
|
|
2220
|
-
}
|
|
2221
|
-
function isCompleteCsiSequence(data) {
|
|
2222
|
-
if (!data.startsWith(ESC + "[")) {
|
|
2223
|
-
return "complete";
|
|
2224
|
-
}
|
|
2225
|
-
if (data.length < 3) {
|
|
2226
|
-
return "incomplete";
|
|
2227
|
-
}
|
|
2228
|
-
const payload = data.slice(2);
|
|
2229
|
-
const lastChar = payload[payload.length - 1];
|
|
2230
|
-
const lastCharCode = lastChar.charCodeAt(0);
|
|
2231
|
-
if (lastCharCode >= 64 && lastCharCode <= 126) {
|
|
2232
|
-
if (payload.startsWith("<")) {
|
|
2233
|
-
const mouseMatch = /^<\d+;\d+;\d+[Mm]$/.test(payload);
|
|
2234
|
-
if (mouseMatch) {
|
|
2235
|
-
return "complete";
|
|
2236
|
-
}
|
|
2237
|
-
if (lastChar === "M" || lastChar === "m") {
|
|
2238
|
-
const parts = payload.slice(1, -1).split(";");
|
|
2239
|
-
if (parts.length === 3 && parts.every((p) => /^\d+$/.test(p))) {
|
|
2240
|
-
return "complete";
|
|
2241
|
-
}
|
|
2242
|
-
}
|
|
2243
|
-
return "incomplete";
|
|
2244
|
-
}
|
|
2245
|
-
return "complete";
|
|
2246
|
-
}
|
|
2247
|
-
return "incomplete";
|
|
2248
|
-
}
|
|
2249
|
-
function isCompleteOscSequence(data) {
|
|
2250
|
-
if (!data.startsWith(ESC + "]")) {
|
|
2251
|
-
return "complete";
|
|
2252
|
-
}
|
|
2253
|
-
if (data.endsWith(ESC + "\\") || data.endsWith("\x07")) {
|
|
2254
|
-
return "complete";
|
|
2255
|
-
}
|
|
2256
|
-
return "incomplete";
|
|
2257
|
-
}
|
|
2258
|
-
function extractCompleteSequences(buffer) {
|
|
2259
|
-
const sequences = [];
|
|
2260
|
-
let pos = 0;
|
|
2261
|
-
while (pos < buffer.length) {
|
|
2262
|
-
const remaining = buffer.slice(pos);
|
|
2263
|
-
if (remaining.startsWith(ESC)) {
|
|
2264
|
-
let seqEnd = 1;
|
|
2265
|
-
while (seqEnd <= remaining.length) {
|
|
2266
|
-
const candidate = remaining.slice(0, seqEnd);
|
|
2267
|
-
const status = isCompleteSequence(candidate);
|
|
2268
|
-
if (status === "complete") {
|
|
2269
|
-
sequences.push(candidate);
|
|
2270
|
-
pos += seqEnd;
|
|
2271
|
-
break;
|
|
2272
|
-
} else if (status === "incomplete") {
|
|
2273
|
-
seqEnd++;
|
|
2274
|
-
} else {
|
|
2275
|
-
sequences.push(candidate);
|
|
2276
|
-
pos += seqEnd;
|
|
2277
|
-
break;
|
|
2278
|
-
}
|
|
2279
|
-
}
|
|
2280
|
-
if (seqEnd > remaining.length) {
|
|
2281
|
-
return { sequences, remainder: remaining };
|
|
2282
|
-
}
|
|
2283
|
-
} else {
|
|
2284
|
-
sequences.push(remaining[0]);
|
|
2285
|
-
pos++;
|
|
2286
|
-
}
|
|
2287
|
-
}
|
|
2288
|
-
return { sequences, remainder: "" };
|
|
2289
|
-
}
|
|
2290
|
-
|
|
2291
|
-
class StdinBuffer extends EventEmitter {
|
|
2292
|
-
buffer = "";
|
|
2293
|
-
timeout = null;
|
|
2294
|
-
timeoutMs;
|
|
2295
|
-
stdin;
|
|
2296
|
-
stdinListener;
|
|
2297
|
-
constructor(stdin, options = {}) {
|
|
2298
|
-
super();
|
|
2299
|
-
this.stdin = stdin;
|
|
2300
|
-
this.timeoutMs = options.timeout ?? 10;
|
|
2301
|
-
this.stdinListener = (data) => {
|
|
2302
|
-
this.handleData(data);
|
|
2303
|
-
};
|
|
2304
|
-
this.stdin.on("data", this.stdinListener);
|
|
2305
|
-
}
|
|
2306
|
-
handleData(data) {
|
|
2307
|
-
if (this.timeout) {
|
|
2308
|
-
clearTimeout(this.timeout);
|
|
2309
|
-
this.timeout = null;
|
|
2310
|
-
}
|
|
2311
|
-
let str;
|
|
2312
|
-
if (Buffer.isBuffer(data)) {
|
|
2313
|
-
if (data.length === 1 && data[0] > 127) {
|
|
2314
|
-
const byte = data[0] - 128;
|
|
2315
|
-
str = "\x1B" + String.fromCharCode(byte);
|
|
2316
|
-
} else {
|
|
2317
|
-
str = data.toString();
|
|
2318
|
-
}
|
|
2319
|
-
} else {
|
|
2320
|
-
str = data;
|
|
2321
|
-
}
|
|
2322
|
-
if (str.length === 0 && this.buffer.length === 0) {
|
|
2323
|
-
this.emit("data", "");
|
|
2324
|
-
return;
|
|
2325
|
-
}
|
|
2326
|
-
this.buffer += str;
|
|
2327
|
-
const result = extractCompleteSequences(this.buffer);
|
|
2328
|
-
this.buffer = result.remainder;
|
|
2329
|
-
for (const sequence of result.sequences) {
|
|
2330
|
-
this.emit("data", sequence);
|
|
2331
|
-
}
|
|
2332
|
-
if (this.buffer.length > 0) {
|
|
2333
|
-
this.timeout = setTimeout(() => {
|
|
2334
|
-
const flushed = this.flush();
|
|
2335
|
-
for (const sequence of flushed) {
|
|
2336
|
-
this.emit("data", sequence);
|
|
2337
|
-
}
|
|
2338
|
-
}, this.timeoutMs);
|
|
2339
|
-
}
|
|
2340
|
-
}
|
|
2341
|
-
flush() {
|
|
2342
|
-
if (this.timeout) {
|
|
2343
|
-
clearTimeout(this.timeout);
|
|
2344
|
-
this.timeout = null;
|
|
2345
|
-
}
|
|
2346
|
-
if (this.buffer.length === 0) {
|
|
2347
|
-
return [];
|
|
2348
|
-
}
|
|
2349
|
-
const sequences = [this.buffer];
|
|
2350
|
-
this.buffer = "";
|
|
2351
|
-
return sequences;
|
|
2352
|
-
}
|
|
2353
|
-
clear() {
|
|
2354
|
-
if (this.timeout) {
|
|
2355
|
-
clearTimeout(this.timeout);
|
|
2356
|
-
this.timeout = null;
|
|
2357
|
-
}
|
|
2358
|
-
this.buffer = "";
|
|
2359
|
-
}
|
|
2360
|
-
getBuffer() {
|
|
2361
|
-
return this.buffer;
|
|
2362
|
-
}
|
|
2363
|
-
destroy() {
|
|
2364
|
-
this.stdin.removeListener("data", this.stdinListener);
|
|
2365
|
-
this.clear();
|
|
2366
|
-
}
|
|
2367
|
-
}
|
|
2368
|
-
|
|
2369
|
-
// src/lib/KeyHandler.ts
|
|
2370
|
-
import { EventEmitter as EventEmitter2 } from "events";
|
|
2371
|
-
|
|
2372
|
-
// src/ansi.ts
|
|
2373
|
-
var ANSI = {
|
|
2374
|
-
switchToAlternateScreen: "\x1B[?1049h",
|
|
2375
|
-
switchToMainScreen: "\x1B[?1049l",
|
|
2376
|
-
reset: "\x1B[0m",
|
|
2377
|
-
scrollDown: (lines) => `\x1B[${lines}T`,
|
|
2378
|
-
scrollUp: (lines) => `\x1B[${lines}S`,
|
|
2379
|
-
moveCursor: (row, col) => `\x1B[${row};${col}H`,
|
|
2380
|
-
moveCursorAndClear: (row, col) => `\x1B[${row};${col}H\x1B[J`,
|
|
2381
|
-
setRgbBackground: (r, g, b) => `\x1B[48;2;${r};${g};${b}m`,
|
|
2382
|
-
resetBackground: "\x1B[49m",
|
|
2383
|
-
bracketedPasteStart: "\x1B[200~",
|
|
2384
|
-
bracketedPasteEnd: "\x1B[201~"
|
|
2385
|
-
};
|
|
2386
|
-
|
|
2387
2238
|
// src/lib/KeyHandler.ts
|
|
2239
|
+
import { EventEmitter } from "events";
|
|
2388
2240
|
class KeyEvent {
|
|
2389
2241
|
name;
|
|
2390
2242
|
ctrl;
|
|
@@ -2443,40 +2295,20 @@ class PasteEvent {
|
|
|
2443
2295
|
}
|
|
2444
2296
|
}
|
|
2445
2297
|
|
|
2446
|
-
class KeyHandler extends
|
|
2447
|
-
stdin;
|
|
2298
|
+
class KeyHandler extends EventEmitter {
|
|
2448
2299
|
useKittyKeyboard;
|
|
2449
|
-
pasteMode = false;
|
|
2450
|
-
pasteBuffer = [];
|
|
2451
2300
|
suspended = false;
|
|
2452
|
-
|
|
2453
|
-
dataListener;
|
|
2454
|
-
constructor(stdin, useKittyKeyboard = false) {
|
|
2301
|
+
constructor(useKittyKeyboard = false) {
|
|
2455
2302
|
super();
|
|
2456
|
-
this.stdin = stdin || process.stdin;
|
|
2457
2303
|
this.useKittyKeyboard = useKittyKeyboard;
|
|
2458
|
-
this.stdinBuffer = new StdinBuffer(this.stdin, { timeout: 5 });
|
|
2459
|
-
this.dataListener = (sequence) => {
|
|
2460
|
-
this.processSequence(sequence);
|
|
2461
|
-
};
|
|
2462
|
-
this.stdinBuffer.on("data", this.dataListener);
|
|
2463
2304
|
}
|
|
2464
|
-
|
|
2465
|
-
if (
|
|
2466
|
-
|
|
2467
|
-
}
|
|
2468
|
-
if (this.pasteMode) {
|
|
2469
|
-
this.pasteBuffer.push(Bun.stripANSI(data));
|
|
2470
|
-
if (data.endsWith(ANSI.bracketedPasteEnd)) {
|
|
2471
|
-
this.pasteMode = false;
|
|
2472
|
-
this.emit("paste", new PasteEvent(this.pasteBuffer.join("")));
|
|
2473
|
-
this.pasteBuffer = [];
|
|
2474
|
-
}
|
|
2475
|
-
return;
|
|
2305
|
+
processInput(data) {
|
|
2306
|
+
if (this.suspended) {
|
|
2307
|
+
return false;
|
|
2476
2308
|
}
|
|
2477
2309
|
const parsedKey = parseKeypress(data, { useKittyKeyboard: this.useKittyKeyboard });
|
|
2478
2310
|
if (!parsedKey) {
|
|
2479
|
-
return;
|
|
2311
|
+
return false;
|
|
2480
2312
|
}
|
|
2481
2313
|
switch (parsedKey.eventType) {
|
|
2482
2314
|
case "press":
|
|
@@ -2492,29 +2324,27 @@ class KeyHandler extends EventEmitter2 {
|
|
|
2492
2324
|
this.emit("keypress", new KeyEvent(parsedKey));
|
|
2493
2325
|
break;
|
|
2494
2326
|
}
|
|
2327
|
+
return true;
|
|
2495
2328
|
}
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2329
|
+
processPaste(data) {
|
|
2330
|
+
if (this.suspended) {
|
|
2331
|
+
return;
|
|
2332
|
+
}
|
|
2333
|
+
const cleanedData = Bun.stripANSI(data);
|
|
2334
|
+
this.emit("paste", new PasteEvent(cleanedData));
|
|
2499
2335
|
}
|
|
2500
2336
|
suspend() {
|
|
2501
|
-
|
|
2502
|
-
this.suspended = true;
|
|
2503
|
-
this.stdinBuffer.removeListener("data", this.dataListener);
|
|
2504
|
-
}
|
|
2337
|
+
this.suspended = true;
|
|
2505
2338
|
}
|
|
2506
2339
|
resume() {
|
|
2507
|
-
|
|
2508
|
-
this.suspended = false;
|
|
2509
|
-
this.stdinBuffer.on("data", this.dataListener);
|
|
2510
|
-
}
|
|
2340
|
+
this.suspended = false;
|
|
2511
2341
|
}
|
|
2512
2342
|
}
|
|
2513
2343
|
|
|
2514
2344
|
class InternalKeyHandler extends KeyHandler {
|
|
2515
2345
|
renderableHandlers = new Map;
|
|
2516
|
-
constructor(
|
|
2517
|
-
super(
|
|
2346
|
+
constructor(useKittyKeyboard = false) {
|
|
2347
|
+
super(useKittyKeyboard);
|
|
2518
2348
|
}
|
|
2519
2349
|
emit(event, ...args) {
|
|
2520
2350
|
return this.emitWithPriority(event, ...args);
|
|
@@ -4528,59 +4358,299 @@ function hastToTextChunks(node, syntaxStyle, parentStyles = []) {
|
|
|
4528
4358
|
chunks.push(...hastToTextChunks(child, syntaxStyle, currentStyles));
|
|
4529
4359
|
}
|
|
4530
4360
|
}
|
|
4531
|
-
return chunks;
|
|
4532
|
-
}
|
|
4533
|
-
function hastToStyledText(hast, syntaxStyle) {
|
|
4534
|
-
const chunks = hastToTextChunks(hast, syntaxStyle);
|
|
4535
|
-
return new StyledText(chunks);
|
|
4361
|
+
return chunks;
|
|
4362
|
+
}
|
|
4363
|
+
function hastToStyledText(hast, syntaxStyle) {
|
|
4364
|
+
const chunks = hastToTextChunks(hast, syntaxStyle);
|
|
4365
|
+
return new StyledText(chunks);
|
|
4366
|
+
}
|
|
4367
|
+
|
|
4368
|
+
// src/lib/scroll-acceleration.ts
|
|
4369
|
+
class LinearScrollAccel {
|
|
4370
|
+
tick(_now) {
|
|
4371
|
+
return 1;
|
|
4372
|
+
}
|
|
4373
|
+
reset() {}
|
|
4374
|
+
}
|
|
4375
|
+
|
|
4376
|
+
class MacOSScrollAccel {
|
|
4377
|
+
opts;
|
|
4378
|
+
lastTickTime = 0;
|
|
4379
|
+
velocityHistory = [];
|
|
4380
|
+
historySize = 3;
|
|
4381
|
+
streakTimeout = 150;
|
|
4382
|
+
minTickInterval = 6;
|
|
4383
|
+
constructor(opts = {}) {
|
|
4384
|
+
this.opts = opts;
|
|
4385
|
+
}
|
|
4386
|
+
tick(now = Date.now()) {
|
|
4387
|
+
const A = this.opts.A ?? 0.8;
|
|
4388
|
+
const tau = this.opts.tau ?? 3;
|
|
4389
|
+
const maxMultiplier = this.opts.maxMultiplier ?? 6;
|
|
4390
|
+
const dt = this.lastTickTime ? now - this.lastTickTime : Infinity;
|
|
4391
|
+
if (dt === Infinity || dt > this.streakTimeout) {
|
|
4392
|
+
this.lastTickTime = now;
|
|
4393
|
+
this.velocityHistory = [];
|
|
4394
|
+
return 1;
|
|
4395
|
+
}
|
|
4396
|
+
if (dt < this.minTickInterval) {
|
|
4397
|
+
return 1;
|
|
4398
|
+
}
|
|
4399
|
+
this.lastTickTime = now;
|
|
4400
|
+
this.velocityHistory.push(dt);
|
|
4401
|
+
if (this.velocityHistory.length > this.historySize) {
|
|
4402
|
+
this.velocityHistory.shift();
|
|
4403
|
+
}
|
|
4404
|
+
const avgInterval = this.velocityHistory.reduce((a, b) => a + b, 0) / this.velocityHistory.length;
|
|
4405
|
+
const referenceInterval = 100;
|
|
4406
|
+
const velocity = referenceInterval / avgInterval;
|
|
4407
|
+
const x = velocity / tau;
|
|
4408
|
+
const multiplier = 1 + A * (Math.exp(x) - 1);
|
|
4409
|
+
return Math.min(multiplier, maxMultiplier);
|
|
4410
|
+
}
|
|
4411
|
+
reset() {
|
|
4412
|
+
this.lastTickTime = 0;
|
|
4413
|
+
this.velocityHistory = [];
|
|
4414
|
+
}
|
|
4415
|
+
}
|
|
4416
|
+
|
|
4417
|
+
// src/lib/stdin-buffer.ts
|
|
4418
|
+
import { EventEmitter as EventEmitter2 } from "events";
|
|
4419
|
+
var ESC = "\x1B";
|
|
4420
|
+
var BRACKETED_PASTE_START = "\x1B[200~";
|
|
4421
|
+
var BRACKETED_PASTE_END = "\x1B[201~";
|
|
4422
|
+
function isCompleteSequence(data) {
|
|
4423
|
+
if (!data.startsWith(ESC)) {
|
|
4424
|
+
return "not-escape";
|
|
4425
|
+
}
|
|
4426
|
+
if (data.length === 1) {
|
|
4427
|
+
return "incomplete";
|
|
4428
|
+
}
|
|
4429
|
+
const afterEsc = data.slice(1);
|
|
4430
|
+
if (afterEsc.startsWith("[")) {
|
|
4431
|
+
if (afterEsc.startsWith("[M")) {
|
|
4432
|
+
return data.length >= 6 ? "complete" : "incomplete";
|
|
4433
|
+
}
|
|
4434
|
+
return isCompleteCsiSequence(data);
|
|
4435
|
+
}
|
|
4436
|
+
if (afterEsc.startsWith("]")) {
|
|
4437
|
+
return isCompleteOscSequence(data);
|
|
4438
|
+
}
|
|
4439
|
+
if (afterEsc.startsWith("P")) {
|
|
4440
|
+
return isCompleteDcsSequence(data);
|
|
4441
|
+
}
|
|
4442
|
+
if (afterEsc.startsWith("_")) {
|
|
4443
|
+
return isCompleteApcSequence(data);
|
|
4444
|
+
}
|
|
4445
|
+
if (afterEsc.startsWith("O")) {
|
|
4446
|
+
return afterEsc.length >= 2 ? "complete" : "incomplete";
|
|
4447
|
+
}
|
|
4448
|
+
if (afterEsc.length === 1) {
|
|
4449
|
+
return "complete";
|
|
4450
|
+
}
|
|
4451
|
+
return "complete";
|
|
4452
|
+
}
|
|
4453
|
+
function isCompleteCsiSequence(data) {
|
|
4454
|
+
if (!data.startsWith(ESC + "[")) {
|
|
4455
|
+
return "complete";
|
|
4456
|
+
}
|
|
4457
|
+
if (data.length < 3) {
|
|
4458
|
+
return "incomplete";
|
|
4459
|
+
}
|
|
4460
|
+
const payload = data.slice(2);
|
|
4461
|
+
const lastChar = payload[payload.length - 1];
|
|
4462
|
+
const lastCharCode = lastChar.charCodeAt(0);
|
|
4463
|
+
if (lastCharCode >= 64 && lastCharCode <= 126) {
|
|
4464
|
+
if (payload.startsWith("<")) {
|
|
4465
|
+
const mouseMatch = /^<\d+;\d+;\d+[Mm]$/.test(payload);
|
|
4466
|
+
if (mouseMatch) {
|
|
4467
|
+
return "complete";
|
|
4468
|
+
}
|
|
4469
|
+
if (lastChar === "M" || lastChar === "m") {
|
|
4470
|
+
const parts = payload.slice(1, -1).split(";");
|
|
4471
|
+
if (parts.length === 3 && parts.every((p) => /^\d+$/.test(p))) {
|
|
4472
|
+
return "complete";
|
|
4473
|
+
}
|
|
4474
|
+
}
|
|
4475
|
+
return "incomplete";
|
|
4476
|
+
}
|
|
4477
|
+
return "complete";
|
|
4478
|
+
}
|
|
4479
|
+
return "incomplete";
|
|
4480
|
+
}
|
|
4481
|
+
function isCompleteOscSequence(data) {
|
|
4482
|
+
if (!data.startsWith(ESC + "]")) {
|
|
4483
|
+
return "complete";
|
|
4484
|
+
}
|
|
4485
|
+
if (data.endsWith(ESC + "\\") || data.endsWith("\x07")) {
|
|
4486
|
+
return "complete";
|
|
4487
|
+
}
|
|
4488
|
+
return "incomplete";
|
|
4489
|
+
}
|
|
4490
|
+
function isCompleteDcsSequence(data) {
|
|
4491
|
+
if (!data.startsWith(ESC + "P")) {
|
|
4492
|
+
return "complete";
|
|
4493
|
+
}
|
|
4494
|
+
if (data.endsWith(ESC + "\\")) {
|
|
4495
|
+
return "complete";
|
|
4496
|
+
}
|
|
4497
|
+
return "incomplete";
|
|
4498
|
+
}
|
|
4499
|
+
function isCompleteApcSequence(data) {
|
|
4500
|
+
if (!data.startsWith(ESC + "_")) {
|
|
4501
|
+
return "complete";
|
|
4502
|
+
}
|
|
4503
|
+
if (data.endsWith(ESC + "\\")) {
|
|
4504
|
+
return "complete";
|
|
4505
|
+
}
|
|
4506
|
+
return "incomplete";
|
|
4507
|
+
}
|
|
4508
|
+
function extractCompleteSequences(buffer) {
|
|
4509
|
+
const sequences = [];
|
|
4510
|
+
let pos = 0;
|
|
4511
|
+
while (pos < buffer.length) {
|
|
4512
|
+
const remaining = buffer.slice(pos);
|
|
4513
|
+
if (remaining.startsWith(ESC)) {
|
|
4514
|
+
let seqEnd = 1;
|
|
4515
|
+
while (seqEnd <= remaining.length) {
|
|
4516
|
+
const candidate = remaining.slice(0, seqEnd);
|
|
4517
|
+
const status = isCompleteSequence(candidate);
|
|
4518
|
+
if (status === "complete") {
|
|
4519
|
+
sequences.push(candidate);
|
|
4520
|
+
pos += seqEnd;
|
|
4521
|
+
break;
|
|
4522
|
+
} else if (status === "incomplete") {
|
|
4523
|
+
seqEnd++;
|
|
4524
|
+
} else {
|
|
4525
|
+
sequences.push(candidate);
|
|
4526
|
+
pos += seqEnd;
|
|
4527
|
+
break;
|
|
4528
|
+
}
|
|
4529
|
+
}
|
|
4530
|
+
if (seqEnd > remaining.length) {
|
|
4531
|
+
return { sequences, remainder: remaining };
|
|
4532
|
+
}
|
|
4533
|
+
} else {
|
|
4534
|
+
sequences.push(remaining[0]);
|
|
4535
|
+
pos++;
|
|
4536
|
+
}
|
|
4537
|
+
}
|
|
4538
|
+
return { sequences, remainder: "" };
|
|
4536
4539
|
}
|
|
4537
4540
|
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4541
|
+
class StdinBuffer extends EventEmitter2 {
|
|
4542
|
+
buffer = "";
|
|
4543
|
+
timeout = null;
|
|
4544
|
+
timeoutMs;
|
|
4545
|
+
pasteMode = false;
|
|
4546
|
+
pasteBuffer = "";
|
|
4547
|
+
constructor(options = {}) {
|
|
4548
|
+
super();
|
|
4549
|
+
this.timeoutMs = options.timeout ?? 10;
|
|
4542
4550
|
}
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4551
|
+
process(data) {
|
|
4552
|
+
if (this.timeout) {
|
|
4553
|
+
clearTimeout(this.timeout);
|
|
4554
|
+
this.timeout = null;
|
|
4555
|
+
}
|
|
4556
|
+
let str;
|
|
4557
|
+
if (Buffer.isBuffer(data)) {
|
|
4558
|
+
if (data.length === 1 && data[0] > 127) {
|
|
4559
|
+
const byte = data[0] - 128;
|
|
4560
|
+
str = "\x1B" + String.fromCharCode(byte);
|
|
4561
|
+
} else {
|
|
4562
|
+
str = data.toString();
|
|
4563
|
+
}
|
|
4564
|
+
} else {
|
|
4565
|
+
str = data;
|
|
4566
|
+
}
|
|
4567
|
+
if (str.length === 0 && this.buffer.length === 0) {
|
|
4568
|
+
this.emit("data", "");
|
|
4569
|
+
return;
|
|
4570
|
+
}
|
|
4571
|
+
this.buffer += str;
|
|
4572
|
+
if (this.pasteMode) {
|
|
4573
|
+
this.pasteBuffer += this.buffer;
|
|
4574
|
+
this.buffer = "";
|
|
4575
|
+
const endIndex = this.pasteBuffer.indexOf(BRACKETED_PASTE_END);
|
|
4576
|
+
if (endIndex !== -1) {
|
|
4577
|
+
const pastedContent = this.pasteBuffer.slice(0, endIndex);
|
|
4578
|
+
const remaining = this.pasteBuffer.slice(endIndex + BRACKETED_PASTE_END.length);
|
|
4579
|
+
this.pasteMode = false;
|
|
4580
|
+
this.pasteBuffer = "";
|
|
4581
|
+
this.emit("paste", pastedContent);
|
|
4582
|
+
if (remaining.length > 0) {
|
|
4583
|
+
this.process(remaining);
|
|
4584
|
+
}
|
|
4585
|
+
}
|
|
4586
|
+
return;
|
|
4587
|
+
}
|
|
4588
|
+
const startIndex = this.buffer.indexOf(BRACKETED_PASTE_START);
|
|
4589
|
+
if (startIndex !== -1) {
|
|
4590
|
+
if (startIndex > 0) {
|
|
4591
|
+
const beforePaste = this.buffer.slice(0, startIndex);
|
|
4592
|
+
const result2 = extractCompleteSequences(beforePaste);
|
|
4593
|
+
for (const sequence of result2.sequences) {
|
|
4594
|
+
this.emit("data", sequence);
|
|
4595
|
+
}
|
|
4596
|
+
}
|
|
4597
|
+
this.buffer = this.buffer.slice(startIndex + BRACKETED_PASTE_START.length);
|
|
4598
|
+
this.pasteMode = true;
|
|
4599
|
+
this.pasteBuffer = this.buffer;
|
|
4600
|
+
this.buffer = "";
|
|
4601
|
+
const endIndex = this.pasteBuffer.indexOf(BRACKETED_PASTE_END);
|
|
4602
|
+
if (endIndex !== -1) {
|
|
4603
|
+
const pastedContent = this.pasteBuffer.slice(0, endIndex);
|
|
4604
|
+
const remaining = this.pasteBuffer.slice(endIndex + BRACKETED_PASTE_END.length);
|
|
4605
|
+
this.pasteMode = false;
|
|
4606
|
+
this.pasteBuffer = "";
|
|
4607
|
+
this.emit("paste", pastedContent);
|
|
4608
|
+
if (remaining.length > 0) {
|
|
4609
|
+
this.process(remaining);
|
|
4610
|
+
}
|
|
4611
|
+
}
|
|
4612
|
+
return;
|
|
4613
|
+
}
|
|
4614
|
+
const result = extractCompleteSequences(this.buffer);
|
|
4615
|
+
this.buffer = result.remainder;
|
|
4616
|
+
for (const sequence of result.sequences) {
|
|
4617
|
+
this.emit("data", sequence);
|
|
4618
|
+
}
|
|
4619
|
+
if (this.buffer.length > 0) {
|
|
4620
|
+
this.timeout = setTimeout(() => {
|
|
4621
|
+
const flushed = this.flush();
|
|
4622
|
+
for (const sequence of flushed) {
|
|
4623
|
+
this.emit("data", sequence);
|
|
4624
|
+
}
|
|
4625
|
+
}, this.timeoutMs);
|
|
4626
|
+
}
|
|
4555
4627
|
}
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
const dt = this.lastTickTime ? now - this.lastTickTime : Infinity;
|
|
4561
|
-
if (dt === Infinity || dt > this.streakTimeout) {
|
|
4562
|
-
this.lastTickTime = now;
|
|
4563
|
-
this.velocityHistory = [];
|
|
4564
|
-
return 1;
|
|
4628
|
+
flush() {
|
|
4629
|
+
if (this.timeout) {
|
|
4630
|
+
clearTimeout(this.timeout);
|
|
4631
|
+
this.timeout = null;
|
|
4565
4632
|
}
|
|
4566
|
-
if (
|
|
4567
|
-
return
|
|
4633
|
+
if (this.buffer.length === 0) {
|
|
4634
|
+
return [];
|
|
4568
4635
|
}
|
|
4569
|
-
|
|
4570
|
-
this.
|
|
4571
|
-
|
|
4572
|
-
|
|
4636
|
+
const sequences = [this.buffer];
|
|
4637
|
+
this.buffer = "";
|
|
4638
|
+
return sequences;
|
|
4639
|
+
}
|
|
4640
|
+
clear() {
|
|
4641
|
+
if (this.timeout) {
|
|
4642
|
+
clearTimeout(this.timeout);
|
|
4643
|
+
this.timeout = null;
|
|
4573
4644
|
}
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
const x = velocity / tau;
|
|
4578
|
-
const multiplier = 1 + A * (Math.exp(x) - 1);
|
|
4579
|
-
return Math.min(multiplier, maxMultiplier);
|
|
4645
|
+
this.buffer = "";
|
|
4646
|
+
this.pasteMode = false;
|
|
4647
|
+
this.pasteBuffer = "";
|
|
4580
4648
|
}
|
|
4581
|
-
|
|
4582
|
-
this.
|
|
4583
|
-
|
|
4649
|
+
getBuffer() {
|
|
4650
|
+
return this.buffer;
|
|
4651
|
+
}
|
|
4652
|
+
destroy() {
|
|
4653
|
+
this.clear();
|
|
4584
4654
|
}
|
|
4585
4655
|
}
|
|
4586
4656
|
|
|
@@ -7563,7 +7633,17 @@ class TerminalPalette {
|
|
|
7563
7633
|
this.activeTimers.push(timer);
|
|
7564
7634
|
inp.on("data", onData);
|
|
7565
7635
|
this.activeListeners.push({ event: "data", handler: onData });
|
|
7566
|
-
this.writeFn([
|
|
7636
|
+
this.writeFn([
|
|
7637
|
+
"\x1B]10;?\x07",
|
|
7638
|
+
"\x1B]11;?\x07",
|
|
7639
|
+
"\x1B]12;?\x07",
|
|
7640
|
+
"\x1B]13;?\x07",
|
|
7641
|
+
"\x1B]14;?\x07",
|
|
7642
|
+
"\x1B]15;?\x07",
|
|
7643
|
+
"\x1B]16;?\x07",
|
|
7644
|
+
"\x1B]17;?\x07",
|
|
7645
|
+
"\x1B]19;?\x07"
|
|
7646
|
+
].join(""));
|
|
7567
7647
|
});
|
|
7568
7648
|
}
|
|
7569
7649
|
async detect(options) {
|
|
@@ -7810,7 +7890,7 @@ class OptimizedBuffer {
|
|
|
7810
7890
|
}
|
|
7811
7891
|
}
|
|
7812
7892
|
|
|
7813
|
-
// ../../node_modules
|
|
7893
|
+
// ../../node_modules/bun-ffi-structs/index.js
|
|
7814
7894
|
import { ptr, toArrayBuffer as toArrayBuffer2 } from "bun:ffi";
|
|
7815
7895
|
function fatalError(...args) {
|
|
7816
7896
|
const message = args.join(" ");
|
|
@@ -7855,6 +7935,23 @@ function isObjectPointerDef(type) {
|
|
|
7855
7935
|
function alignOffset(offset, align) {
|
|
7856
7936
|
return offset + (align - 1) & ~(align - 1);
|
|
7857
7937
|
}
|
|
7938
|
+
function enumTypeError(value) {
|
|
7939
|
+
throw new TypeError(`Invalid enum value: ${value}`);
|
|
7940
|
+
}
|
|
7941
|
+
function defineEnum(mapping, base = "u32") {
|
|
7942
|
+
const reverse2 = Object.fromEntries(Object.entries(mapping).map(([k, v]) => [v, k]));
|
|
7943
|
+
return {
|
|
7944
|
+
__type: "enum",
|
|
7945
|
+
type: base,
|
|
7946
|
+
to(value) {
|
|
7947
|
+
return typeof value === "number" ? value : mapping[value] ?? enumTypeError(String(value));
|
|
7948
|
+
},
|
|
7949
|
+
from(value) {
|
|
7950
|
+
return reverse2[value] ?? enumTypeError(String(value));
|
|
7951
|
+
},
|
|
7952
|
+
enum: mapping
|
|
7953
|
+
};
|
|
7954
|
+
}
|
|
7858
7955
|
function isEnum(type) {
|
|
7859
7956
|
return typeof type === "object" && type.__type === "enum";
|
|
7860
7957
|
}
|
|
@@ -7931,6 +8028,7 @@ function packObjectArray(val) {
|
|
|
7931
8028
|
return bufferView;
|
|
7932
8029
|
}
|
|
7933
8030
|
var encoder = new TextEncoder;
|
|
8031
|
+
var decoder = new TextDecoder;
|
|
7934
8032
|
function defineStruct(fields, structDefOptions) {
|
|
7935
8033
|
let offset = 0;
|
|
7936
8034
|
let maxAlign = 1;
|
|
@@ -7973,6 +8071,7 @@ function defineStruct(fields, structDefOptions) {
|
|
|
7973
8071
|
const ptrVal = pointerUnpacker(view, off);
|
|
7974
8072
|
return ptrVal;
|
|
7975
8073
|
};
|
|
8074
|
+
needsLengthOf = true;
|
|
7976
8075
|
} else if (isEnum(typeOrStruct)) {
|
|
7977
8076
|
const base = typeOrStruct.type;
|
|
7978
8077
|
size = typeSizes[base];
|
|
@@ -8175,9 +8274,10 @@ function defineStruct(fields, structDefOptions) {
|
|
|
8175
8274
|
lengthOfFields[options.lengthOf] = layoutField;
|
|
8176
8275
|
}
|
|
8177
8276
|
if (needsLengthOf) {
|
|
8178
|
-
|
|
8179
|
-
|
|
8180
|
-
|
|
8277
|
+
const def = typeof typeOrStruct === "string" && typeOrStruct === "char*" ? "char*" : lengthOfDef;
|
|
8278
|
+
if (!def)
|
|
8279
|
+
fatalError(`Internal error: needsLengthOf=true but def is null for ${name}`);
|
|
8280
|
+
lengthOfRequested.push({ requester: layoutField, def });
|
|
8181
8281
|
}
|
|
8182
8282
|
offset += size;
|
|
8183
8283
|
maxAlign = Math.max(maxAlign, align);
|
|
@@ -8185,9 +8285,26 @@ function defineStruct(fields, structDefOptions) {
|
|
|
8185
8285
|
for (const { requester, def } of lengthOfRequested) {
|
|
8186
8286
|
const lengthOfField = lengthOfFields[requester.name];
|
|
8187
8287
|
if (!lengthOfField) {
|
|
8288
|
+
if (def === "char*") {
|
|
8289
|
+
continue;
|
|
8290
|
+
}
|
|
8188
8291
|
throw new Error(`lengthOf field not found for array field ${requester.name}`);
|
|
8189
8292
|
}
|
|
8190
|
-
if (
|
|
8293
|
+
if (def === "char*") {
|
|
8294
|
+
requester.unpack = (view, off) => {
|
|
8295
|
+
const ptrAddress = pointerUnpacker(view, off);
|
|
8296
|
+
const length = lengthOfField.unpack(view, lengthOfField.offset);
|
|
8297
|
+
if (ptrAddress === 0) {
|
|
8298
|
+
return null;
|
|
8299
|
+
}
|
|
8300
|
+
const byteLength = typeof length === "bigint" ? Number(length) : length;
|
|
8301
|
+
if (byteLength === 0) {
|
|
8302
|
+
return "";
|
|
8303
|
+
}
|
|
8304
|
+
const buffer = toArrayBuffer2(ptrAddress, 0, byteLength);
|
|
8305
|
+
return decoder.decode(buffer);
|
|
8306
|
+
};
|
|
8307
|
+
} else if (isPrimitiveType(def)) {
|
|
8191
8308
|
const elemSize = typeSizes[def];
|
|
8192
8309
|
const { unpack: primitiveUnpack } = primitivePackers(def);
|
|
8193
8310
|
requester.unpack = (view, off) => {
|
|
@@ -8427,6 +8544,27 @@ var VisualCursorStruct = defineStruct([
|
|
|
8427
8544
|
["logicalCol", "u32"],
|
|
8428
8545
|
["offset", "u32"]
|
|
8429
8546
|
]);
|
|
8547
|
+
var UnicodeMethodEnum = defineEnum({ wcwidth: 0, unicode: 1 }, "u8");
|
|
8548
|
+
var TerminalCapabilitiesStruct = defineStruct([
|
|
8549
|
+
["kitty_keyboard", "bool_u8"],
|
|
8550
|
+
["kitty_graphics", "bool_u8"],
|
|
8551
|
+
["rgb", "bool_u8"],
|
|
8552
|
+
["unicode", UnicodeMethodEnum],
|
|
8553
|
+
["sgr_pixels", "bool_u8"],
|
|
8554
|
+
["color_scheme_updates", "bool_u8"],
|
|
8555
|
+
["explicit_width", "bool_u8"],
|
|
8556
|
+
["scaled_text", "bool_u8"],
|
|
8557
|
+
["sixel", "bool_u8"],
|
|
8558
|
+
["focus_tracking", "bool_u8"],
|
|
8559
|
+
["sync", "bool_u8"],
|
|
8560
|
+
["bracketed_paste", "bool_u8"],
|
|
8561
|
+
["hyperlinks", "bool_u8"],
|
|
8562
|
+
["term_name", "char*"],
|
|
8563
|
+
["term_name_len", "u64", { lengthOf: "term_name" }],
|
|
8564
|
+
["term_version", "char*"],
|
|
8565
|
+
["term_version_len", "u64", { lengthOf: "term_version" }],
|
|
8566
|
+
["term_from_xtversion", "bool_u8"]
|
|
8567
|
+
]);
|
|
8430
8568
|
|
|
8431
8569
|
// src/zig.ts
|
|
8432
8570
|
var module = await import(`@opentui/core-${process.platform}-${process.arch}/index.ts`);
|
|
@@ -8748,6 +8886,14 @@ function getOpenTUILib(libPath) {
|
|
|
8748
8886
|
args: ["ptr", "u8"],
|
|
8749
8887
|
returns: "void"
|
|
8750
8888
|
},
|
|
8889
|
+
textBufferAppend: {
|
|
8890
|
+
args: ["ptr", "ptr", "usize"],
|
|
8891
|
+
returns: "void"
|
|
8892
|
+
},
|
|
8893
|
+
textBufferAppendFromMemId: {
|
|
8894
|
+
args: ["ptr", "u8"],
|
|
8895
|
+
returns: "void"
|
|
8896
|
+
},
|
|
8751
8897
|
textBufferLoadFile: {
|
|
8752
8898
|
args: ["ptr", "ptr", "usize"],
|
|
8753
8899
|
returns: "bool"
|
|
@@ -9711,6 +9857,12 @@ class FFIRenderLib {
|
|
|
9711
9857
|
textBufferSetTextFromMem(buffer, memId) {
|
|
9712
9858
|
this.opentui.symbols.textBufferSetTextFromMem(buffer, memId);
|
|
9713
9859
|
}
|
|
9860
|
+
textBufferAppend(buffer, bytes) {
|
|
9861
|
+
this.opentui.symbols.textBufferAppend(buffer, bytes, bytes.length);
|
|
9862
|
+
}
|
|
9863
|
+
textBufferAppendFromMemId(buffer, memId) {
|
|
9864
|
+
this.opentui.symbols.textBufferAppendFromMemId(buffer, memId);
|
|
9865
|
+
}
|
|
9714
9866
|
textBufferLoadFile(buffer, path4) {
|
|
9715
9867
|
const pathBytes = this.encoder.encode(path4);
|
|
9716
9868
|
return this.opentui.symbols.textBufferLoadFile(buffer, pathBytes, pathBytes.length);
|
|
@@ -10242,25 +10394,29 @@ class FFIRenderLib {
|
|
|
10242
10394
|
this.opentui.symbols.bufferClearScissorRects(buffer);
|
|
10243
10395
|
}
|
|
10244
10396
|
getTerminalCapabilities(renderer) {
|
|
10245
|
-
const capsBuffer = new
|
|
10246
|
-
this.opentui.symbols.getTerminalCapabilities(renderer, capsBuffer);
|
|
10247
|
-
|
|
10248
|
-
|
|
10249
|
-
kitty_keyboard:
|
|
10250
|
-
kitty_graphics:
|
|
10251
|
-
rgb:
|
|
10252
|
-
unicode:
|
|
10253
|
-
sgr_pixels:
|
|
10254
|
-
color_scheme_updates:
|
|
10255
|
-
explicit_width:
|
|
10256
|
-
scaled_text:
|
|
10257
|
-
sixel:
|
|
10258
|
-
focus_tracking:
|
|
10259
|
-
sync:
|
|
10260
|
-
bracketed_paste:
|
|
10261
|
-
hyperlinks:
|
|
10397
|
+
const capsBuffer = new ArrayBuffer(TerminalCapabilitiesStruct.size);
|
|
10398
|
+
this.opentui.symbols.getTerminalCapabilities(renderer, ptr3(capsBuffer));
|
|
10399
|
+
const caps = TerminalCapabilitiesStruct.unpack(capsBuffer);
|
|
10400
|
+
return {
|
|
10401
|
+
kitty_keyboard: caps.kitty_keyboard,
|
|
10402
|
+
kitty_graphics: caps.kitty_graphics,
|
|
10403
|
+
rgb: caps.rgb,
|
|
10404
|
+
unicode: caps.unicode,
|
|
10405
|
+
sgr_pixels: caps.sgr_pixels,
|
|
10406
|
+
color_scheme_updates: caps.color_scheme_updates,
|
|
10407
|
+
explicit_width: caps.explicit_width,
|
|
10408
|
+
scaled_text: caps.scaled_text,
|
|
10409
|
+
sixel: caps.sixel,
|
|
10410
|
+
focus_tracking: caps.focus_tracking,
|
|
10411
|
+
sync: caps.sync,
|
|
10412
|
+
bracketed_paste: caps.bracketed_paste,
|
|
10413
|
+
hyperlinks: caps.hyperlinks,
|
|
10414
|
+
terminal: {
|
|
10415
|
+
name: caps.term_name ?? "",
|
|
10416
|
+
version: caps.term_version ?? "",
|
|
10417
|
+
from_xtversion: caps.term_from_xtversion
|
|
10418
|
+
}
|
|
10262
10419
|
};
|
|
10263
|
-
return capabilities;
|
|
10264
10420
|
}
|
|
10265
10421
|
processCapabilityResponse(renderer, response) {
|
|
10266
10422
|
const responseBytes = this.encoder.encode(response);
|
|
@@ -10352,6 +10508,7 @@ class TextBuffer {
|
|
|
10352
10508
|
_syntaxStyle;
|
|
10353
10509
|
_textBytes;
|
|
10354
10510
|
_memId;
|
|
10511
|
+
_appendedChunks = [];
|
|
10355
10512
|
constructor(lib, ptr4) {
|
|
10356
10513
|
this.lib = lib;
|
|
10357
10514
|
this.bufferPtr = ptr4;
|
|
@@ -10376,6 +10533,16 @@ class TextBuffer {
|
|
|
10376
10533
|
this._length = this.lib.textBufferGetLength(this.bufferPtr);
|
|
10377
10534
|
this._byteSize = this.lib.textBufferGetByteSize(this.bufferPtr);
|
|
10378
10535
|
this._lineInfo = undefined;
|
|
10536
|
+
this._appendedChunks = [];
|
|
10537
|
+
}
|
|
10538
|
+
append(text) {
|
|
10539
|
+
this.guard();
|
|
10540
|
+
const textBytes = this.lib.encoder.encode(text);
|
|
10541
|
+
this._appendedChunks.push(textBytes);
|
|
10542
|
+
this.lib.textBufferAppend(this.bufferPtr, textBytes);
|
|
10543
|
+
this._length = this.lib.textBufferGetLength(this.bufferPtr);
|
|
10544
|
+
this._byteSize = this.lib.textBufferGetByteSize(this.bufferPtr);
|
|
10545
|
+
this._lineInfo = undefined;
|
|
10379
10546
|
}
|
|
10380
10547
|
loadFile(path4) {
|
|
10381
10548
|
this.guard();
|
|
@@ -10501,6 +10668,7 @@ class TextBuffer {
|
|
|
10501
10668
|
this._byteSize = 0;
|
|
10502
10669
|
this._lineInfo = undefined;
|
|
10503
10670
|
this._textBytes = undefined;
|
|
10671
|
+
this._appendedChunks = [];
|
|
10504
10672
|
}
|
|
10505
10673
|
reset() {
|
|
10506
10674
|
this.guard();
|
|
@@ -10510,6 +10678,7 @@ class TextBuffer {
|
|
|
10510
10678
|
this._lineInfo = undefined;
|
|
10511
10679
|
this._textBytes = undefined;
|
|
10512
10680
|
this._memId = undefined;
|
|
10681
|
+
this._appendedChunks = [];
|
|
10513
10682
|
}
|
|
10514
10683
|
destroy() {
|
|
10515
10684
|
if (this._destroyed)
|
|
@@ -10693,7 +10862,6 @@ class Renderable extends BaseRenderable {
|
|
|
10693
10862
|
parent = null;
|
|
10694
10863
|
childrenPrimarySortDirty = true;
|
|
10695
10864
|
childrenSortedByPrimaryAxis = [];
|
|
10696
|
-
_newChildren = [];
|
|
10697
10865
|
onLifecyclePass = null;
|
|
10698
10866
|
renderBefore;
|
|
10699
10867
|
renderAfter;
|
|
@@ -11351,7 +11519,6 @@ class Renderable extends BaseRenderable {
|
|
|
11351
11519
|
}
|
|
11352
11520
|
obj.parent = this;
|
|
11353
11521
|
}
|
|
11354
|
-
_forceLayoutUpdateFor = null;
|
|
11355
11522
|
add(obj, index) {
|
|
11356
11523
|
if (!obj) {
|
|
11357
11524
|
return -1;
|
|
@@ -11385,7 +11552,6 @@ class Renderable extends BaseRenderable {
|
|
|
11385
11552
|
this.propagateLiveCount(renderable._liveCount);
|
|
11386
11553
|
}
|
|
11387
11554
|
}
|
|
11388
|
-
this._newChildren.push(renderable);
|
|
11389
11555
|
const childLayoutNode = renderable.getLayoutNode();
|
|
11390
11556
|
const insertedIndex = this._childrenInLayoutOrder.length;
|
|
11391
11557
|
this._childrenInLayoutOrder.push(renderable);
|
|
@@ -11438,11 +11604,9 @@ class Renderable extends BaseRenderable {
|
|
|
11438
11604
|
this.propagateLiveCount(renderable._liveCount);
|
|
11439
11605
|
}
|
|
11440
11606
|
}
|
|
11441
|
-
this._newChildren.push(renderable);
|
|
11442
11607
|
this.childrenPrimarySortDirty = true;
|
|
11443
11608
|
const anchorIndex = this._childrenInLayoutOrder.indexOf(anchor);
|
|
11444
11609
|
const insertedIndex = Math.max(0, Math.min(anchorIndex, this._childrenInLayoutOrder.length));
|
|
11445
|
-
this._forceLayoutUpdateFor = this._childrenInLayoutOrder.slice(insertedIndex);
|
|
11446
11610
|
this._childrenInLayoutOrder.splice(insertedIndex, 0, renderable);
|
|
11447
11611
|
this.yogaNode.insertChild(renderable.getLayoutNode(), insertedIndex);
|
|
11448
11612
|
this.requestRender();
|
|
@@ -11476,16 +11640,6 @@ class Renderable extends BaseRenderable {
|
|
|
11476
11640
|
if (zIndexIndex !== -1) {
|
|
11477
11641
|
this._childrenInZIndexOrder.splice(zIndexIndex, 1);
|
|
11478
11642
|
}
|
|
11479
|
-
if (this._forceLayoutUpdateFor) {
|
|
11480
|
-
const forceIndex = this._forceLayoutUpdateFor.findIndex((obj2) => obj2.id === id);
|
|
11481
|
-
if (forceIndex !== -1) {
|
|
11482
|
-
this._forceLayoutUpdateFor?.splice(forceIndex, 1);
|
|
11483
|
-
}
|
|
11484
|
-
}
|
|
11485
|
-
const newChildIndex = this._newChildren.findIndex((obj2) => obj2.id === id);
|
|
11486
|
-
if (newChildIndex !== -1) {
|
|
11487
|
-
this._newChildren?.splice(newChildIndex, 1);
|
|
11488
|
-
}
|
|
11489
11643
|
this.childrenPrimarySortDirty = true;
|
|
11490
11644
|
}
|
|
11491
11645
|
}
|
|
@@ -11503,18 +11657,6 @@ class Renderable extends BaseRenderable {
|
|
|
11503
11657
|
this.onUpdate(deltaTime);
|
|
11504
11658
|
this.updateFromLayout();
|
|
11505
11659
|
renderList.push({ action: "render", renderable: this });
|
|
11506
|
-
if (this._newChildren.length > 0) {
|
|
11507
|
-
for (const child of this._newChildren) {
|
|
11508
|
-
child.updateFromLayout();
|
|
11509
|
-
}
|
|
11510
|
-
this._newChildren = [];
|
|
11511
|
-
}
|
|
11512
|
-
if (this._forceLayoutUpdateFor) {
|
|
11513
|
-
for (const child of this._forceLayoutUpdateFor) {
|
|
11514
|
-
child.updateFromLayout();
|
|
11515
|
-
}
|
|
11516
|
-
this._forceLayoutUpdateFor = null;
|
|
11517
|
-
}
|
|
11518
11660
|
this.ensureZIndexSorted();
|
|
11519
11661
|
const shouldPushScissor = this._overflow !== "visible" && this.width > 0 && this.height > 0;
|
|
11520
11662
|
if (shouldPushScissor) {
|
|
@@ -11527,7 +11669,12 @@ class Renderable extends BaseRenderable {
|
|
|
11527
11669
|
height: scissorRect.height
|
|
11528
11670
|
});
|
|
11529
11671
|
}
|
|
11530
|
-
|
|
11672
|
+
const visibleChildren = this._getVisibleChildren();
|
|
11673
|
+
for (const child of this._childrenInZIndexOrder) {
|
|
11674
|
+
if (!visibleChildren.includes(child.num)) {
|
|
11675
|
+
child.updateFromLayout();
|
|
11676
|
+
continue;
|
|
11677
|
+
}
|
|
11531
11678
|
child.updateLayout(deltaTime, renderList);
|
|
11532
11679
|
}
|
|
11533
11680
|
if (shouldPushScissor) {
|
|
@@ -11552,8 +11699,8 @@ class Renderable extends BaseRenderable {
|
|
|
11552
11699
|
buffer.drawFrameBuffer(this.x, this.y, this.frameBuffer);
|
|
11553
11700
|
}
|
|
11554
11701
|
}
|
|
11555
|
-
|
|
11556
|
-
return this._childrenInZIndexOrder;
|
|
11702
|
+
_getVisibleChildren() {
|
|
11703
|
+
return this._childrenInZIndexOrder.map((child) => child.num);
|
|
11557
11704
|
}
|
|
11558
11705
|
onUpdate(deltaTime) {}
|
|
11559
11706
|
getScissorRect() {
|
|
@@ -12150,7 +12297,7 @@ class TerminalConsole extends EventEmitter8 {
|
|
|
12150
12297
|
isVisible = false;
|
|
12151
12298
|
isFocused = false;
|
|
12152
12299
|
renderer;
|
|
12153
|
-
|
|
12300
|
+
keyHandler;
|
|
12154
12301
|
options;
|
|
12155
12302
|
_debugModeEnabled = false;
|
|
12156
12303
|
frameBuffer = null;
|
|
@@ -12188,7 +12335,7 @@ class TerminalConsole extends EventEmitter8 {
|
|
|
12188
12335
|
super();
|
|
12189
12336
|
this.renderer = renderer;
|
|
12190
12337
|
this.options = { ...DEFAULT_CONSOLE_OPTIONS, ...options };
|
|
12191
|
-
this.
|
|
12338
|
+
this.keyHandler = this.handleKeyPress.bind(this);
|
|
12192
12339
|
this._debugModeEnabled = this.options.startInDebugMode;
|
|
12193
12340
|
terminalConsoleCache.setCollectCallerInfo(this._debugModeEnabled);
|
|
12194
12341
|
this._rgbaInfo = parseColor(this.options.colorInfo);
|
|
@@ -12267,75 +12414,65 @@ class TerminalConsole extends EventEmitter8 {
|
|
|
12267
12414
|
}
|
|
12268
12415
|
this.currentLineIndex = Math.max(0, Math.min(this.currentLineIndex, this.consoleHeight - 1));
|
|
12269
12416
|
}
|
|
12270
|
-
|
|
12271
|
-
const key = data.toString();
|
|
12417
|
+
handleKeyPress(event) {
|
|
12272
12418
|
let needsRedraw = false;
|
|
12273
12419
|
const displayLineCount = this._displayLines.length;
|
|
12274
12420
|
const logAreaHeight = Math.max(1, this.consoleHeight - 1);
|
|
12275
12421
|
const maxScrollTop = Math.max(0, displayLineCount - logAreaHeight);
|
|
12276
12422
|
const currentPositionIndex = this._positions.indexOf(this.options.position);
|
|
12277
|
-
|
|
12278
|
-
|
|
12279
|
-
|
|
12280
|
-
|
|
12281
|
-
|
|
12282
|
-
|
|
12283
|
-
|
|
12284
|
-
|
|
12285
|
-
|
|
12286
|
-
|
|
12287
|
-
|
|
12288
|
-
|
|
12289
|
-
|
|
12290
|
-
|
|
12291
|
-
|
|
12292
|
-
|
|
12293
|
-
|
|
12294
|
-
|
|
12295
|
-
|
|
12296
|
-
|
|
12297
|
-
|
|
12298
|
-
|
|
12299
|
-
|
|
12300
|
-
|
|
12301
|
-
|
|
12302
|
-
|
|
12303
|
-
|
|
12304
|
-
|
|
12305
|
-
|
|
12306
|
-
|
|
12307
|
-
|
|
12308
|
-
|
|
12309
|
-
|
|
12310
|
-
|
|
12311
|
-
|
|
12312
|
-
|
|
12313
|
-
|
|
12314
|
-
|
|
12315
|
-
|
|
12316
|
-
|
|
12317
|
-
|
|
12318
|
-
|
|
12319
|
-
|
|
12320
|
-
|
|
12321
|
-
|
|
12322
|
-
|
|
12323
|
-
|
|
12324
|
-
|
|
12325
|
-
|
|
12326
|
-
|
|
12327
|
-
|
|
12328
|
-
|
|
12329
|
-
|
|
12330
|
-
this.resize(this.renderer.terminalWidth, this.renderer.terminalHeight);
|
|
12331
|
-
break;
|
|
12332
|
-
case "-":
|
|
12333
|
-
this.options.sizePercent = Math.max(10, this.options.sizePercent - 5);
|
|
12334
|
-
this.resize(this.renderer.terminalWidth, this.renderer.terminalHeight);
|
|
12335
|
-
break;
|
|
12336
|
-
case "\x13":
|
|
12337
|
-
this.saveLogsToFile();
|
|
12338
|
-
break;
|
|
12423
|
+
if (event.name === "escape") {
|
|
12424
|
+
this.blur();
|
|
12425
|
+
return;
|
|
12426
|
+
}
|
|
12427
|
+
if (event.name === "up" && event.shift) {
|
|
12428
|
+
if (this.scrollTopIndex > 0 || this.currentLineIndex > 0) {
|
|
12429
|
+
this.scrollTopIndex = 0;
|
|
12430
|
+
this.currentLineIndex = 0;
|
|
12431
|
+
this.isScrolledToBottom = this._displayLines.length <= Math.max(1, this.consoleHeight - 1);
|
|
12432
|
+
needsRedraw = true;
|
|
12433
|
+
}
|
|
12434
|
+
} else if (event.name === "down" && event.shift) {
|
|
12435
|
+
const logAreaHeightForScroll = Math.max(1, this.consoleHeight - 1);
|
|
12436
|
+
const maxScrollPossible = Math.max(0, this._displayLines.length - logAreaHeightForScroll);
|
|
12437
|
+
if (this.scrollTopIndex < maxScrollPossible || !this.isScrolledToBottom) {
|
|
12438
|
+
this._scrollToBottom(true);
|
|
12439
|
+
needsRedraw = true;
|
|
12440
|
+
}
|
|
12441
|
+
} else if (event.name === "up") {
|
|
12442
|
+
if (this.currentLineIndex > 0) {
|
|
12443
|
+
this.currentLineIndex--;
|
|
12444
|
+
needsRedraw = true;
|
|
12445
|
+
} else if (this.scrollTopIndex > 0) {
|
|
12446
|
+
this.scrollTopIndex--;
|
|
12447
|
+
this.isScrolledToBottom = false;
|
|
12448
|
+
needsRedraw = true;
|
|
12449
|
+
}
|
|
12450
|
+
} else if (event.name === "down") {
|
|
12451
|
+
const canCursorMoveDown = this.currentLineIndex < logAreaHeight - 1 && this.scrollTopIndex + this.currentLineIndex < displayLineCount - 1;
|
|
12452
|
+
if (canCursorMoveDown) {
|
|
12453
|
+
this.currentLineIndex++;
|
|
12454
|
+
needsRedraw = true;
|
|
12455
|
+
} else if (this.scrollTopIndex < maxScrollTop) {
|
|
12456
|
+
this.scrollTopIndex++;
|
|
12457
|
+
this.isScrolledToBottom = this.scrollTopIndex === maxScrollTop;
|
|
12458
|
+
needsRedraw = true;
|
|
12459
|
+
}
|
|
12460
|
+
} else if (event.name === "p" && event.ctrl) {
|
|
12461
|
+
const prevIndex = (currentPositionIndex - 1 + this._positions.length) % this._positions.length;
|
|
12462
|
+
this.options.position = this._positions[prevIndex];
|
|
12463
|
+
this.resize(this.renderer.terminalWidth, this.renderer.terminalHeight);
|
|
12464
|
+
} else if (event.name === "o" && event.ctrl) {
|
|
12465
|
+
const nextIndex = (currentPositionIndex + 1) % this._positions.length;
|
|
12466
|
+
this.options.position = this._positions[nextIndex];
|
|
12467
|
+
this.resize(this.renderer.terminalWidth, this.renderer.terminalHeight);
|
|
12468
|
+
} else if (event.name === "+" || event.name === "=" && event.shift) {
|
|
12469
|
+
this.options.sizePercent = Math.min(100, this.options.sizePercent + 5);
|
|
12470
|
+
this.resize(this.renderer.terminalWidth, this.renderer.terminalHeight);
|
|
12471
|
+
} else if (event.name === "-") {
|
|
12472
|
+
this.options.sizePercent = Math.max(10, this.options.sizePercent - 5);
|
|
12473
|
+
this.resize(this.renderer.terminalWidth, this.renderer.terminalHeight);
|
|
12474
|
+
} else if (event.name === "s" && event.ctrl) {
|
|
12475
|
+
this.saveLogsToFile();
|
|
12339
12476
|
}
|
|
12340
12477
|
if (needsRedraw) {
|
|
12341
12478
|
this.markNeedsRerender();
|
|
@@ -12344,13 +12481,13 @@ class TerminalConsole extends EventEmitter8 {
|
|
|
12344
12481
|
attachStdin() {
|
|
12345
12482
|
if (this.isFocused)
|
|
12346
12483
|
return;
|
|
12347
|
-
|
|
12484
|
+
this.renderer.keyInput.on("keypress", this.keyHandler);
|
|
12348
12485
|
this.isFocused = true;
|
|
12349
12486
|
}
|
|
12350
12487
|
detachStdin() {
|
|
12351
12488
|
if (!this.isFocused)
|
|
12352
12489
|
return;
|
|
12353
|
-
|
|
12490
|
+
this.renderer.keyInput.off("keypress", this.keyHandler);
|
|
12354
12491
|
this.isFocused = false;
|
|
12355
12492
|
}
|
|
12356
12493
|
formatTimestamp(date) {
|
|
@@ -12605,6 +12742,21 @@ class TerminalConsole extends EventEmitter8 {
|
|
|
12605
12742
|
}
|
|
12606
12743
|
}
|
|
12607
12744
|
|
|
12745
|
+
// src/ansi.ts
|
|
12746
|
+
var ANSI = {
|
|
12747
|
+
switchToAlternateScreen: "\x1B[?1049h",
|
|
12748
|
+
switchToMainScreen: "\x1B[?1049l",
|
|
12749
|
+
reset: "\x1B[0m",
|
|
12750
|
+
scrollDown: (lines) => `\x1B[${lines}T`,
|
|
12751
|
+
scrollUp: (lines) => `\x1B[${lines}S`,
|
|
12752
|
+
moveCursor: (row, col) => `\x1B[${row};${col}H`,
|
|
12753
|
+
moveCursorAndClear: (row, col) => `\x1B[${row};${col}H\x1B[J`,
|
|
12754
|
+
setRgbBackground: (r, g, b) => `\x1B[48;2;${r};${g};${b}m`,
|
|
12755
|
+
resetBackground: "\x1B[49m",
|
|
12756
|
+
bracketedPasteStart: "\x1B[200~",
|
|
12757
|
+
bracketedPasteEnd: "\x1B[201~"
|
|
12758
|
+
};
|
|
12759
|
+
|
|
12608
12760
|
// src/renderer.ts
|
|
12609
12761
|
import { EventEmitter as EventEmitter9 } from "events";
|
|
12610
12762
|
|
|
@@ -12698,6 +12850,42 @@ function getObjectsInViewport(viewport, objects, direction = "column", padding =
|
|
|
12698
12850
|
return visibleChildren;
|
|
12699
12851
|
}
|
|
12700
12852
|
|
|
12853
|
+
// src/lib/terminal-capability-detection.ts
|
|
12854
|
+
function isCapabilityResponse(sequence) {
|
|
12855
|
+
if (/\x1b\[\?\d+(?:;\d+)*\$y/.test(sequence)) {
|
|
12856
|
+
return true;
|
|
12857
|
+
}
|
|
12858
|
+
if (/\x1b\[1;(?!1R)\d+R/.test(sequence)) {
|
|
12859
|
+
return true;
|
|
12860
|
+
}
|
|
12861
|
+
if (/\x1bP>\|[\s\S]*?\x1b\\/.test(sequence)) {
|
|
12862
|
+
return true;
|
|
12863
|
+
}
|
|
12864
|
+
if (/\x1b_G[\s\S]*?\x1b\\/.test(sequence)) {
|
|
12865
|
+
return true;
|
|
12866
|
+
}
|
|
12867
|
+
if (/\x1b\[\?\d+(?:;\d+)?u/.test(sequence)) {
|
|
12868
|
+
return true;
|
|
12869
|
+
}
|
|
12870
|
+
if (/\x1b\[\?[0-9;]*c/.test(sequence)) {
|
|
12871
|
+
return true;
|
|
12872
|
+
}
|
|
12873
|
+
return false;
|
|
12874
|
+
}
|
|
12875
|
+
function isPixelResolutionResponse(sequence) {
|
|
12876
|
+
return /\x1b\[4;\d+;\d+t/.test(sequence);
|
|
12877
|
+
}
|
|
12878
|
+
function parsePixelResolution(sequence) {
|
|
12879
|
+
const match = sequence.match(/\x1b\[4;(\d+);(\d+)t/);
|
|
12880
|
+
if (match) {
|
|
12881
|
+
return {
|
|
12882
|
+
width: parseInt(match[2]),
|
|
12883
|
+
height: parseInt(match[1])
|
|
12884
|
+
};
|
|
12885
|
+
}
|
|
12886
|
+
return null;
|
|
12887
|
+
}
|
|
12888
|
+
|
|
12701
12889
|
// src/renderer.ts
|
|
12702
12890
|
registerEnvVar({
|
|
12703
12891
|
name: "OTUI_DUMP_CAPTURES",
|
|
@@ -12890,6 +13078,7 @@ class CliRenderer extends EventEmitter9 {
|
|
|
12890
13078
|
_console;
|
|
12891
13079
|
_resolution = null;
|
|
12892
13080
|
_keyHandler;
|
|
13081
|
+
_stdinBuffer;
|
|
12893
13082
|
animationRequest = new Map;
|
|
12894
13083
|
resizeTimeoutId = null;
|
|
12895
13084
|
resizeDebounceDelay = 100;
|
|
@@ -12929,6 +13118,8 @@ class CliRenderer extends EventEmitter9 {
|
|
|
12929
13118
|
_paletteDetector = null;
|
|
12930
13119
|
_cachedPalette = null;
|
|
12931
13120
|
_paletteDetectionPromise = null;
|
|
13121
|
+
inputHandlers = [];
|
|
13122
|
+
prependedInputHandlers = [];
|
|
12932
13123
|
handleError = ((error) => {
|
|
12933
13124
|
console.error(error);
|
|
12934
13125
|
if (this._openConsoleOnError) {
|
|
@@ -13002,6 +13193,7 @@ Captured output:
|
|
|
13002
13193
|
this.nextRenderBuffer = this.lib.getNextBuffer(this.rendererPtr);
|
|
13003
13194
|
this.currentRenderBuffer = this.lib.getCurrentBuffer(this.rendererPtr);
|
|
13004
13195
|
this.postProcessFns = config.postProcessFns || [];
|
|
13196
|
+
this.prependedInputHandlers = config.prependInputHandlers || [];
|
|
13005
13197
|
this.root = new RootRenderable(this);
|
|
13006
13198
|
if (this.memorySnapshotInterval > 0) {
|
|
13007
13199
|
this.startMemorySnapshotTimer();
|
|
@@ -13014,10 +13206,7 @@ Captured output:
|
|
|
13014
13206
|
process.on("uncaughtException", this.handleError);
|
|
13015
13207
|
process.on("unhandledRejection", this.handleError);
|
|
13016
13208
|
process.on("exit", this.exitHandler);
|
|
13017
|
-
this.
|
|
13018
|
-
this.useConsole = config.useConsole ?? true;
|
|
13019
|
-
this._openConsoleOnError = config.openConsoleOnError ?? true;
|
|
13020
|
-
this._keyHandler = new InternalKeyHandler(this.stdin, config.useKittyKeyboard ?? true);
|
|
13209
|
+
this._keyHandler = new InternalKeyHandler(config.useKittyKeyboard ?? true);
|
|
13021
13210
|
this._keyHandler.on("keypress", (event) => {
|
|
13022
13211
|
if (this.exitOnCtrlC && event.name === "c" && event.ctrl) {
|
|
13023
13212
|
process.nextTick(() => {
|
|
@@ -13026,6 +13215,10 @@ Captured output:
|
|
|
13026
13215
|
return;
|
|
13027
13216
|
}
|
|
13028
13217
|
});
|
|
13218
|
+
this._stdinBuffer = new StdinBuffer({ timeout: 5 });
|
|
13219
|
+
this._console = new TerminalConsole(this, config.consoleOptions);
|
|
13220
|
+
this.useConsole = config.useConsole ?? true;
|
|
13221
|
+
this._openConsoleOnError = config.openConsoleOnError ?? true;
|
|
13029
13222
|
global.requestAnimationFrame = (callback) => {
|
|
13030
13223
|
const id = CliRenderer.animationFrameId++;
|
|
13031
13224
|
this.animationRequest.set(id, callback);
|
|
@@ -13257,52 +13450,86 @@ Captured output:
|
|
|
13257
13450
|
if (this._terminalIsSetup)
|
|
13258
13451
|
return;
|
|
13259
13452
|
this._terminalIsSetup = true;
|
|
13260
|
-
|
|
13261
|
-
const timeout = setTimeout(() => {
|
|
13262
|
-
this.stdin.off("data", capListener);
|
|
13263
|
-
resolve4(true);
|
|
13264
|
-
}, 100);
|
|
13265
|
-
const capListener = (str) => {
|
|
13266
|
-
clearTimeout(timeout);
|
|
13267
|
-
this.lib.processCapabilityResponse(this.rendererPtr, str);
|
|
13268
|
-
this.stdin.off("data", capListener);
|
|
13269
|
-
resolve4(true);
|
|
13270
|
-
};
|
|
13271
|
-
this.stdin.on("data", capListener);
|
|
13272
|
-
this.lib.setupTerminal(this.rendererPtr, this._useAlternateScreen);
|
|
13273
|
-
});
|
|
13453
|
+
this.lib.setupTerminal(this.rendererPtr, this._useAlternateScreen);
|
|
13274
13454
|
this._capabilities = this.lib.getTerminalCapabilities(this.rendererPtr);
|
|
13455
|
+
setTimeout(() => {
|
|
13456
|
+
this.removeInputHandler(this.capabilityHandler);
|
|
13457
|
+
}, 5000);
|
|
13275
13458
|
if (this._useMouse) {
|
|
13276
13459
|
this.enableMouse();
|
|
13277
13460
|
}
|
|
13278
13461
|
this.queryPixelResolution();
|
|
13279
13462
|
}
|
|
13280
13463
|
stdinListener = ((data) => {
|
|
13281
|
-
const str = data.toString();
|
|
13282
|
-
if (this.waitingForPixelResolution && /\x1b\[4;\d+;\d+t/.test(str)) {
|
|
13283
|
-
const match = str.match(/\x1b\[4;(\d+);(\d+)t/);
|
|
13284
|
-
if (match) {
|
|
13285
|
-
const resolution = {
|
|
13286
|
-
width: parseInt(match[2]),
|
|
13287
|
-
height: parseInt(match[1])
|
|
13288
|
-
};
|
|
13289
|
-
this._resolution = resolution;
|
|
13290
|
-
this.waitingForPixelResolution = false;
|
|
13291
|
-
return;
|
|
13292
|
-
}
|
|
13293
|
-
}
|
|
13294
13464
|
if (this._useMouse && this.handleMouseData(data)) {
|
|
13295
13465
|
return;
|
|
13296
13466
|
}
|
|
13297
|
-
this.
|
|
13467
|
+
this._stdinBuffer.process(data);
|
|
13468
|
+
}).bind(this);
|
|
13469
|
+
addInputHandler(handler) {
|
|
13470
|
+
this.inputHandlers.push(handler);
|
|
13471
|
+
}
|
|
13472
|
+
prependInputHandler(handler) {
|
|
13473
|
+
this.inputHandlers.unshift(handler);
|
|
13474
|
+
}
|
|
13475
|
+
removeInputHandler(handler) {
|
|
13476
|
+
this.inputHandlers = this.inputHandlers.filter((h2) => h2 !== handler);
|
|
13477
|
+
}
|
|
13478
|
+
capabilityHandler = ((sequence) => {
|
|
13479
|
+
if (isCapabilityResponse(sequence)) {
|
|
13480
|
+
this.lib.processCapabilityResponse(this.rendererPtr, sequence);
|
|
13481
|
+
this._capabilities = this.lib.getTerminalCapabilities(this.rendererPtr);
|
|
13482
|
+
return true;
|
|
13483
|
+
}
|
|
13484
|
+
return false;
|
|
13485
|
+
}).bind(this);
|
|
13486
|
+
focusHandler = ((sequence) => {
|
|
13487
|
+
if (sequence === "\x1B[I") {
|
|
13488
|
+
this.emit("focus");
|
|
13489
|
+
return true;
|
|
13490
|
+
}
|
|
13491
|
+
if (sequence === "\x1B[O") {
|
|
13492
|
+
this.emit("blur");
|
|
13493
|
+
return true;
|
|
13494
|
+
}
|
|
13495
|
+
return false;
|
|
13298
13496
|
}).bind(this);
|
|
13299
13497
|
setupInput() {
|
|
13498
|
+
for (const handler of this.prependedInputHandlers) {
|
|
13499
|
+
this.addInputHandler(handler);
|
|
13500
|
+
}
|
|
13501
|
+
this.addInputHandler((sequence) => {
|
|
13502
|
+
if (isPixelResolutionResponse(sequence) && this.waitingForPixelResolution) {
|
|
13503
|
+
const resolution = parsePixelResolution(sequence);
|
|
13504
|
+
if (resolution) {
|
|
13505
|
+
this._resolution = resolution;
|
|
13506
|
+
this.waitingForPixelResolution = false;
|
|
13507
|
+
}
|
|
13508
|
+
return true;
|
|
13509
|
+
}
|
|
13510
|
+
return false;
|
|
13511
|
+
});
|
|
13512
|
+
this.addInputHandler(this.capabilityHandler);
|
|
13513
|
+
this.addInputHandler(this.focusHandler);
|
|
13514
|
+
this.addInputHandler((sequence) => {
|
|
13515
|
+
return this._keyHandler.processInput(sequence);
|
|
13516
|
+
});
|
|
13300
13517
|
if (this.stdin.setRawMode) {
|
|
13301
13518
|
this.stdin.setRawMode(true);
|
|
13302
13519
|
}
|
|
13303
13520
|
this.stdin.resume();
|
|
13304
13521
|
this.stdin.setEncoding("utf8");
|
|
13305
13522
|
this.stdin.on("data", this.stdinListener);
|
|
13523
|
+
this._stdinBuffer.on("data", (sequence) => {
|
|
13524
|
+
for (const handler of this.inputHandlers) {
|
|
13525
|
+
if (handler(sequence)) {
|
|
13526
|
+
return;
|
|
13527
|
+
}
|
|
13528
|
+
}
|
|
13529
|
+
});
|
|
13530
|
+
this._stdinBuffer.on("paste", (data) => {
|
|
13531
|
+
this._keyHandler.processPaste(data);
|
|
13532
|
+
});
|
|
13306
13533
|
}
|
|
13307
13534
|
handleMouseData(data) {
|
|
13308
13535
|
const mouseEvent = this.mouseParser.parseMouseEvent(data);
|
|
@@ -13628,6 +13855,7 @@ Captured output:
|
|
|
13628
13855
|
this._suspendedMouseEnabled = this._useMouse;
|
|
13629
13856
|
this.disableMouse();
|
|
13630
13857
|
this._keyHandler.suspend();
|
|
13858
|
+
this._stdinBuffer.clear();
|
|
13631
13859
|
if (this.stdin.setRawMode) {
|
|
13632
13860
|
this.stdin.setRawMode(false);
|
|
13633
13861
|
}
|
|
@@ -13697,7 +13925,7 @@ Captured output:
|
|
|
13697
13925
|
} catch (e) {
|
|
13698
13926
|
console.error("Error destroying root renderable:", e instanceof Error ? e.stack : String(e));
|
|
13699
13927
|
}
|
|
13700
|
-
this.
|
|
13928
|
+
this._stdinBuffer.destroy();
|
|
13701
13929
|
this._console.deactivate();
|
|
13702
13930
|
this.disableStdoutInterception();
|
|
13703
13931
|
if (this._splitHeight > 0) {
|
|
@@ -13970,7 +14198,7 @@ Captured output:
|
|
|
13970
14198
|
}
|
|
13971
14199
|
}
|
|
13972
14200
|
|
|
13973
|
-
export { __toESM, __commonJS, __export, __require, Edge, Gutter, exports_src, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, nonAlphanumericKeys, parseKeypress,
|
|
14201
|
+
export { __toESM, __commonJS, __export, __require, Edge, Gutter, exports_src, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, nonAlphanumericKeys, parseKeypress, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, DebugOverlayCorner, createTextAttributes, visualizeRenderableTree, isStyledText, StyledText, stringToStyledText, black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bold, italic, underline, strikethrough, dim, reverse, blink, fg, bg, t, hastToStyledText, LinearScrollAccel, MacOSScrollAccel, StdinBuffer, parseAlign, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, envRegistry, registerEnvVar, clearEnvCache, generateEnvMarkdown, generateEnvColored, env, treeSitterToTextChunks, treeSitterToStyledText, addDefaultParsers, TreeSitterClient, DataPathsManager, getDataPaths, extToFiletype, pathToFiletype, main, getTreeSitterClient, ExtmarksController, createExtmarksController, TerminalPalette, createTerminalPalette, TextBuffer, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, isValidPercentage, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, ANSI, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, RendererControlState, CliRenderer };
|
|
13974
14202
|
|
|
13975
|
-
//# debugId=
|
|
13976
|
-
//# sourceMappingURL=index-
|
|
14203
|
+
//# debugId=7BD9FAB5ED52E27064756E2164756E21
|
|
14204
|
+
//# sourceMappingURL=index-kj9k00yt.js.map
|