@xmoon76/dsh-pi-tui 0.5.5 → 0.5.6
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/README.en.md +30 -47
- package/README.md +30 -30
- package/cordis.patch.yml +77 -7
- package/dist/{bootstrap-DLOydLLj.mjs → bootstrap-DQ4YPL-7.mjs} +12416 -7243
- package/dist/builtins.mjs +3 -8
- package/dist/{application-runtime-CbBO4bY-.mjs → client-bootstrap-Cr1JCaF5.mjs} +3098 -1747
- package/dist/{dist-C7QMk0ws.mjs → dist-CIsR7cz4.mjs} +510 -224
- package/dist/{extensions-pcFiH7Qe.mjs → extensions-Bp0L37lP.mjs} +527 -249
- package/dist/extensions.mjs +1 -1
- package/dist/{host-bootstrap-CKdfLkNS.mjs → host-bootstrap-DilsvA6f.mjs} +106 -13
- package/dist/host-foundation-probe--5jtvHVe.mjs +413 -0
- package/dist/host-runtime.d.mts +10 -6
- package/dist/host-runtime.mjs +877 -10
- package/dist/index.d.mts +11 -17
- package/dist/index.mjs +13328 -6828
- package/dist/local-client.mjs +408 -61
- package/dist/{local-discovery-CXnLT4GF.mjs → local-discovery-C9VMjc0K.mjs} +10 -6
- package/dist/{local-discovery-DVFFpfBG.mjs → local-discovery-CDaQHA_R.mjs} +1 -1
- package/dist/local-host.mjs +188 -36
- package/dist/{local-transport-C9aonplC.mjs → local-transport-BVwFYq_Y.mjs} +1 -1
- package/dist/{context-summary-D9mhxPXL.mjs → pasted-path-range-CMnxuGPx.mjs} +6166 -227
- package/dist/{context-summary-Bz0AGXa1.mjs → pasted-path-range-r6qzV_tC.mjs} +5927 -444
- package/dist/{pi-tui-remote-contribution-DRk6Tl3J.mjs → pi-tui-remote-contribution-B0EQsP0N.mjs} +27 -20
- package/dist/{pi-tui-terminal-progress-contract-XTQKj-WW.mjs → pi-tui-terminal-progress-contract-MLXZ-i3t.mjs} +2 -2
- package/dist/pi-tui-web-access-contract-BN8Cc_Ho.mjs +118 -0
- package/dist/{runtime-status-0lp9CM0V.mjs → runtime-status-Cj1nFOdS.mjs} +72 -214
- package/dist/{session-4keoXjk0.mjs → session-BKGXyh80.mjs} +7487 -2562
- package/dist/{session-B2zqv4wr.mjs → session-CPt_U8_f.mjs} +7486 -2560
- package/dist/{startup-Ct2UUjUL.mjs → startup-7BYWuvBU.mjs} +121 -6
- package/dist/startup.mjs +1 -1
- package/dist/{terminal-progress-source-BhufrZ74.mjs → terminal-progress-source-DrqQhtT8.mjs} +305 -45
- package/dist/visual-tools.d.mts +2 -2
- package/dist/visual-tools.mjs +26 -31
- package/dist/web-preferences.d.mts +29 -0
- package/dist/web-preferences.mjs +15 -0
- package/dist/web-roster-CjqnUXNk.mjs +285 -0
- package/generated/dsh-presets/cordis.patch.yml +5 -3
- package/generated/dsh-presets/ptc.patch.yml +7 -7
- package/generated/dsh-presets/standard.patch.yml +6 -4
- package/package.json +182 -168
- package/dist/client-bootstrap-DwSFzcTW.mjs +0 -872
- package/dist/custom-items-CKrOBCox.mjs +0 -655
- package/dist/dispose-cause-BzcXo4hu.mjs +0 -123
- package/dist/host-foundation-probe-CYHsbAw6.mjs +0 -143
- package/dist/host-prerequisites-9JBTtVNu.mjs +0 -36
- package/dist/runtime-Bh5OsftD.mjs +0 -6798
- package/dist/runtime-C5ROZqFj.mjs +0 -2
- package/dist/terminal-progress-source-CsBinCJ_.mjs +0 -965
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { n as TUI_STARTUP_SERVICE } from "./startup-
|
|
1
|
+
import { n as TUI_STARTUP_SERVICE } from "./startup-7BYWuvBU.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import * as fs from "node:fs";
|
|
4
4
|
import { readFileSync } from "node:fs";
|
|
5
|
-
import * as path from "node:path";
|
|
6
|
-
import { dirname, isAbsolute, join } from "node:path";
|
|
7
5
|
import * as os from "node:os";
|
|
8
6
|
import { homedir } from "node:os";
|
|
7
|
+
import * as path from "node:path";
|
|
8
|
+
import { dirname, isAbsolute, join } from "node:path";
|
|
9
9
|
import { parseCommand } from "@deepseek-ai/dsh-commands";
|
|
10
10
|
import { execSync } from "node:child_process";
|
|
11
11
|
import { Marked, Tokenizer } from "marked";
|
|
@@ -16,20 +16,9 @@ import { basename as basename$1, dirname as dirname$1, join as join$1 } from "pa
|
|
|
16
16
|
import { eastAsianWidth } from "get-east-asian-width";
|
|
17
17
|
import { performance as performance$1 } from "node:perf_hooks";
|
|
18
18
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
19
|
+
import markedCjkFriendly from "marked-cjk-friendly";
|
|
19
20
|
import { EventEmitter } from "events";
|
|
20
21
|
import { Service } from "@deepseek-ai/cordis";
|
|
21
|
-
//#region \0rolldown/runtime.js
|
|
22
|
-
var __defProp = Object.defineProperty;
|
|
23
|
-
var __exportAll = (all, no_symbols) => {
|
|
24
|
-
let target = {};
|
|
25
|
-
for (var name in all) __defProp(target, name, {
|
|
26
|
-
get: all[name],
|
|
27
|
-
enumerable: true
|
|
28
|
-
});
|
|
29
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
30
|
-
return target;
|
|
31
|
-
};
|
|
32
|
-
//#endregion
|
|
33
22
|
//#region src/domain/footer/layout.ts
|
|
34
23
|
/** The per-id default `Hide in TSP` value (Owner-frozen): the three items
|
|
35
24
|
* that a capable TSP composer already carries are hidden by default; every
|
|
@@ -285,55 +274,65 @@ function resolveCommandFooterFallback(doc) {
|
|
|
285
274
|
}
|
|
286
275
|
//#endregion
|
|
287
276
|
//#region packages/pi-tui/dist/index.mjs
|
|
288
|
-
function
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
score
|
|
299
|
-
};
|
|
300
|
-
let queryIndex = 0;
|
|
301
|
-
let score = 0;
|
|
302
|
-
let lastMatchIndex = -1;
|
|
303
|
-
let consecutiveMatches = 0;
|
|
304
|
-
while (queryIndex < normalizedQuery.length) {
|
|
305
|
-
const i = textLower.indexOf(normalizedQuery[queryIndex], lastMatchIndex + 1);
|
|
306
|
-
if (i === -1) break;
|
|
307
|
-
const isWordBoundary = i === 0 || /[\s\-_./:]/.test(textLower[i - 1]);
|
|
308
|
-
if (lastMatchIndex === i - 1) {
|
|
309
|
-
consecutiveMatches++;
|
|
310
|
-
score -= consecutiveMatches * 5;
|
|
311
|
-
} else {
|
|
312
|
-
consecutiveMatches = 0;
|
|
313
|
-
if (lastMatchIndex >= 0) score += (i - lastMatchIndex - 1) * 2;
|
|
314
|
-
}
|
|
315
|
-
if (isWordBoundary) score -= 10;
|
|
316
|
-
score += i * .1;
|
|
317
|
-
lastMatchIndex = i;
|
|
318
|
-
queryIndex++;
|
|
277
|
+
function scorePositions(textLower, positions) {
|
|
278
|
+
let score = 0;
|
|
279
|
+
let lastMatchIndex = -1;
|
|
280
|
+
let consecutiveMatches = 0;
|
|
281
|
+
for (const i of positions) {
|
|
282
|
+
if (lastMatchIndex === i - 1) {
|
|
283
|
+
consecutiveMatches++;
|
|
284
|
+
score -= consecutiveMatches * 5;
|
|
285
|
+
} else {
|
|
286
|
+
consecutiveMatches = 0;
|
|
287
|
+
if (lastMatchIndex >= 0) score += (i - lastMatchIndex - 1) * 2;
|
|
319
288
|
}
|
|
320
|
-
if (
|
|
289
|
+
if (i === 0 || /[\s\-_./:]/.test(textLower[i - 1])) score -= 10;
|
|
290
|
+
score += i * .1;
|
|
291
|
+
lastMatchIndex = i;
|
|
292
|
+
}
|
|
293
|
+
return score;
|
|
294
|
+
}
|
|
295
|
+
function matchQuery(normalizedQuery, textLower) {
|
|
296
|
+
if (normalizedQuery.length === 0) return {
|
|
297
|
+
matches: true,
|
|
298
|
+
score: 0
|
|
299
|
+
};
|
|
300
|
+
if (normalizedQuery.length > textLower.length) return {
|
|
301
|
+
matches: false,
|
|
302
|
+
score: 0
|
|
303
|
+
};
|
|
304
|
+
const positions = [];
|
|
305
|
+
let lastMatchIndex = -1;
|
|
306
|
+
for (let queryIndex = 0; queryIndex < normalizedQuery.length; queryIndex++) {
|
|
307
|
+
const i = textLower.indexOf(normalizedQuery[queryIndex], lastMatchIndex + 1);
|
|
308
|
+
if (i === -1) return {
|
|
321
309
|
matches: false,
|
|
322
310
|
score: 0
|
|
323
311
|
};
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
312
|
+
positions.push(i);
|
|
313
|
+
lastMatchIndex = i;
|
|
314
|
+
}
|
|
315
|
+
let score = scorePositions(textLower, positions);
|
|
316
|
+
for (let start = textLower.indexOf(normalizedQuery); start !== -1; start = textLower.indexOf(normalizedQuery, start + 1)) {
|
|
317
|
+
for (let k = 0; k < positions.length; k++) positions[k] = start + k;
|
|
318
|
+
score = Math.min(score, scorePositions(textLower, positions));
|
|
319
|
+
}
|
|
320
|
+
if (normalizedQuery === textLower) score -= 100;
|
|
321
|
+
return {
|
|
322
|
+
matches: true,
|
|
323
|
+
score
|
|
329
324
|
};
|
|
330
|
-
|
|
325
|
+
}
|
|
326
|
+
function fuzzyMatch(query, text) {
|
|
327
|
+
const queryLower = query.toLowerCase();
|
|
328
|
+
const textLower = text.toLowerCase();
|
|
329
|
+
const primaryMatch = matchQuery(queryLower, textLower);
|
|
331
330
|
if (primaryMatch.matches) return primaryMatch;
|
|
332
331
|
const alphaNumericMatch = queryLower.match(/^(?<letters>[a-z]+)(?<digits>[0-9]+)$/);
|
|
333
332
|
const numericAlphaMatch = queryLower.match(/^(?<digits>[0-9]+)(?<letters>[a-z]+)$/);
|
|
334
333
|
const swappedQuery = alphaNumericMatch ? `${alphaNumericMatch.groups?.digits ?? ""}${alphaNumericMatch.groups?.letters ?? ""}` : numericAlphaMatch ? `${numericAlphaMatch.groups?.letters ?? ""}${numericAlphaMatch.groups?.digits ?? ""}` : "";
|
|
335
334
|
if (!swappedQuery) return primaryMatch;
|
|
336
|
-
const swappedMatch = matchQuery(swappedQuery);
|
|
335
|
+
const swappedMatch = matchQuery(swappedQuery, textLower);
|
|
337
336
|
if (!swappedMatch.matches) return primaryMatch;
|
|
338
337
|
return {
|
|
339
338
|
matches: true,
|
|
@@ -580,6 +579,44 @@ function stripTerminalSequences(str) {
|
|
|
580
579
|
}
|
|
581
580
|
return result;
|
|
582
581
|
}
|
|
582
|
+
function extractAnsiCodes(str) {
|
|
583
|
+
let result = "";
|
|
584
|
+
let i = str.indexOf("\x1B");
|
|
585
|
+
while (i !== -1) {
|
|
586
|
+
const length = ansiCodeLength(str, i);
|
|
587
|
+
if (length > 0) {
|
|
588
|
+
result += str.substring(i, i + length);
|
|
589
|
+
i += length;
|
|
590
|
+
} else i++;
|
|
591
|
+
i = str.indexOf("\x1B", i);
|
|
592
|
+
}
|
|
593
|
+
return result;
|
|
594
|
+
}
|
|
595
|
+
const WHITESPACE_REGEX = /\s/;
|
|
596
|
+
/**
|
|
597
|
+
* Whether a token's visible text is only whitespace. Codes closing a styled word attach to the following space,
|
|
598
|
+
* e.g. "\x1b[22m ", so they are skipped. Stops at the first visible non-whitespace text without allocating a
|
|
599
|
+
* stripped copy, because styled words reach this check on every wrap.
|
|
600
|
+
*/
|
|
601
|
+
function isWhitespaceToken(token) {
|
|
602
|
+
let i = 0;
|
|
603
|
+
while (i < token.length) {
|
|
604
|
+
const code = token.charCodeAt(i);
|
|
605
|
+
if (code === 27) {
|
|
606
|
+
const length = ansiCodeLength(token, i);
|
|
607
|
+
if (length === 0) return false;
|
|
608
|
+
i += length;
|
|
609
|
+
} else if (code === 32 || code >= 9 && code <= 13) i++;
|
|
610
|
+
else if (code < 128 || !WHITESPACE_REGEX.test(token[i])) return false;
|
|
611
|
+
else i++;
|
|
612
|
+
}
|
|
613
|
+
return true;
|
|
614
|
+
}
|
|
615
|
+
const CONTROL_CHARACTERS = /[\u0000-\u001f\u007f-\u009f]+/g;
|
|
616
|
+
/** Replace each run of C0 and C1 control characters (ESC, BEL, newlines, ...) with one space. */
|
|
617
|
+
function replaceControlCharacters(str) {
|
|
618
|
+
return str.replace(CONTROL_CHARACTERS, " ");
|
|
619
|
+
}
|
|
583
620
|
/** Return the terminal-cell range occupied by the grapheme at a visible column. */
|
|
584
621
|
function getGraphemeCellRange(line, column) {
|
|
585
622
|
let currentCol = 0;
|
|
@@ -1062,9 +1099,10 @@ function wrapSingleLine(line, width) {
|
|
|
1062
1099
|
let currentVisibleLength = 0;
|
|
1063
1100
|
for (const token of tokens) {
|
|
1064
1101
|
const tokenVisibleLength = visibleWidth(token);
|
|
1065
|
-
const isWhitespace = token
|
|
1102
|
+
const isWhitespace = isWhitespaceToken(token);
|
|
1066
1103
|
if (tokenVisibleLength > width && !isWhitespace) {
|
|
1067
1104
|
if (currentLine) {
|
|
1105
|
+
currentLine = currentLine.trimEnd();
|
|
1068
1106
|
const lineEndReset = tracker.getLineEndReset();
|
|
1069
1107
|
if (lineEndReset) currentLine += lineEndReset;
|
|
1070
1108
|
wrapped.push(currentLine);
|
|
@@ -1077,19 +1115,25 @@ function wrapSingleLine(line, width) {
|
|
|
1077
1115
|
currentVisibleLength = visibleWidth(currentLine);
|
|
1078
1116
|
continue;
|
|
1079
1117
|
}
|
|
1080
|
-
|
|
1118
|
+
const totalNeeded = currentVisibleLength + tokenVisibleLength;
|
|
1119
|
+
if (totalNeeded > width && currentVisibleLength > 0) {
|
|
1081
1120
|
let lineToWrap = currentLine.trimEnd();
|
|
1121
|
+
if (isWhitespace) {
|
|
1122
|
+
lineToWrap += extractAnsiCodes(token);
|
|
1123
|
+
updateTrackerFromText(token, tracker);
|
|
1124
|
+
}
|
|
1082
1125
|
const lineEndReset = tracker.getLineEndReset();
|
|
1083
1126
|
if (lineEndReset) lineToWrap += lineEndReset;
|
|
1084
1127
|
wrapped.push(lineToWrap);
|
|
1085
1128
|
if (isWhitespace) {
|
|
1086
1129
|
currentLine = tracker.getActiveCodes();
|
|
1087
1130
|
currentVisibleLength = 0;
|
|
1088
|
-
|
|
1089
|
-
currentLine = tracker.getActiveCodes() + token;
|
|
1090
|
-
currentVisibleLength = tokenVisibleLength;
|
|
1131
|
+
continue;
|
|
1091
1132
|
}
|
|
1092
|
-
|
|
1133
|
+
currentLine = tracker.getActiveCodes() + token;
|
|
1134
|
+
currentVisibleLength = tokenVisibleLength;
|
|
1135
|
+
} else if (isWhitespace && totalNeeded > width && token.includes("\x1B")) currentLine += extractAnsiCodes(token);
|
|
1136
|
+
else {
|
|
1093
1137
|
currentLine += token;
|
|
1094
1138
|
currentVisibleLength += tokenVisibleLength;
|
|
1095
1139
|
}
|
|
@@ -1352,7 +1396,7 @@ function extractSegments(line, beforeEnd, afterStart, afterLen, strictAfter = fa
|
|
|
1352
1396
|
if (ansi) {
|
|
1353
1397
|
pooledStyleTracker.process(ansi.code);
|
|
1354
1398
|
if (currentCol < beforeEnd) pendingAnsiBefore += ansi.code;
|
|
1355
|
-
else if (currentCol >= afterStart && currentCol < afterEnd && afterStarted) after += ansi.code;
|
|
1399
|
+
else if (currentCol >= afterStart && currentCol < afterEnd && (afterStarted || ansi.code.startsWith("\x1B_"))) after += ansi.code;
|
|
1356
1400
|
i += ansi.length;
|
|
1357
1401
|
continue;
|
|
1358
1402
|
}
|
|
@@ -1413,14 +1457,12 @@ function escapeRegex(value) {
|
|
|
1413
1457
|
}
|
|
1414
1458
|
function buildFdPathQuery(query) {
|
|
1415
1459
|
const normalized = toDisplayPath(query);
|
|
1416
|
-
if (!normalized.includes("/")) return normalized;
|
|
1460
|
+
if (!normalized.includes("/")) return escapeRegex(normalized);
|
|
1417
1461
|
const hasTrailingSeparator = normalized.endsWith("/");
|
|
1418
1462
|
const trimmed = normalized.replace(/^\/+|\/+$/g, "");
|
|
1419
1463
|
if (!trimmed) return normalized;
|
|
1420
1464
|
const separatorPattern = "[\\\\/]";
|
|
1421
|
-
|
|
1422
|
-
if (segments.length === 0) return normalized;
|
|
1423
|
-
let pattern = segments.join(separatorPattern);
|
|
1465
|
+
let pattern = trimmed.split("/").filter(Boolean).map((segment) => escapeRegex(segment)).join(separatorPattern);
|
|
1424
1466
|
if (hasTrailingSeparator) pattern += separatorPattern;
|
|
1425
1467
|
return pattern;
|
|
1426
1468
|
}
|
|
@@ -2048,6 +2090,13 @@ const SYMBOL_KEYS = /* @__PURE__ */ new Set([
|
|
|
2048
2090
|
">",
|
|
2049
2091
|
"?"
|
|
2050
2092
|
]);
|
|
2093
|
+
const SHIFTED_SYMBOL_KEYS = /* @__PURE__ */ new Set("~!@#$%^&*()_+|{}:<>?");
|
|
2094
|
+
const MODIFIER_NAMES = [
|
|
2095
|
+
"shift",
|
|
2096
|
+
"alt",
|
|
2097
|
+
"ctrl",
|
|
2098
|
+
"super"
|
|
2099
|
+
];
|
|
2051
2100
|
const MODIFIERS = {
|
|
2052
2101
|
shift: 1,
|
|
2053
2102
|
alt: 2,
|
|
@@ -2075,8 +2124,22 @@ const FUNCTIONAL_CODEPOINTS = {
|
|
|
2075
2124
|
pageUp: -12,
|
|
2076
2125
|
pageDown: -13,
|
|
2077
2126
|
home: -14,
|
|
2078
|
-
end: -15
|
|
2127
|
+
end: -15,
|
|
2128
|
+
f1: -21,
|
|
2129
|
+
f2: -22,
|
|
2130
|
+
f3: -23,
|
|
2131
|
+
f4: -24,
|
|
2132
|
+
f5: -25,
|
|
2133
|
+
f6: -26,
|
|
2134
|
+
f7: -27,
|
|
2135
|
+
f8: -28,
|
|
2136
|
+
f9: -29,
|
|
2137
|
+
f10: -30,
|
|
2138
|
+
f11: -31,
|
|
2139
|
+
f12: -32
|
|
2079
2140
|
};
|
|
2141
|
+
const KITTY_FUNCTIONAL_PUA_START = 57344;
|
|
2142
|
+
const KITTY_FUNCTIONAL_PUA_END = 63743;
|
|
2080
2143
|
const KITTY_FUNCTIONAL_KEY_EQUIVALENTS = /* @__PURE__ */ new Map([
|
|
2081
2144
|
[57399, 48],
|
|
2082
2145
|
[57400, 49],
|
|
@@ -2113,6 +2176,15 @@ function normalizeShiftedLetterIdentityCodepoint(codepoint, modifier) {
|
|
|
2113
2176
|
if ((modifier & -193 & MODIFIERS.shift) !== 0 && codepoint >= 65 && codepoint <= 90) return codepoint + 32;
|
|
2114
2177
|
return codepoint;
|
|
2115
2178
|
}
|
|
2179
|
+
function getLogicalShiftedSymbolCandidate(codepoint, modifier, allowedSymbols) {
|
|
2180
|
+
if (codepoint === void 0 || (modifier & MODIFIERS.shift) === 0) return void 0;
|
|
2181
|
+
const normalizedCodepoint = normalizeKittyFunctionalCodepoint(codepoint);
|
|
2182
|
+
if (!allowedSymbols.has(String.fromCharCode(normalizedCodepoint))) return void 0;
|
|
2183
|
+
return {
|
|
2184
|
+
codepoint: normalizedCodepoint,
|
|
2185
|
+
modifier: modifier & ~MODIFIERS.shift
|
|
2186
|
+
};
|
|
2187
|
+
}
|
|
2116
2188
|
const LEGACY_KEY_SEQUENCES = {
|
|
2117
2189
|
up: ["\x1B[A", "\x1BOA"],
|
|
2118
2190
|
down: ["\x1B[B", "\x1BOB"],
|
|
@@ -2256,7 +2328,7 @@ const matchesLegacyModifierSequence = (data, key, modifier) => {
|
|
|
2256
2328
|
if (modifier === MODIFIERS.ctrl) return matchesLegacySequence(data, LEGACY_CTRL_SEQUENCES[key]);
|
|
2257
2329
|
return false;
|
|
2258
2330
|
};
|
|
2259
|
-
const KITTY_EVENT_SEQUENCE = /^\x1b\[\d+(?::\d*)?(?::\d+)?;\d+:(?<event>[23])(?:u|~|[
|
|
2331
|
+
const KITTY_EVENT_SEQUENCE = /^\x1b\[\d+(?::\d*)?(?::\d+)?;\d+:(?<event>[23])(?:u|~|[ABCDHFPQS])$/u;
|
|
2260
2332
|
function kittyEventType(data) {
|
|
2261
2333
|
const match = KITTY_EVENT_SEQUENCE.exec(data);
|
|
2262
2334
|
if (match === null) return void 0;
|
|
@@ -2325,7 +2397,19 @@ function parseKittySequence(data) {
|
|
|
2325
2397
|
5: FUNCTIONAL_CODEPOINTS.pageUp,
|
|
2326
2398
|
6: FUNCTIONAL_CODEPOINTS.pageDown,
|
|
2327
2399
|
7: FUNCTIONAL_CODEPOINTS.home,
|
|
2328
|
-
8: FUNCTIONAL_CODEPOINTS.end
|
|
2400
|
+
8: FUNCTIONAL_CODEPOINTS.end,
|
|
2401
|
+
11: FUNCTIONAL_CODEPOINTS.f1,
|
|
2402
|
+
12: FUNCTIONAL_CODEPOINTS.f2,
|
|
2403
|
+
13: FUNCTIONAL_CODEPOINTS.f3,
|
|
2404
|
+
14: FUNCTIONAL_CODEPOINTS.f4,
|
|
2405
|
+
15: FUNCTIONAL_CODEPOINTS.f5,
|
|
2406
|
+
17: FUNCTIONAL_CODEPOINTS.f6,
|
|
2407
|
+
18: FUNCTIONAL_CODEPOINTS.f7,
|
|
2408
|
+
19: FUNCTIONAL_CODEPOINTS.f8,
|
|
2409
|
+
20: FUNCTIONAL_CODEPOINTS.f9,
|
|
2410
|
+
21: FUNCTIONAL_CODEPOINTS.f10,
|
|
2411
|
+
23: FUNCTIONAL_CODEPOINTS.f11,
|
|
2412
|
+
24: FUNCTIONAL_CODEPOINTS.f12
|
|
2329
2413
|
}[keyNum];
|
|
2330
2414
|
if (codepoint !== void 0) return {
|
|
2331
2415
|
codepoint,
|
|
@@ -2343,14 +2427,33 @@ function parseKittySequence(data) {
|
|
|
2343
2427
|
eventType
|
|
2344
2428
|
};
|
|
2345
2429
|
}
|
|
2430
|
+
const fKeyMatch = data.match(/^\x1b\[(?:1;(\d+)(?::(\d+))?)?([PQS])$/);
|
|
2431
|
+
if (fKeyMatch) {
|
|
2432
|
+
const modValue = fKeyMatch[1] ? parseInt(fKeyMatch[1], 10) : 1;
|
|
2433
|
+
const eventType = parseEventType(fKeyMatch[2]);
|
|
2434
|
+
return {
|
|
2435
|
+
codepoint: {
|
|
2436
|
+
P: FUNCTIONAL_CODEPOINTS.f1,
|
|
2437
|
+
Q: FUNCTIONAL_CODEPOINTS.f2,
|
|
2438
|
+
S: FUNCTIONAL_CODEPOINTS.f4
|
|
2439
|
+
}[fKeyMatch[3]],
|
|
2440
|
+
modifier: modValue - 1,
|
|
2441
|
+
eventType
|
|
2442
|
+
};
|
|
2443
|
+
}
|
|
2346
2444
|
return null;
|
|
2347
2445
|
}
|
|
2348
2446
|
function matchesKittySequence(data, expectedCodepoint, expectedModifier) {
|
|
2349
2447
|
const parsed = parseKittySequence(data);
|
|
2350
2448
|
if (!parsed) return false;
|
|
2351
|
-
|
|
2449
|
+
const actualMod = parsed.modifier & -193;
|
|
2450
|
+
const expectedMod = expectedModifier & -193;
|
|
2352
2451
|
const normalizedCodepoint = normalizeShiftedLetterIdentityCodepoint(normalizeKittyFunctionalCodepoint(parsed.codepoint), parsed.modifier);
|
|
2353
|
-
|
|
2452
|
+
const normalizedExpectedCodepoint = normalizeShiftedLetterIdentityCodepoint(normalizeKittyFunctionalCodepoint(expectedCodepoint), expectedModifier);
|
|
2453
|
+
if (actualMod === expectedMod && normalizedCodepoint === normalizedExpectedCodepoint) return true;
|
|
2454
|
+
const logicalShiftedSymbol = getLogicalShiftedSymbolCandidate(parsed.shiftedKey, actualMod, SYMBOL_KEYS);
|
|
2455
|
+
if (logicalShiftedSymbol && (logicalShiftedSymbol.modifier & -193) === expectedMod && logicalShiftedSymbol.codepoint === normalizeKittyFunctionalCodepoint(expectedCodepoint)) return true;
|
|
2456
|
+
if (actualMod !== expectedMod) return false;
|
|
2354
2457
|
if (parsed.baseLayoutKey !== void 0 && parsed.baseLayoutKey === expectedCodepoint) {
|
|
2355
2458
|
const cp = normalizedCodepoint;
|
|
2356
2459
|
const isLatinLetter = cp >= 97 && cp <= 122;
|
|
@@ -2415,10 +2518,11 @@ function isDigitKey(key) {
|
|
|
2415
2518
|
return key >= "0" && key <= "9";
|
|
2416
2519
|
}
|
|
2417
2520
|
function matchesPrintableModifyOtherKeys(data, expectedKeycode, expectedModifier) {
|
|
2418
|
-
if (expectedModifier === 0) return false;
|
|
2419
2521
|
const parsed = parseModifyOtherKeysSequence(data);
|
|
2420
|
-
if (!parsed
|
|
2421
|
-
|
|
2522
|
+
if (!parsed) return false;
|
|
2523
|
+
if (parsed.modifier === expectedModifier && normalizeShiftedLetterIdentityCodepoint(parsed.codepoint, parsed.modifier) === normalizeShiftedLetterIdentityCodepoint(expectedKeycode, expectedModifier)) return true;
|
|
2524
|
+
const logicalShiftedSymbol = getLogicalShiftedSymbolCandidate(parsed.codepoint, parsed.modifier, SHIFTED_SYMBOL_KEYS);
|
|
2525
|
+
return logicalShiftedSymbol?.modifier === expectedModifier && logicalShiftedSymbol.codepoint === expectedKeycode;
|
|
2422
2526
|
}
|
|
2423
2527
|
function formatKeyNameWithModifiers(keyName, modifier) {
|
|
2424
2528
|
const mods = [];
|
|
@@ -2431,15 +2535,22 @@ function formatKeyNameWithModifiers(keyName, modifier) {
|
|
|
2431
2535
|
return mods.length > 0 ? `${mods.join("+")}+${keyName}` : keyName;
|
|
2432
2536
|
}
|
|
2433
2537
|
function parseKeyId(keyId) {
|
|
2434
|
-
|
|
2435
|
-
const
|
|
2436
|
-
|
|
2538
|
+
let key = keyId.toLowerCase();
|
|
2539
|
+
const modifiers = /* @__PURE__ */ new Set();
|
|
2540
|
+
while (true) {
|
|
2541
|
+
const modifier = MODIFIER_NAMES.find((name) => key.startsWith(`${name}+`));
|
|
2542
|
+
if (!modifier) break;
|
|
2543
|
+
if (modifiers.has(modifier)) return null;
|
|
2544
|
+
modifiers.add(modifier);
|
|
2545
|
+
key = key.slice(modifier.length + 1);
|
|
2546
|
+
}
|
|
2547
|
+
if (!key || key.includes("+") && key !== "+") return null;
|
|
2437
2548
|
return {
|
|
2438
2549
|
key,
|
|
2439
|
-
ctrl:
|
|
2440
|
-
shift:
|
|
2441
|
-
alt:
|
|
2442
|
-
super:
|
|
2550
|
+
ctrl: modifiers.has("ctrl"),
|
|
2551
|
+
shift: modifiers.has("shift"),
|
|
2552
|
+
alt: modifiers.has("alt"),
|
|
2553
|
+
super: modifiers.has("super")
|
|
2443
2554
|
};
|
|
2444
2555
|
}
|
|
2445
2556
|
/**
|
|
@@ -2571,9 +2682,11 @@ function matchesKey(data, keyId) {
|
|
|
2571
2682
|
case "f9":
|
|
2572
2683
|
case "f10":
|
|
2573
2684
|
case "f11":
|
|
2574
|
-
case "f12":
|
|
2575
|
-
|
|
2576
|
-
|
|
2685
|
+
case "f12": {
|
|
2686
|
+
const functionKey = key;
|
|
2687
|
+
if (modifier === 0 && matchesLegacySequence(data, LEGACY_KEY_SEQUENCES[functionKey])) return true;
|
|
2688
|
+
return matchesKittySequence(data, FUNCTIONAL_CODEPOINTS[functionKey], modifier);
|
|
2689
|
+
}
|
|
2577
2690
|
}
|
|
2578
2691
|
if (key.length === 1 && (key >= "a" && key <= "z" || isDigitKey(key) || SYMBOL_KEYS.has(key))) {
|
|
2579
2692
|
const codepoint = key.charCodeAt(0);
|
|
@@ -2596,7 +2709,7 @@ function matchesKey(data, keyId) {
|
|
|
2596
2709
|
return matchesKittySequence(data, codepoint, MODIFIERS.shift) || matchesPrintableModifyOtherKeys(data, codepoint, MODIFIERS.shift);
|
|
2597
2710
|
}
|
|
2598
2711
|
if (modifier !== 0) return matchesKittySequence(data, codepoint, modifier) || matchesPrintableModifyOtherKeys(data, codepoint, modifier);
|
|
2599
|
-
return data === key || matchesKittySequence(data, codepoint, 0);
|
|
2712
|
+
return data === key || matchesKittySequence(data, codepoint, 0) || matchesPrintableModifyOtherKeys(data, codepoint, 0);
|
|
2600
2713
|
}
|
|
2601
2714
|
return false;
|
|
2602
2715
|
}
|
|
@@ -2624,6 +2737,7 @@ function formatParsedKey(codepoint, modifier, baseLayoutKey) {
|
|
|
2624
2737
|
else if (effectiveCodepoint === FUNCTIONAL_CODEPOINTS.end) keyName = "end";
|
|
2625
2738
|
else if (effectiveCodepoint === FUNCTIONAL_CODEPOINTS.pageUp) keyName = "pageUp";
|
|
2626
2739
|
else if (effectiveCodepoint === FUNCTIONAL_CODEPOINTS.pageDown) keyName = "pageDown";
|
|
2740
|
+
else if (effectiveCodepoint <= FUNCTIONAL_CODEPOINTS.f1 && effectiveCodepoint >= FUNCTIONAL_CODEPOINTS.f12) keyName = `f${FUNCTIONAL_CODEPOINTS.f1 - effectiveCodepoint + 1}`;
|
|
2627
2741
|
else if (effectiveCodepoint === ARROW_CODEPOINTS.up) keyName = "up";
|
|
2628
2742
|
else if (effectiveCodepoint === ARROW_CODEPOINTS.down) keyName = "down";
|
|
2629
2743
|
else if (effectiveCodepoint === ARROW_CODEPOINTS.left) keyName = "left";
|
|
@@ -2636,9 +2750,15 @@ function formatParsedKey(codepoint, modifier, baseLayoutKey) {
|
|
|
2636
2750
|
}
|
|
2637
2751
|
function parseKey(data) {
|
|
2638
2752
|
const kitty = parseKittySequence(data);
|
|
2639
|
-
if (kitty)
|
|
2753
|
+
if (kitty) {
|
|
2754
|
+
const logicalShiftedSymbol = getLogicalShiftedSymbolCandidate(kitty.shiftedKey, kitty.modifier, SYMBOL_KEYS);
|
|
2755
|
+
return formatParsedKey(logicalShiftedSymbol?.codepoint ?? kitty.codepoint, logicalShiftedSymbol?.modifier ?? kitty.modifier, kitty.baseLayoutKey);
|
|
2756
|
+
}
|
|
2640
2757
|
const modifyOtherKeys = parseModifyOtherKeysSequence(data);
|
|
2641
|
-
if (modifyOtherKeys)
|
|
2758
|
+
if (modifyOtherKeys) {
|
|
2759
|
+
const logicalShiftedSymbol = getLogicalShiftedSymbolCandidate(modifyOtherKeys.codepoint, modifyOtherKeys.modifier, SHIFTED_SYMBOL_KEYS);
|
|
2760
|
+
return formatParsedKey(logicalShiftedSymbol?.codepoint ?? modifyOtherKeys.codepoint, logicalShiftedSymbol?.modifier ?? modifyOtherKeys.modifier);
|
|
2761
|
+
}
|
|
2642
2762
|
if (_kittyProtocolActive) {
|
|
2643
2763
|
if (data === "\x1B\r" || data === "\n") return "shift+enter";
|
|
2644
2764
|
}
|
|
@@ -2715,6 +2835,7 @@ function decodeKittyPrintable(data) {
|
|
|
2715
2835
|
if (modifier & MODIFIERS.shift && typeof shiftedKey === "number") effectiveCodepoint = shiftedKey;
|
|
2716
2836
|
effectiveCodepoint = normalizeKittyFunctionalCodepoint(effectiveCodepoint);
|
|
2717
2837
|
if (!Number.isFinite(effectiveCodepoint) || effectiveCodepoint < 32) return void 0;
|
|
2838
|
+
if (effectiveCodepoint >= KITTY_FUNCTIONAL_PUA_START && effectiveCodepoint <= KITTY_FUNCTIONAL_PUA_END) return;
|
|
2718
2839
|
try {
|
|
2719
2840
|
return String.fromCodePoint(effectiveCodepoint);
|
|
2720
2841
|
} catch {
|
|
@@ -2846,10 +2967,20 @@ function detectCapabilitiesFromEnvironment(tmuxForwardsHyperlink) {
|
|
|
2846
2967
|
hyperlinks: false
|
|
2847
2968
|
};
|
|
2848
2969
|
if (termProgram === "herdr") return {
|
|
2849
|
-
images:
|
|
2970
|
+
images: "kitty",
|
|
2850
2971
|
trueColor: hasTrueColorHint,
|
|
2851
2972
|
hyperlinks: true
|
|
2852
2973
|
};
|
|
2974
|
+
if (termProgram === "rex") return {
|
|
2975
|
+
images: "kitty",
|
|
2976
|
+
trueColor: true,
|
|
2977
|
+
hyperlinks: true
|
|
2978
|
+
};
|
|
2979
|
+
if (termProgram === "orca" && process.env.ORCA_IMAGE_PROTOCOL === "kitty") return {
|
|
2980
|
+
images: "kitty",
|
|
2981
|
+
trueColor: true,
|
|
2982
|
+
hyperlinks: true
|
|
2983
|
+
};
|
|
2853
2984
|
if (process.env.KITTY_WINDOW_ID || termProgram === "kitty" || termProgram === "tern") return {
|
|
2854
2985
|
images: "kitty",
|
|
2855
2986
|
trueColor: true,
|
|
@@ -3094,8 +3225,10 @@ function encodeITerm2(base64Data, options = {}) {
|
|
|
3094
3225
|
}
|
|
3095
3226
|
const kittyImageMetadata = /* @__PURE__ */ new Map();
|
|
3096
3227
|
let kittyTransmissionGeneration = 0;
|
|
3228
|
+
let maxKittyImageRows = 0;
|
|
3097
3229
|
function registerKittyImageMetadata(metadata) {
|
|
3098
3230
|
kittyTransmissionGeneration += 1;
|
|
3231
|
+
maxKittyImageRows = Math.max(maxKittyImageRows, metadata.rows);
|
|
3099
3232
|
kittyImageMetadata.delete(metadata.imageId);
|
|
3100
3233
|
kittyImageMetadata.set(metadata.imageId, {
|
|
3101
3234
|
...metadata,
|
|
@@ -3106,6 +3239,10 @@ function registerKittyImageMetadata(metadata) {
|
|
|
3106
3239
|
if (oldestImageId !== void 0) kittyImageMetadata.delete(oldestImageId);
|
|
3107
3240
|
}
|
|
3108
3241
|
}
|
|
3242
|
+
/** Return the row height of the tallest Kitty image registered so far. */
|
|
3243
|
+
function getMaxKittyImageRows() {
|
|
3244
|
+
return maxKittyImageRows;
|
|
3245
|
+
}
|
|
3109
3246
|
function getRegisteredKittyImageMetadataFromControls(controls) {
|
|
3110
3247
|
const imageId = /(?:^|,)i=(\d+)(?:,|$)/.exec(controls)?.[1];
|
|
3111
3248
|
return imageId === void 0 ? void 0 : kittyImageMetadata.get(Number.parseInt(imageId, 10));
|
|
@@ -3522,6 +3659,14 @@ function isFocusable(component) {
|
|
|
3522
3659
|
* TUI finds and strips this marker, then positions the hardware cursor there.
|
|
3523
3660
|
*/
|
|
3524
3661
|
const CURSOR_MARKER = "\x1B_pi:c\x07";
|
|
3662
|
+
/** Fake cursor markers - zero-width APC sequences around the text drawn as the cursor. See resolveFakeCursors(). */
|
|
3663
|
+
const FAKE_CURSOR_START = "\x1B_pi:fc\x07";
|
|
3664
|
+
const FAKE_CURSOR_END = "\x1B_pi:/fc\x07";
|
|
3665
|
+
const FOCUSED_FAKE_CURSOR = /(\x1b_pi:c\x07)\x1b_pi:fc\x07(.*?)(?:\x1b_pi:\/fc\x07|$)/s;
|
|
3666
|
+
/** Wrap text in fake cursor markers. */
|
|
3667
|
+
function renderFakeCursor(text) {
|
|
3668
|
+
return `${FAKE_CURSOR_START}${text}${FAKE_CURSOR_END}`;
|
|
3669
|
+
}
|
|
3525
3670
|
/** Parse a SizeValue into absolute value given a reference size */
|
|
3526
3671
|
function parseSizeValue(value, referenceSize) {
|
|
3527
3672
|
if (value === void 0) return void 0;
|
|
@@ -3901,6 +4046,24 @@ var TuiBase = class TuiBase extends Container {
|
|
|
3901
4046
|
afterTerminalStart() {}
|
|
3902
4047
|
beforeTerminalStop(_options) {}
|
|
3903
4048
|
afterTerminalStop(_options) {}
|
|
4049
|
+
/** Mode resets written before the terminal's own resets when the process exits without stop(). */
|
|
4050
|
+
getExitRestorePrefix() {
|
|
4051
|
+
return `${this.terminalColorSchemeNotificationsEnabled ? "\x1B[?2031l" : ""}\x1b[?25h`;
|
|
4052
|
+
}
|
|
4053
|
+
/** Mode resets written after the terminal's own resets when the process exits without stop(). */
|
|
4054
|
+
getExitRestoreSuffix() {
|
|
4055
|
+
return "";
|
|
4056
|
+
}
|
|
4057
|
+
/**
|
|
4058
|
+
* Last-resort restore for exit paths that skip stop(), e.g. a direct process.exit() (#11170).
|
|
4059
|
+
* Hard kills and native aborts run no JavaScript and cannot be covered.
|
|
4060
|
+
*/
|
|
4061
|
+
exitRestoreHandler = () => {
|
|
4062
|
+
if (this.stopped) return;
|
|
4063
|
+
try {
|
|
4064
|
+
this.terminal.restoreOnExit?.(this.getExitRestorePrefix(), this.getExitRestoreSuffix());
|
|
4065
|
+
} catch {}
|
|
4066
|
+
};
|
|
3904
4067
|
get fullRedraws() {
|
|
3905
4068
|
return this.fullRedrawCount;
|
|
3906
4069
|
}
|
|
@@ -4240,6 +4403,8 @@ var TuiBase = class TuiBase extends Container {
|
|
|
4240
4403
|
}
|
|
4241
4404
|
start() {
|
|
4242
4405
|
this.stopped = false;
|
|
4406
|
+
process.off("exit", this.exitRestoreHandler);
|
|
4407
|
+
process.on("exit", this.exitRestoreHandler);
|
|
4243
4408
|
this.beforeTerminalStart();
|
|
4244
4409
|
this.terminal.start((data) => this.handleTerminalInput(data), () => this.requestRender());
|
|
4245
4410
|
this.terminalStarted = true;
|
|
@@ -4275,6 +4440,7 @@ var TuiBase = class TuiBase extends Container {
|
|
|
4275
4440
|
}
|
|
4276
4441
|
stop(options = {}) {
|
|
4277
4442
|
this.stopped = true;
|
|
4443
|
+
process.off("exit", this.exitRestoreHandler);
|
|
4278
4444
|
this.terminalStarted = false;
|
|
4279
4445
|
this.cancelRenderTimer();
|
|
4280
4446
|
this.settleBackgroundProbe(void 0);
|
|
@@ -4570,7 +4736,7 @@ var TuiBase = class TuiBase extends Container {
|
|
|
4570
4736
|
for (const entry of visibleEntries) {
|
|
4571
4737
|
const { component, options } = entry;
|
|
4572
4738
|
const { width, maxHeight } = this.resolveOverlayLayout(options, 0, termWidth, termHeight);
|
|
4573
|
-
let overlayLines = component.render(width);
|
|
4739
|
+
let overlayLines = this.resolveFakeCursors(component.render(width));
|
|
4574
4740
|
if (maxHeight !== void 0 && overlayLines.length > maxHeight) overlayLines = overlayLines.slice(0, maxHeight);
|
|
4575
4741
|
const { row, col } = this.resolveOverlayLayout(options, overlayLines.length, termWidth, termHeight);
|
|
4576
4742
|
entry.bounds = {
|
|
@@ -4667,6 +4833,17 @@ var TuiBase = class TuiBase extends Container {
|
|
|
4667
4833
|
return null;
|
|
4668
4834
|
}
|
|
4669
4835
|
/**
|
|
4836
|
+
* Resolve fake cursor markers to reverse video. When the hardware cursor is shown, a fake cursor
|
|
4837
|
+
* directly after CURSOR_MARKER is dropped because the terminal cursor is drawn there. Fake cursors
|
|
4838
|
+
* of components without focus have no CURSOR_MARKER and stay visible.
|
|
4839
|
+
*/
|
|
4840
|
+
resolveFakeCursors(lines) {
|
|
4841
|
+
return lines.map((line) => {
|
|
4842
|
+
if (!line.includes("\x1B_pi:fc\x07")) return line;
|
|
4843
|
+
return (this.showHardwareCursor ? line.replace(FOCUSED_FAKE_CURSOR, "$1$2") : line).replaceAll(FAKE_CURSOR_START, "\x1B[7m").replaceAll(FAKE_CURSOR_END, "\x1B[27m");
|
|
4844
|
+
});
|
|
4845
|
+
}
|
|
4846
|
+
/**
|
|
4670
4847
|
* Query the terminal's theme colors: the default foreground (OSC 10), the default background
|
|
4671
4848
|
* (OSC 11), and ANSI colors 0-15 (OSC 4), followed by a DA1 request that marks the end of the
|
|
4672
4849
|
* replies. Resolves when the DA1 reply or all color replies arrive, or when the timeout expires.
|
|
@@ -5024,6 +5201,18 @@ function getKeybindings() {
|
|
|
5024
5201
|
return globalKeybindings;
|
|
5025
5202
|
}
|
|
5026
5203
|
/**
|
|
5204
|
+
* Returns the selection index after a `tui.select.pageUp` or `tui.select.pageDown` key, moved by `pageSize` and
|
|
5205
|
+
* clamped to `0..itemCount - 1`. Returns undefined when `data` is not a selection page key, and 0 for a page key on
|
|
5206
|
+
* an empty list, so callers must still check that the list has items before selecting.
|
|
5207
|
+
*/
|
|
5208
|
+
function getSelectPageIndex(keybindings, data, selectedIndex, itemCount, pageSize) {
|
|
5209
|
+
let direction;
|
|
5210
|
+
if (keybindings.matches(data, "tui.select.pageUp")) direction = -1;
|
|
5211
|
+
else if (keybindings.matches(data, "tui.select.pageDown")) direction = 1;
|
|
5212
|
+
else return void 0;
|
|
5213
|
+
return Math.max(0, Math.min(itemCount - 1, selectedIndex + direction * pageSize));
|
|
5214
|
+
}
|
|
5215
|
+
/**
|
|
5027
5216
|
* Text component - displays multi-line text with word wrapping
|
|
5028
5217
|
*/
|
|
5029
5218
|
var Text = class {
|
|
@@ -5041,6 +5230,7 @@ var Text = class {
|
|
|
5041
5230
|
this.customBgFn = customBgFn;
|
|
5042
5231
|
}
|
|
5043
5232
|
setText(text) {
|
|
5233
|
+
if (text === this.text) return;
|
|
5044
5234
|
this.text = text;
|
|
5045
5235
|
this.cachedText = void 0;
|
|
5046
5236
|
this.cachedWidth = void 0;
|
|
@@ -5245,6 +5435,7 @@ const MIN_DESCRIPTION_WIDTH = 10;
|
|
|
5245
5435
|
const normalizeToSingleLine = (text) => text.replace(/[\r\n]+/g, " ").trim();
|
|
5246
5436
|
const clamp = (value, min, max) => Math.max(min, Math.min(value, max));
|
|
5247
5437
|
var SelectList = class {
|
|
5438
|
+
capturesViewportInput = true;
|
|
5248
5439
|
items = [];
|
|
5249
5440
|
filteredItems = [];
|
|
5250
5441
|
selectedIndex = 0;
|
|
@@ -5345,12 +5536,17 @@ var SelectList = class {
|
|
|
5345
5536
|
}
|
|
5346
5537
|
handleInput(keyData) {
|
|
5347
5538
|
const kb = getKeybindings();
|
|
5539
|
+
const pageIndex = getSelectPageIndex(kb, keyData, this.selectedIndex, this.filteredItems.length, this.maxVisible);
|
|
5348
5540
|
if (kb.matches(keyData, "tui.select.up")) {
|
|
5349
5541
|
this.selectedIndex = this.selectedIndex === 0 ? this.filteredItems.length - 1 : this.selectedIndex - 1;
|
|
5350
5542
|
this.notifySelectionChange();
|
|
5351
5543
|
} else if (kb.matches(keyData, "tui.select.down")) {
|
|
5352
5544
|
this.selectedIndex = this.selectedIndex === this.filteredItems.length - 1 ? 0 : this.selectedIndex + 1;
|
|
5353
5545
|
this.notifySelectionChange();
|
|
5546
|
+
} else if (pageIndex !== void 0) {
|
|
5547
|
+
if (this.filteredItems.length === 0 || pageIndex === this.selectedIndex) return;
|
|
5548
|
+
this.selectedIndex = pageIndex;
|
|
5549
|
+
this.notifySelectionChange();
|
|
5354
5550
|
} else if (kb.matches(keyData, "tui.select.confirm")) {
|
|
5355
5551
|
const selectedItem = this.filteredItems[this.selectedIndex];
|
|
5356
5552
|
if (selectedItem && this.onSelect) this.onSelect(selectedItem);
|
|
@@ -5633,6 +5829,10 @@ var Editor = class Editor {
|
|
|
5633
5829
|
};
|
|
5634
5830
|
/** Focusable interface - set by TUI when focus changes */
|
|
5635
5831
|
focused = false;
|
|
5832
|
+
/** The open autocomplete menu receives fullscreen viewport keys, such as PageUp/PageDown. */
|
|
5833
|
+
get capturesViewportInput() {
|
|
5834
|
+
return this.autocompleteState !== null;
|
|
5835
|
+
}
|
|
5636
5836
|
tui;
|
|
5637
5837
|
theme;
|
|
5638
5838
|
paddingX = 0;
|
|
@@ -5703,6 +5903,15 @@ var Editor = class Editor {
|
|
|
5703
5903
|
* unchanged body never needs another scan (X064). */
|
|
5704
5904
|
pasteImagePlaceholders = /* @__PURE__ */ new Map();
|
|
5705
5905
|
onSubmit;
|
|
5906
|
+
/** Pre-clear submit ADMISSION (dsh-pi-tui divergence X075): called with
|
|
5907
|
+
* the expanded submitted value BEFORE {@link onBeforeSubmitClear} and
|
|
5908
|
+
* before any draft/undo/paste-registry mutation. Returning `false` (or
|
|
5909
|
+
* throwing) aborts THIS submit gesture as if it never started: the draft,
|
|
5910
|
+
* caret, paste registry and Undo history stay exactly as they were, and
|
|
5911
|
+
* no history row/ack/business dispatch happens. The host uses it for the
|
|
5912
|
+
* one refusal that cannot be expressed after the clear: a terminal
|
|
5913
|
+
* pasted image path whose attachment read is still in flight. */
|
|
5914
|
+
onMaySubmit;
|
|
5706
5915
|
/** Called with the submitted text immediately BEFORE the draft/undo clear.
|
|
5707
5916
|
* The host reserves submission-time resources first and returns a ONE-SHOT
|
|
5708
5917
|
* release: it runs in a finally after the synchronous clear + onSubmit
|
|
@@ -5957,10 +6166,11 @@ var Editor = class Editor {
|
|
|
5957
6166
|
if (after.length > 0) {
|
|
5958
6167
|
const firstGrapheme = [...this.segment(after, "grapheme")][0]?.segment || "";
|
|
5959
6168
|
const restAfter = after.slice(firstGrapheme.length);
|
|
5960
|
-
const cursor =
|
|
6169
|
+
const cursor = renderFakeCursor(firstGrapheme);
|
|
5961
6170
|
displayText = before + marker + cursor + restAfter;
|
|
5962
6171
|
} else {
|
|
5963
|
-
|
|
6172
|
+
const cursor = renderFakeCursor(" ");
|
|
6173
|
+
displayText = before + marker + cursor;
|
|
5964
6174
|
lineVisibleWidth = lineVisibleWidth + 1;
|
|
5965
6175
|
if (lineVisibleWidth > contentWidth && paddingX > 0) cursorInPadding = true;
|
|
5966
6176
|
}
|
|
@@ -6109,7 +6319,7 @@ var Editor = class Editor {
|
|
|
6109
6319
|
this.cancelAutocomplete();
|
|
6110
6320
|
return;
|
|
6111
6321
|
}
|
|
6112
|
-
if (kb.matches(data, "tui.select.up") || kb.matches(data, "tui.select.down")) {
|
|
6322
|
+
if (kb.matches(data, "tui.select.up") || kb.matches(data, "tui.select.down") || kb.matches(data, "tui.select.pageUp") || kb.matches(data, "tui.select.pageDown")) {
|
|
6113
6323
|
this.autocompleteList.handleInput(data);
|
|
6114
6324
|
return;
|
|
6115
6325
|
}
|
|
@@ -6646,6 +6856,7 @@ var Editor = class Editor {
|
|
|
6646
6856
|
}
|
|
6647
6857
|
submitValue() {
|
|
6648
6858
|
const result = this.expandPasteMarkersSinglePass(this.state.lines.join("\n")).text.trim();
|
|
6859
|
+
if (this.onMaySubmit?.(result) === false) return;
|
|
6649
6860
|
const release = this.onBeforeSubmitClear?.(result);
|
|
6650
6861
|
try {
|
|
6651
6862
|
this.clearDraftAfterSubmit();
|
|
@@ -8111,7 +8322,7 @@ var Input = class {
|
|
|
8111
8322
|
const placeholder = truncateToWidth(this.placeholder, availableWidth, "");
|
|
8112
8323
|
const atCursor = [...segmenter$1.segment(placeholder)][0]?.segment ?? " ";
|
|
8113
8324
|
const afterCursor = placeholder.slice(atCursor.length);
|
|
8114
|
-
const textWithCursor = (this.focused ? CURSOR_MARKER : "") +
|
|
8325
|
+
const textWithCursor = (this.focused ? CURSOR_MARKER : "") + renderFakeCursor(this.placeholderStyle(atCursor)) + this.placeholderStyle(afterCursor);
|
|
8115
8326
|
const padding = " ".repeat(Math.max(0, availableWidth - visibleWidth(textWithCursor)));
|
|
8116
8327
|
return [this.prompt + textWithCursor + padding];
|
|
8117
8328
|
}
|
|
@@ -8142,7 +8353,7 @@ var Input = class {
|
|
|
8142
8353
|
const atCursor = cursorGrapheme?.segment ?? " ";
|
|
8143
8354
|
const afterCursor = visibleText.slice(cursorDisplay + atCursor.length);
|
|
8144
8355
|
const marker = this.focused ? CURSOR_MARKER : "";
|
|
8145
|
-
const cursorChar =
|
|
8356
|
+
const cursorChar = renderFakeCursor(atCursor);
|
|
8146
8357
|
const textWithCursor = beforeCursor + marker + cursorChar + afterCursor;
|
|
8147
8358
|
const visualLength = visibleWidth(textWithCursor);
|
|
8148
8359
|
const padding = " ".repeat(Math.max(0, availableWidth - visualLength));
|
|
@@ -9417,7 +9628,13 @@ function renderLatex(source, options = {}) {
|
|
|
9417
9628
|
return lines.map((line) => line.slice(indentation).trimEnd()).join("\n").trimEnd().replaceAll(PROTECTED_SPACE, " ");
|
|
9418
9629
|
}
|
|
9419
9630
|
const STRICT_STRIKETHROUGH_REGEX = /^(~~)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/;
|
|
9420
|
-
var
|
|
9631
|
+
var MarkdownTokenizer = class extends Tokenizer {
|
|
9632
|
+
url(src) {
|
|
9633
|
+
const token = super.url(src);
|
|
9634
|
+
if (!token) return void 0;
|
|
9635
|
+
const punctuationIndex = token.raw.search(cjkPunctuationRegex);
|
|
9636
|
+
return punctuationIndex < 0 ? token : super.url(token.raw.slice(0, punctuationIndex));
|
|
9637
|
+
}
|
|
9421
9638
|
del(src) {
|
|
9422
9639
|
const match = STRICT_STRIKETHROUGH_REGEX.exec(src);
|
|
9423
9640
|
if (!match) return;
|
|
@@ -9430,73 +9647,6 @@ var StrictStrikethroughTokenizer = class extends Tokenizer {
|
|
|
9430
9647
|
};
|
|
9431
9648
|
}
|
|
9432
9649
|
};
|
|
9433
|
-
const FULLWIDTH_LEFT_PAREN = 65288;
|
|
9434
|
-
const FULLWIDTH_RIGHT_PAREN = 65289;
|
|
9435
|
-
const CJK_URL_TERMINATOR_REGEX = /[\u3000-\u303f\uff01-\uff07\uff0a-\uff0f\uff1a-\uff20\uff3b-\uff40\uff5b-\uff65\u2013\u2014\u2018\u2019\u201c\u201d\u2026]/;
|
|
9436
|
-
/**
|
|
9437
|
-
* Index at which to cut an autolink match, or -1 to keep it whole. Non-paren
|
|
9438
|
-
* CJK punctuation terminates the URL outside of full-width parens; full-width
|
|
9439
|
-
* parens only terminate it when unbalanced. Punctuation inside a balanced
|
|
9440
|
-
* parenthetical (e.g. the ,in (北京,1949年)) stays part of the URL —
|
|
9441
|
-
* prose parentheticals contain spaces and never survive marked's match this
|
|
9442
|
-
* far, so a balanced group is almost always deliberate URL content.
|
|
9443
|
-
*/
|
|
9444
|
-
function findCjkUrlBoundary(match) {
|
|
9445
|
-
let parenDepth = 0;
|
|
9446
|
-
let unmatchedOpen = -1;
|
|
9447
|
-
for (let i = 0; i < match.length; i++) {
|
|
9448
|
-
const code = match.charCodeAt(i);
|
|
9449
|
-
if (code === FULLWIDTH_LEFT_PAREN) {
|
|
9450
|
-
parenDepth++;
|
|
9451
|
-
if (unmatchedOpen === -1) unmatchedOpen = i;
|
|
9452
|
-
} else if (code === FULLWIDTH_RIGHT_PAREN) {
|
|
9453
|
-
if (parenDepth === 0) return i;
|
|
9454
|
-
parenDepth--;
|
|
9455
|
-
if (parenDepth === 0) unmatchedOpen = -1;
|
|
9456
|
-
} else if (parenDepth === 0 && CJK_URL_TERMINATOR_REGEX.test(match[i])) return i;
|
|
9457
|
-
}
|
|
9458
|
-
return parenDepth > 0 ? unmatchedOpen : -1;
|
|
9459
|
-
}
|
|
9460
|
-
var CjkBoundaryUrlTokenizer = class extends StrictStrikethroughTokenizer {
|
|
9461
|
-
url(src) {
|
|
9462
|
-
const cap = this.rules.inline.url.exec(src);
|
|
9463
|
-
if (!cap) return;
|
|
9464
|
-
if (cap[2] === "@") {
|
|
9465
|
-
const text = cap[0];
|
|
9466
|
-
return {
|
|
9467
|
-
type: "link",
|
|
9468
|
-
raw: text,
|
|
9469
|
-
text,
|
|
9470
|
-
href: `mailto:${text}`,
|
|
9471
|
-
tokens: [{
|
|
9472
|
-
type: "text",
|
|
9473
|
-
raw: text,
|
|
9474
|
-
text
|
|
9475
|
-
}]
|
|
9476
|
-
};
|
|
9477
|
-
}
|
|
9478
|
-
const boundary = findCjkUrlBoundary(cap[0]);
|
|
9479
|
-
if (boundary !== -1) cap[0] = cap[0].slice(0, boundary);
|
|
9480
|
-
if (!cap[0]) return;
|
|
9481
|
-
let previous;
|
|
9482
|
-
do {
|
|
9483
|
-
previous = cap[0];
|
|
9484
|
-
cap[0] = this.rules.inline._backpedal.exec(cap[0])?.[0] ?? "";
|
|
9485
|
-
} while (previous !== cap[0]);
|
|
9486
|
-
const text = cap[0];
|
|
9487
|
-
return {
|
|
9488
|
-
type: "link",
|
|
9489
|
-
raw: text,
|
|
9490
|
-
text,
|
|
9491
|
-
href: cap[1] === "www." ? `http://${text}` : text,
|
|
9492
|
-
tokens: [{
|
|
9493
|
-
type: "text",
|
|
9494
|
-
raw: text,
|
|
9495
|
-
text
|
|
9496
|
-
}]
|
|
9497
|
-
};
|
|
9498
|
-
}
|
|
9499
|
-
};
|
|
9500
9650
|
function isEscaped(source, index) {
|
|
9501
9651
|
let backslashes = 0;
|
|
9502
9652
|
for (let position = index - 1; position >= 0 && source[position] === "\\"; position--) backslashes++;
|
|
@@ -9546,28 +9696,37 @@ function tokenizeInlineLatex(source) {
|
|
|
9546
9696
|
text
|
|
9547
9697
|
};
|
|
9548
9698
|
}
|
|
9699
|
+
const TABLE_DELIMITER_ROW_REGEX = /^ {0,3}\|?[ \t]*:?-+:?[ \t]*(?:\|[ \t]*:?-+:?[ \t]*)*\|?[ \t]*$/;
|
|
9700
|
+
function containsTableStart(source) {
|
|
9701
|
+
const lines = source.split("\n");
|
|
9702
|
+
for (let index = 0; index < lines.length - 1; index++) {
|
|
9703
|
+
const delimiterRow = lines[index + 1];
|
|
9704
|
+
if ((delimiterRow.includes("|") || lines[index].includes("|")) && TABLE_DELIMITER_ROW_REGEX.test(delimiterRow)) return true;
|
|
9705
|
+
}
|
|
9706
|
+
return false;
|
|
9707
|
+
}
|
|
9549
9708
|
function tokenizeBlockLatex(source) {
|
|
9550
9709
|
const dollarMatch = /^ {0,3}\$\$[ \t]*(?:\n)?([\s\S]*?)\$\$[ \t]*(?:\n|$)/.exec(source);
|
|
9551
|
-
if (dollarMatch?.[1]) return {
|
|
9710
|
+
if (dollarMatch?.[1] && !containsTableStart(dollarMatch[1])) return {
|
|
9552
9711
|
type: "latexBlock",
|
|
9553
9712
|
raw: dollarMatch[0],
|
|
9554
9713
|
text: dollarMatch[1].trim()
|
|
9555
9714
|
};
|
|
9556
9715
|
const bracketMatch = /^ {0,3}\\\[[ \t]*(?:\n)?([\s\S]*?)\\\][ \t]*(?:\n|$)/.exec(source);
|
|
9557
|
-
if (bracketMatch?.[1]) return {
|
|
9716
|
+
if (bracketMatch?.[1] && !containsTableStart(bracketMatch[1])) return {
|
|
9558
9717
|
type: "latexBlock",
|
|
9559
9718
|
raw: bracketMatch[0],
|
|
9560
9719
|
text: bracketMatch[1].trim()
|
|
9561
9720
|
};
|
|
9562
9721
|
const pendingBracket = /^ {0,3}\\\[[ \t]*(?:\n)?([\s\S]*)$/.exec(source);
|
|
9563
|
-
if (pendingBracket) return {
|
|
9722
|
+
if (pendingBracket?.[1] && !containsTableStart(pendingBracket[1])) return {
|
|
9564
9723
|
type: "latexBlock",
|
|
9565
9724
|
raw: pendingBracket[0],
|
|
9566
9725
|
text: pendingBracket[1],
|
|
9567
9726
|
pending: true
|
|
9568
9727
|
};
|
|
9569
9728
|
const pendingDollar = /^ {0,3}\$\$[ \t]*(?:\n)?([\s\S]*)$/.exec(source);
|
|
9570
|
-
if (pendingDollar?.[1] && looksLikePendingDollarMath(pendingDollar[1])) return {
|
|
9729
|
+
if (pendingDollar?.[1] && looksLikePendingDollarMath(pendingDollar[1]) && !containsTableStart(pendingDollar[1])) return {
|
|
9571
9730
|
type: "latexBlock",
|
|
9572
9731
|
raw: pendingDollar[0],
|
|
9573
9732
|
text: pendingDollar[1],
|
|
@@ -9612,8 +9771,11 @@ function trimPartialClosingFences(tokens) {
|
|
|
9612
9771
|
token.text = token.text.slice(0, -lastLine.length).replace(/\n$/, "");
|
|
9613
9772
|
}
|
|
9614
9773
|
const markdownParser = new Marked();
|
|
9615
|
-
markdownParser.setOptions({ tokenizer: new
|
|
9616
|
-
markdownParser.use({
|
|
9774
|
+
markdownParser.setOptions({ tokenizer: new MarkdownTokenizer() });
|
|
9775
|
+
markdownParser.use({
|
|
9776
|
+
tokenizer: { emStrong: markedCjkFriendly().tokenizer?.emStrong },
|
|
9777
|
+
extensions: [...LATEX_MARKDOWN_EXTENSIONS]
|
|
9778
|
+
});
|
|
9617
9779
|
var Markdown = class {
|
|
9618
9780
|
text;
|
|
9619
9781
|
paddingX;
|
|
@@ -9626,6 +9788,8 @@ var Markdown = class {
|
|
|
9626
9788
|
cachedWidth;
|
|
9627
9789
|
cachedLines;
|
|
9628
9790
|
cachedTokens;
|
|
9791
|
+
blocks;
|
|
9792
|
+
blockHighlightedCode;
|
|
9629
9793
|
constructor(text, paddingX, paddingY, theme, defaultTextStyle, options) {
|
|
9630
9794
|
this.text = text;
|
|
9631
9795
|
this.paddingX = paddingX;
|
|
@@ -9636,9 +9800,14 @@ var Markdown = class {
|
|
|
9636
9800
|
}
|
|
9637
9801
|
setText(text) {
|
|
9638
9802
|
this.text = text;
|
|
9639
|
-
this.
|
|
9803
|
+
this.clearRenderCache();
|
|
9640
9804
|
}
|
|
9641
9805
|
invalidate() {
|
|
9806
|
+
this.clearRenderCache();
|
|
9807
|
+
this.blocks = void 0;
|
|
9808
|
+
this.defaultStylePrefix = void 0;
|
|
9809
|
+
}
|
|
9810
|
+
clearRenderCache() {
|
|
9642
9811
|
this.cachedText = void 0;
|
|
9643
9812
|
this.cachedWidth = void 0;
|
|
9644
9813
|
this.cachedLines = void 0;
|
|
@@ -9648,6 +9817,7 @@ var Markdown = class {
|
|
|
9648
9817
|
const contentWidth = Math.max(1, width - this.paddingX * 2);
|
|
9649
9818
|
const text = this.options.transform?.(this.text, contentWidth) ?? this.text;
|
|
9650
9819
|
if (!text || text.trim() === "") {
|
|
9820
|
+
this.blocks = void 0;
|
|
9651
9821
|
const result = [];
|
|
9652
9822
|
this.cachedText = this.text;
|
|
9653
9823
|
this.cachedWidth = width;
|
|
@@ -9665,46 +9835,65 @@ var Markdown = class {
|
|
|
9665
9835
|
tokens
|
|
9666
9836
|
});
|
|
9667
9837
|
}
|
|
9668
|
-
const
|
|
9838
|
+
const reuseBlocks = Object.keys(tokens.links).length === 0;
|
|
9839
|
+
const previousBlocks = this.blocks?.deref();
|
|
9840
|
+
const blocks = /* @__PURE__ */ new Map();
|
|
9841
|
+
this.blocks = new WeakRef(blocks);
|
|
9842
|
+
const contentLines = [];
|
|
9669
9843
|
for (let i = 0; i < tokens.length; i++) {
|
|
9670
9844
|
const token = tokens[i];
|
|
9671
|
-
const
|
|
9672
|
-
const
|
|
9673
|
-
|
|
9845
|
+
const nextTokenType = tokens[i + 1]?.type;
|
|
9846
|
+
const block = (reuseBlocks ? blocks.get(token.raw) ?? previousBlocks?.get(token.raw) : void 0) ?? {
|
|
9847
|
+
width: -1,
|
|
9848
|
+
nextTokenType,
|
|
9849
|
+
lines: [],
|
|
9850
|
+
highlightedCode: /* @__PURE__ */ new Map()
|
|
9851
|
+
};
|
|
9852
|
+
if (block.width !== width || block.nextTokenType !== nextTokenType) this.renderBlock(block, token, nextTokenType, width, contentWidth);
|
|
9853
|
+
if (reuseBlocks) blocks.set(token.raw, block);
|
|
9854
|
+
for (const line of block.lines) contentLines.push(line);
|
|
9674
9855
|
}
|
|
9675
|
-
const wrappedLines = [];
|
|
9676
|
-
for (const line of renderedLines) if (isImageLine(line)) wrappedLines.push(line);
|
|
9677
|
-
else for (const wrappedLine of wrapTextWithAnsi(line, contentWidth)) wrappedLines.push(wrappedLine);
|
|
9678
|
-
const leftMargin = " ".repeat(this.paddingX);
|
|
9679
|
-
const rightMargin = " ".repeat(this.paddingX);
|
|
9680
9856
|
const bgFn = this.defaultTextStyle?.bgColor;
|
|
9681
|
-
const contentLines = [];
|
|
9682
|
-
for (const line of wrappedLines) {
|
|
9683
|
-
if (isImageLine(line)) {
|
|
9684
|
-
contentLines.push(line);
|
|
9685
|
-
continue;
|
|
9686
|
-
}
|
|
9687
|
-
const lineWithMargins = leftMargin + line + rightMargin;
|
|
9688
|
-
if (bgFn) contentLines.push(applyBackgroundToLine(lineWithMargins, width, bgFn));
|
|
9689
|
-
else {
|
|
9690
|
-
const visibleLen = visibleWidth(lineWithMargins);
|
|
9691
|
-
const paddingNeeded = Math.max(0, width - visibleLen);
|
|
9692
|
-
contentLines.push(lineWithMargins + " ".repeat(paddingNeeded));
|
|
9693
|
-
}
|
|
9694
|
-
}
|
|
9695
9857
|
const emptyLine = " ".repeat(width);
|
|
9696
9858
|
const emptyLines = [];
|
|
9697
9859
|
for (let i = 0; i < this.paddingY; i++) {
|
|
9698
9860
|
const line = bgFn ? applyBackgroundToLine(emptyLine, width, bgFn) : emptyLine;
|
|
9699
9861
|
emptyLines.push(line);
|
|
9700
9862
|
}
|
|
9863
|
+
flattenLines(emptyLines);
|
|
9701
9864
|
const result = emptyLines.concat(contentLines, emptyLines);
|
|
9702
|
-
flattenLines(result);
|
|
9703
9865
|
this.cachedText = this.text;
|
|
9704
9866
|
this.cachedWidth = width;
|
|
9705
9867
|
this.cachedLines = result;
|
|
9706
9868
|
return result.length > 0 ? result : [""];
|
|
9707
9869
|
}
|
|
9870
|
+
/** Render one top-level block to output lines: wrapped, with margins, and padded or backgrounded to the width. */
|
|
9871
|
+
renderBlock(block, token, nextTokenType, width, contentWidth) {
|
|
9872
|
+
this.blockHighlightedCode = block.highlightedCode;
|
|
9873
|
+
const leftMargin = " ".repeat(this.paddingX);
|
|
9874
|
+
const rightMargin = " ".repeat(this.paddingX);
|
|
9875
|
+
const bgFn = this.defaultTextStyle?.bgColor;
|
|
9876
|
+
const lines = [];
|
|
9877
|
+
for (const line of this.renderToken(token, contentWidth, nextTokenType)) {
|
|
9878
|
+
if (isImageLine(line)) {
|
|
9879
|
+
lines.push(line);
|
|
9880
|
+
continue;
|
|
9881
|
+
}
|
|
9882
|
+
for (const wrappedLine of wrapTextWithAnsi(line, contentWidth)) {
|
|
9883
|
+
const lineWithMargins = leftMargin + wrappedLine + rightMargin;
|
|
9884
|
+
if (bgFn) lines.push(applyBackgroundToLine(lineWithMargins, width, bgFn));
|
|
9885
|
+
else {
|
|
9886
|
+
const paddingNeeded = Math.max(0, width - visibleWidth(lineWithMargins));
|
|
9887
|
+
lines.push(lineWithMargins + " ".repeat(paddingNeeded));
|
|
9888
|
+
}
|
|
9889
|
+
}
|
|
9890
|
+
}
|
|
9891
|
+
this.blockHighlightedCode = void 0;
|
|
9892
|
+
flattenLines(lines);
|
|
9893
|
+
block.lines = lines;
|
|
9894
|
+
block.width = width;
|
|
9895
|
+
block.nextTokenType = nextTokenType;
|
|
9896
|
+
}
|
|
9708
9897
|
/**
|
|
9709
9898
|
* Apply default text style to a string.
|
|
9710
9899
|
* This is the base styling applied to all text content.
|
|
@@ -9777,7 +9966,8 @@ var Markdown = class {
|
|
|
9777
9966
|
break;
|
|
9778
9967
|
case "latexBlock": {
|
|
9779
9968
|
const latexToken = token;
|
|
9780
|
-
|
|
9969
|
+
let rendered = !latexToken.pending && this.options.renderLatex !== false ? renderLatex(latexToken.text, { display: true }) : void 0;
|
|
9970
|
+
if (rendered === void 0 || rendered.split("\n").some((line) => visibleWidth(line) > width)) rendered = latexToken.raw.trim();
|
|
9781
9971
|
for (const line of rendered.split("\n")) lines.push(this.applyDefaultStyle(line));
|
|
9782
9972
|
if (nextTokenType && nextTokenType !== "space") lines.push("");
|
|
9783
9973
|
break;
|
|
@@ -9786,8 +9976,13 @@ var Markdown = class {
|
|
|
9786
9976
|
const indent = this.theme.codeBlockIndent ?? " ";
|
|
9787
9977
|
lines.push(this.theme.codeBlockBorder(`\`\`\`${token.lang || ""}`));
|
|
9788
9978
|
if (this.theme.highlightCode) {
|
|
9789
|
-
const
|
|
9790
|
-
|
|
9979
|
+
const key = `${token.lang ?? ""}\0${token.text}`;
|
|
9980
|
+
let highlighted = this.blockHighlightedCode?.get(key);
|
|
9981
|
+
if (!highlighted) {
|
|
9982
|
+
highlighted = this.theme.highlightCode(token.text, token.lang);
|
|
9983
|
+
this.blockHighlightedCode?.set(key, highlighted);
|
|
9984
|
+
}
|
|
9985
|
+
for (const hlLine of highlighted) lines.push(`${indent}${hlLine}`);
|
|
9791
9986
|
} else {
|
|
9792
9987
|
const codeLines = token.text.split("\n");
|
|
9793
9988
|
for (const codeLine of codeLines) lines.push(`${indent}${this.theme.codeBlock(codeLine)}`);
|
|
@@ -9814,7 +10009,12 @@ var Markdown = class {
|
|
|
9814
10009
|
const lineWithReappliedStyle = line.replace(/\x1b\[0m/g, `\x1b[0m${quoteStylePrefix}`);
|
|
9815
10010
|
return quoteStyle(lineWithReappliedStyle);
|
|
9816
10011
|
};
|
|
9817
|
-
|
|
10012
|
+
if (width < 3) {
|
|
10013
|
+
const quoteTokens = token.tokens || [];
|
|
10014
|
+
for (let i = 0; i < quoteTokens.length; i++) for (const line of this.renderToken(quoteTokens[i], width, quoteTokens[i + 1]?.type, styleContext)) lines.push(line);
|
|
10015
|
+
break;
|
|
10016
|
+
}
|
|
10017
|
+
const quoteContentWidth = width - 2;
|
|
9818
10018
|
const quoteInlineStyleContext = {
|
|
9819
10019
|
applyText: (text) => text,
|
|
9820
10020
|
stylePrefix: quoteStylePrefix
|
|
@@ -9824,7 +10024,7 @@ var Markdown = class {
|
|
|
9824
10024
|
for (let i = 0; i < quoteTokens.length; i++) {
|
|
9825
10025
|
const quoteToken = quoteTokens[i];
|
|
9826
10026
|
const nextQuoteToken = quoteTokens[i + 1];
|
|
9827
|
-
|
|
10027
|
+
for (const line of this.renderToken(quoteToken, quoteContentWidth, nextQuoteToken?.type, quoteInlineStyleContext)) renderedQuoteLines.push(line);
|
|
9828
10028
|
}
|
|
9829
10029
|
while (renderedQuoteLines.length > 0 && renderedQuoteLines[renderedQuoteLines.length - 1] === "") renderedQuoteLines.pop();
|
|
9830
10030
|
for (const quoteLine of renderedQuoteLines) {
|
|
@@ -10362,6 +10562,7 @@ function fitValueParts(parts, maxWidth) {
|
|
|
10362
10562
|
return parts.slice(0, kept).map((part) => part.text).join("");
|
|
10363
10563
|
}
|
|
10364
10564
|
var SettingsList = class {
|
|
10565
|
+
capturesViewportInput = true;
|
|
10365
10566
|
items;
|
|
10366
10567
|
filteredItems;
|
|
10367
10568
|
theme;
|
|
@@ -10665,12 +10866,16 @@ var SettingsList = class {
|
|
|
10665
10866
|
}
|
|
10666
10867
|
const kb = getKeybindings();
|
|
10667
10868
|
const displayItems = this.getDisplayItems();
|
|
10869
|
+
const pageIndex = getSelectPageIndex(kb, data, this.selectedIndex, displayItems.length, this.maxVisible);
|
|
10668
10870
|
if (kb.matches(data, "tui.select.up")) {
|
|
10669
10871
|
if (displayItems.length === 0) return;
|
|
10670
10872
|
this.selectedIndex = this.selectedIndex === 0 ? displayItems.length - 1 : this.selectedIndex - 1;
|
|
10671
10873
|
} else if (kb.matches(data, "tui.select.down")) {
|
|
10672
10874
|
if (displayItems.length === 0) return;
|
|
10673
10875
|
this.selectedIndex = this.selectedIndex === displayItems.length - 1 ? 0 : this.selectedIndex + 1;
|
|
10876
|
+
} else if (pageIndex !== void 0) {
|
|
10877
|
+
if (displayItems.length === 0) return;
|
|
10878
|
+
this.selectedIndex = pageIndex;
|
|
10674
10879
|
} else if (kb.matches(data, "tui.select.confirm") || data === " " && (!this.searchEnabled || this.searchInput?.getValue().length === 0)) this.activateItem();
|
|
10675
10880
|
else if (kb.matches(data, "tui.select.cancel")) this.onCancel();
|
|
10676
10881
|
else if (this.searchEnabled && this.searchInput) {
|
|
@@ -10811,6 +11016,12 @@ function getNativePlatformHelper() {
|
|
|
10811
11016
|
if (process.platform !== "darwin" && process.platform !== "win32") return void 0;
|
|
10812
11017
|
return loadNativePlatformHelper(process.platform);
|
|
10813
11018
|
}
|
|
11019
|
+
/**
|
|
11020
|
+
* Program Status Protocol (OSC 7501): a program tells the terminal whether it is idle, working,
|
|
11021
|
+
* blocked on the user, done, or failed. Only the root record is supported.
|
|
11022
|
+
*
|
|
11023
|
+
* Spec: https://www.superlogical.com/rex/docs/build/program-status
|
|
11024
|
+
*/
|
|
10814
11025
|
/** Feature detection query. A supporting terminal replies with the same body. */
|
|
10815
11026
|
const PROGRAM_STATUS_QUERY = "\x1B]7501;?\x1B\\";
|
|
10816
11027
|
/** The reply to {@link PROGRAM_STATUS_QUERY}. Later spec revisions may add pairs after the `?`. */
|
|
@@ -10818,7 +11029,6 @@ function isProgramStatusReply(sequence) {
|
|
|
10818
11029
|
return /^\x1b\]7501;\?[^\x07\x1b]*(?:\x07|\x1b\\)$/.test(sequence);
|
|
10819
11030
|
}
|
|
10820
11031
|
const APP_PATTERN = /^[A-Za-z0-9_.+-]{1,32}$/;
|
|
10821
|
-
const CONTROL_CHARACTERS = /[\u0000-\u001f\u007f-\u009f]+/g;
|
|
10822
11032
|
/** Decoded `msg` limit. Its base64 encoding stays under the 2732-byte encoded limit. */
|
|
10823
11033
|
const MAX_MESSAGE_BYTES = 2048;
|
|
10824
11034
|
function truncateUtf8(text, maxBytes) {
|
|
@@ -10838,7 +11048,7 @@ function formatProgramStatus(status) {
|
|
|
10838
11048
|
const pairs = [`state=${status.state}`];
|
|
10839
11049
|
if (status.app !== void 0 && APP_PATTERN.test(status.app)) pairs.push(`app=${status.app}`);
|
|
10840
11050
|
if (status.state === "blocked" && status.kind) pairs.push(`kind=${status.kind}`);
|
|
10841
|
-
const message = truncateUtf8((status.message ?? "").
|
|
11051
|
+
const message = truncateUtf8(replaceControlCharacters(status.message ?? "").trim(), MAX_MESSAGE_BYTES);
|
|
10842
11052
|
if (message) pairs.push(`msg=${Buffer.from(message, "utf8").toString("base64")}`);
|
|
10843
11053
|
return `\x1b]7501;${pairs.join(":")}\x1b\\`;
|
|
10844
11054
|
}
|
|
@@ -10865,6 +11075,10 @@ const DEFAULT_SEQUENCE_TIMEOUT_MS = 50;
|
|
|
10865
11075
|
const DEFAULT_ESCAPE_TIMEOUT_MS$1 = 10;
|
|
10866
11076
|
const BRACKETED_PASTE_START$1 = "\x1B[200~";
|
|
10867
11077
|
const BRACKETED_PASTE_END$1 = "\x1B[201~";
|
|
11078
|
+
const TERMINAL_REPLY_HEADER_PATTERN = /^\x1b(?:\](?:1[01];|4;\d{1,3};|7501;\?)|P>\||_G(?:[a-z]=\d+,)*[a-z]=\d+;)/;
|
|
11079
|
+
function isControlString(data) {
|
|
11080
|
+
return data.startsWith(`${ESC}]`) || data.startsWith(`${ESC}P`) || data.startsWith(`${ESC}_`);
|
|
11081
|
+
}
|
|
10868
11082
|
/**
|
|
10869
11083
|
* A never-terminating ESC prefix (corrupt stream, oversized paste) must not
|
|
10870
11084
|
* reslice the buffer once per byte — cap the scan and degrade the ESC to a
|
|
@@ -10956,8 +11170,20 @@ function extractCompleteSequences(buffer) {
|
|
|
10956
11170
|
while (pos < buffer.length) {
|
|
10957
11171
|
const remaining = buffer.slice(pos);
|
|
10958
11172
|
if (remaining.startsWith(ESC)) {
|
|
11173
|
+
const terminalReply = isControlString(remaining) && TERMINAL_REPLY_HEADER_PATTERN.test(remaining);
|
|
10959
11174
|
let seqEnd = 1;
|
|
10960
11175
|
while (seqEnd <= remaining.length) {
|
|
11176
|
+
if (terminalReply && seqEnd > 2) {
|
|
11177
|
+
const char = remaining[seqEnd - 1];
|
|
11178
|
+
if (char === "" || char === "") {
|
|
11179
|
+
pos += seqEnd;
|
|
11180
|
+
break;
|
|
11181
|
+
}
|
|
11182
|
+
if (char === ESC && seqEnd < remaining.length && remaining[seqEnd] !== "\\") {
|
|
11183
|
+
pos += seqEnd - 1;
|
|
11184
|
+
break;
|
|
11185
|
+
}
|
|
11186
|
+
}
|
|
10961
11187
|
const candidate = remaining.slice(0, seqEnd);
|
|
10962
11188
|
const status = isCompleteSequence(candidate);
|
|
10963
11189
|
if (status === "complete") {
|
|
@@ -11075,10 +11301,14 @@ var StdinBuffer = class extends EventEmitter {
|
|
|
11075
11301
|
this.buffer = result.remainder;
|
|
11076
11302
|
for (const sequence of result.sequences) this.emitDataSequence(sequence);
|
|
11077
11303
|
if (this.buffer.length > 0) {
|
|
11304
|
+
if (TERMINAL_REPLY_HEADER_PATTERN.test(this.buffer)) return;
|
|
11078
11305
|
const timeoutMs = this.buffer === ESC ? this.escapeTimeoutMs : this.timeoutMs;
|
|
11079
11306
|
this.timeout = setTimeout(() => {
|
|
11080
11307
|
const flushed = this.flush();
|
|
11081
|
-
for (const sequence of flushed)
|
|
11308
|
+
for (const sequence of flushed) if (sequence.length > 2 && isControlString(sequence)) {
|
|
11309
|
+
this.emitDataSequence(sequence.slice(0, 2));
|
|
11310
|
+
this.process(sequence.slice(2));
|
|
11311
|
+
} else this.emitDataSequence(sequence);
|
|
11082
11312
|
}, timeoutMs);
|
|
11083
11313
|
}
|
|
11084
11314
|
}
|
|
@@ -11178,8 +11408,11 @@ function refreshTerminalDimensions() {
|
|
|
11178
11408
|
process.kill(process.pid, "SIGWINCH");
|
|
11179
11409
|
} catch {}
|
|
11180
11410
|
}
|
|
11411
|
+
function isNativeShiftEnterCandidate(data) {
|
|
11412
|
+
return data === "\r" || data === "\x1B\r";
|
|
11413
|
+
}
|
|
11181
11414
|
function normalizeNativeShiftEnterInput(data, shouldDetectNativeShiftEnter, isShiftPressed) {
|
|
11182
|
-
if (shouldDetectNativeShiftEnter && data
|
|
11415
|
+
if (shouldDetectNativeShiftEnter && isNativeShiftEnterCandidate(data) && isShiftPressed) return NATIVE_SHIFT_ENTER_SEQUENCE;
|
|
11183
11416
|
return data;
|
|
11184
11417
|
}
|
|
11185
11418
|
const DEFAULT_ESCAPE_TIMEOUT_MS = 10;
|
|
@@ -11462,7 +11695,7 @@ var ProcessTerminal = class {
|
|
|
11462
11695
|
}
|
|
11463
11696
|
forwardInputSequence(sequence) {
|
|
11464
11697
|
if (!this.inputHandler) return;
|
|
11465
|
-
const shouldDetectNativeShiftEnter = sequence
|
|
11698
|
+
const shouldDetectNativeShiftEnter = isNativeShiftEnterCandidate(sequence) && (isAppleTerminalSession() || process.platform === "win32");
|
|
11466
11699
|
const input = normalizeNativeShiftEnterInput(sequence, shouldDetectNativeShiftEnter, shouldDetectNativeShiftEnter && isNativeModifierPressed("shift"));
|
|
11467
11700
|
this.inputHandler(input);
|
|
11468
11701
|
}
|
|
@@ -11555,6 +11788,18 @@ var ProcessTerminal = class {
|
|
|
11555
11788
|
if (process.stdin.setRawMode) process.stdin.setRawMode(this.wasRaw);
|
|
11556
11789
|
this.started = false;
|
|
11557
11790
|
}
|
|
11791
|
+
restoreOnExit(before, after) {
|
|
11792
|
+
let sequence = before;
|
|
11793
|
+
if (this.progressState !== "clear") sequence += TERMINAL_PROGRESS_CLEAR_SEQUENCE;
|
|
11794
|
+
if (this.programStatusSupported && this.programStatus) sequence += formatProgramStatus({ state: "clear" });
|
|
11795
|
+
sequence += "\x1B[?2004l";
|
|
11796
|
+
if (this.keyboardProtocolPushed || this._kittyProtocolActive) sequence += "\x1B[<u";
|
|
11797
|
+
if (this._modifyOtherKeysActive) sequence += "\x1B[>4;0m";
|
|
11798
|
+
sequence += after;
|
|
11799
|
+
try {
|
|
11800
|
+
fs.writeSync(process.stdout.fd, sequence);
|
|
11801
|
+
} catch {}
|
|
11802
|
+
}
|
|
11558
11803
|
write(data) {
|
|
11559
11804
|
process.stdout.write(data);
|
|
11560
11805
|
if (this.writeLogPath) try {
|
|
@@ -11587,7 +11832,7 @@ var ProcessTerminal = class {
|
|
|
11587
11832
|
process.stdout.write("\x1B[2J\x1B[H");
|
|
11588
11833
|
}
|
|
11589
11834
|
setTitle(title) {
|
|
11590
|
-
process.stdout.write(`\x1b]0;${title}\x07`);
|
|
11835
|
+
process.stdout.write(`\x1b]0;${replaceControlCharacters(title)}\x07`);
|
|
11591
11836
|
}
|
|
11592
11837
|
setProgramStatus(status) {
|
|
11593
11838
|
this.programStatus = status.state === "clear" ? void 0 : status;
|
|
@@ -11909,7 +12154,7 @@ var AltScreenFlashContainer = class {
|
|
|
11909
12154
|
});
|
|
11910
12155
|
}
|
|
11911
12156
|
};
|
|
11912
|
-
const OSC133_ZONE_PREFIX$
|
|
12157
|
+
const OSC133_ZONE_PREFIX$2 = /^(?:\x1b\]133;[ABC](?:\x07|\x1b\\))+/;
|
|
11913
12158
|
/** The largest number of image body rows an upward crop search may cross (X074). */
|
|
11914
12159
|
const MAX_SIXEL_CROP_SCAN_ROWS = 12;
|
|
11915
12160
|
function intersect(a, b) {
|
|
@@ -12218,7 +12463,7 @@ function paintBox(box, screen, totalWidth, context) {
|
|
|
12218
12463
|
const sourceIndex = offset + row - box.rect.y;
|
|
12219
12464
|
const sourceLine = box.lines[sourceIndex];
|
|
12220
12465
|
if (sourceLine === void 0) continue;
|
|
12221
|
-
let line = sourceLine.replace(OSC133_ZONE_PREFIX$
|
|
12466
|
+
let line = sourceLine.replace(OSC133_ZONE_PREFIX$2, "");
|
|
12222
12467
|
if (line.startsWith("\x1B_pi:tmux-image:v1:i=")) {
|
|
12223
12468
|
const marker = getManagedKittyVirtualMarker(line);
|
|
12224
12469
|
if (marker === void 0) throw new Error("managed kitty virtual marker is malformed");
|
|
@@ -12267,40 +12512,49 @@ function paintBox(box, screen, totalWidth, context) {
|
|
|
12267
12512
|
}
|
|
12268
12513
|
for (const child of box.children) paintBox(child, screen, totalWidth, context);
|
|
12269
12514
|
if (box.scrollView && box.scrollContentLines && box.scrollView.scrollTop > 0 && box.rect.height > 0) {
|
|
12270
|
-
const
|
|
12271
|
-
|
|
12515
|
+
const scrollTop = box.scrollView.scrollTop;
|
|
12516
|
+
const kittyScanFloor = Math.max(0, scrollTop - getMaxKittyImageRows());
|
|
12517
|
+
const sixelScanFloor = Math.max(0, scrollTop - MAX_SIXEL_CROP_SCAN_ROWS);
|
|
12518
|
+
let sixelSearch = true;
|
|
12519
|
+
let kittySearch = true;
|
|
12520
|
+
for (let imageRow = scrollTop - 1; imageRow >= 0; imageRow--) {
|
|
12521
|
+
if (!sixelSearch && !kittySearch) break;
|
|
12272
12522
|
const imageLine = box.scrollContentLines[imageRow] ?? "";
|
|
12273
|
-
|
|
12274
|
-
|
|
12275
|
-
|
|
12276
|
-
|
|
12277
|
-
|
|
12278
|
-
if (block.
|
|
12279
|
-
|
|
12280
|
-
|
|
12281
|
-
|
|
12282
|
-
|
|
12283
|
-
|
|
12284
|
-
|
|
12285
|
-
|
|
12286
|
-
|
|
12287
|
-
|
|
12288
|
-
|
|
12523
|
+
if (sixelSearch) {
|
|
12524
|
+
const block = sixelBlock(imageLine, sixelScreen);
|
|
12525
|
+
if (block !== void 0) {
|
|
12526
|
+
const hiddenRows = scrollTop - imageRow;
|
|
12527
|
+
const visibleRows = Math.min(box.rect.height, block.rows - hiddenRows);
|
|
12528
|
+
if (hiddenRows < block.rows && visibleRows > 0 && box.rect.x === 0 && box.rect.width >= totalWidth) {
|
|
12529
|
+
if (block.kind === "candidate") {
|
|
12530
|
+
context.sixelDemands.push({
|
|
12531
|
+
line: imageLine,
|
|
12532
|
+
cropTopRows: hiddenRows,
|
|
12533
|
+
visibleRows,
|
|
12534
|
+
physicalRow: box.rect.y
|
|
12535
|
+
});
|
|
12536
|
+
screen[box.rect.y] = sixelScreen?.materialize(imageLine, hiddenRows, visibleRows) ?? block.fallback;
|
|
12537
|
+
} else {
|
|
12538
|
+
const cropped = sixelScreen?.crop(imageLine, hiddenRows, visibleRows);
|
|
12539
|
+
if (cropped !== void 0) screen[box.rect.y] = cropped;
|
|
12540
|
+
}
|
|
12289
12541
|
}
|
|
12542
|
+
break;
|
|
12290
12543
|
}
|
|
12291
|
-
break;
|
|
12292
12544
|
}
|
|
12293
|
-
|
|
12294
|
-
|
|
12295
|
-
|
|
12296
|
-
|
|
12297
|
-
|
|
12298
|
-
|
|
12545
|
+
if (kittySearch) {
|
|
12546
|
+
const metadata = getKittyImageMetadata(imageLine);
|
|
12547
|
+
if (metadata) {
|
|
12548
|
+
const hiddenRows = scrollTop - imageRow;
|
|
12549
|
+
if (hiddenRows < metadata.rows) {
|
|
12550
|
+
const cropped = cropKittyImageLine(imageLine, hiddenRows, Math.min(box.rect.height, metadata.rows - hiddenRows));
|
|
12551
|
+
if (box.rect.x === 0 && box.rect.width >= totalWidth) screen[box.rect.y] = cropped;
|
|
12552
|
+
}
|
|
12553
|
+
break;
|
|
12299
12554
|
}
|
|
12300
|
-
break;
|
|
12301
12555
|
}
|
|
12302
|
-
if (imageLine !== "")
|
|
12303
|
-
if (
|
|
12556
|
+
if (sixelSearch && (imageLine !== "" || imageRow <= sixelScanFloor)) sixelSearch = false;
|
|
12557
|
+
if (kittySearch && imageRow <= kittyScanFloor) kittySearch = false;
|
|
12304
12558
|
}
|
|
12305
12559
|
}
|
|
12306
12560
|
paintScrollbar(box, screen, totalWidth, sixelScreen);
|
|
@@ -12452,7 +12706,7 @@ const FOCUS_IN = "\x1B[I";
|
|
|
12452
12706
|
const FOCUS_OUT = "\x1B[O";
|
|
12453
12707
|
const BEGIN_SYNCHRONIZED_OUTPUT = "\x1B[?2026h";
|
|
12454
12708
|
const END_SYNCHRONIZED_OUTPUT = "\x1B[?2026l";
|
|
12455
|
-
const OSC133_ZONE_PREFIX = /^(?:\x1b\]133;[ABC](?:\x07|\x1b\\))+/;
|
|
12709
|
+
const OSC133_ZONE_PREFIX$1 = /^(?:\x1b\]133;[ABC](?:\x07|\x1b\\))+/;
|
|
12456
12710
|
const OSC133_PROMPT_START = /^\x1b\]133;A(?:\x07|\x1b\\)/;
|
|
12457
12711
|
const PAGE_SCROLL_OVERLAP = 4;
|
|
12458
12712
|
const ALT_WHEEL_SCROLL_MULTIPLIER = 5;
|
|
@@ -12461,7 +12715,15 @@ const MAX_CACHED_OFFSCREEN_KITTY_TRANSMISSION_BYTES = 33554432;
|
|
|
12461
12715
|
const MAX_CACHED_OFFSCREEN_KITTY_DECODED_BYTES = 67108864;
|
|
12462
12716
|
const DOUBLE_CLICK_INTERVAL_MS = 500;
|
|
12463
12717
|
const COPY_ERROR_FLASH_DURATION_MS = 5e3;
|
|
12464
|
-
const TERMINAL_WORD_SELECTION_JOINERS = /* @__PURE__ */ new Set([
|
|
12718
|
+
const TERMINAL_WORD_SELECTION_JOINERS = /* @__PURE__ */ new Set([
|
|
12719
|
+
"/",
|
|
12720
|
+
"-",
|
|
12721
|
+
"+",
|
|
12722
|
+
"\\",
|
|
12723
|
+
"~",
|
|
12724
|
+
"_",
|
|
12725
|
+
"."
|
|
12726
|
+
]);
|
|
12465
12727
|
const wordSegmenter = getWordSegmenter();
|
|
12466
12728
|
/** Alternate-screen TUI with a scrollable, application-owned viewport. */
|
|
12467
12729
|
var TuiAltScreen = class extends TuiBase {
|
|
@@ -12733,7 +12995,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12733
12995
|
if (options.preserveScreen) this.terminal.write(`${BEGIN_SYNCHRONIZED_OUTPUT}${EXIT_ALT_SCREEN}\x1b[?25h${END_SYNCHRONIZED_OUTPUT}`);
|
|
12734
12996
|
else {
|
|
12735
12997
|
const width = Math.max(1, this.terminal.columns);
|
|
12736
|
-
const documentLines = this.render(width).map((line) => line.replace(OSC133_ZONE_PREFIX, "")).map((line) => this.sixelScreen?.candidate(line)?.fallback ?? line);
|
|
12998
|
+
const documentLines = this.resolveFakeCursors(this.render(width)).map((line) => line.replace(OSC133_ZONE_PREFIX$1, "")).map((line) => this.sixelScreen?.candidate(line)?.fallback ?? line);
|
|
12737
12999
|
this.lastDocument = this.applyLineResets(documentLines.map((line) => line.replaceAll(CURSOR_MARKER, ""))).map((line) => this.sixelFootprint(line) !== void 0 ? "" : isImageLine(line) || visibleWidth(line) <= width ? line : sliceByColumn(line, 0, width, true));
|
|
12738
13000
|
let buffer = `${BEGIN_SYNCHRONIZED_OUTPUT}${EXIT_ALT_SCREEN}${DISABLE_AUTOWRAP}`;
|
|
12739
13001
|
for (let row = 0; row < this.lastDocument.length; row++) {
|
|
@@ -12748,6 +13010,14 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12748
13010
|
this.savedCapabilities = void 0;
|
|
12749
13011
|
}
|
|
12750
13012
|
}
|
|
13013
|
+
getExitRestorePrefix() {
|
|
13014
|
+
const prefix = super.getExitRestorePrefix();
|
|
13015
|
+
if (!this.altScreenActive) return prefix;
|
|
13016
|
+
return `${END_SYNCHRONIZED_OUTPUT}${this.mouseEnabled ? DISABLE_MOUSE : ""}${ENABLE_AUTOWRAP}${prefix}`;
|
|
13017
|
+
}
|
|
13018
|
+
getExitRestoreSuffix() {
|
|
13019
|
+
return `${super.getExitRestoreSuffix()}${this.altScreenActive ? `${EXIT_ALT_SCREEN}\x1b[?25h` : ""}`;
|
|
13020
|
+
}
|
|
12751
13021
|
deleteKittyImages() {
|
|
12752
13022
|
return this.imageProtocol === "kitty" ? deleteAllKittyImages() : "";
|
|
12753
13023
|
}
|
|
@@ -13014,6 +13284,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13014
13284
|
flash(message, durationMs) {
|
|
13015
13285
|
this.flashes.flash(message, durationMs);
|
|
13016
13286
|
}
|
|
13287
|
+
/** Focused overlays and components that capture viewport input receive viewport keys instead of the transcript. */
|
|
13017
13288
|
shouldDeferViewportInputToOverlay() {
|
|
13018
13289
|
return this.isOverlayFocused() && this.activeSearch?.overlay?.isFocused() !== true;
|
|
13019
13290
|
}
|
|
@@ -13174,6 +13445,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13174
13445
|
}
|
|
13175
13446
|
}
|
|
13176
13447
|
if (this.shouldDeferViewportInputToOverlay()) return void 0;
|
|
13448
|
+
if (this.getFocusedComponent()?.capturesViewportInput === true) return void 0;
|
|
13177
13449
|
if (!isRelease && this.onBeforeViewportInput?.(data) === true) return { consume: true };
|
|
13178
13450
|
const primaryScrollable = this.getPrimaryScrollView().canScroll;
|
|
13179
13451
|
if (keybindings.matches(data, "tui.altScreen.search")) {
|
|
@@ -14149,7 +14421,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
14149
14421
|
if (this.sixelScreen !== void 0) {
|
|
14150
14422
|
if (this.sixelScreen.reconcileVisible(this, nextLayout.sixelDemands)) nextLayout = renderLayoutFrame(root, width, height, () => this.requestRender(), this.sixelScreen);
|
|
14151
14423
|
}
|
|
14152
|
-
let screen = nextLayout.lines.map((line) => line.replace(OSC133_ZONE_PREFIX, ""));
|
|
14424
|
+
let screen = this.resolveFakeCursors(nextLayout.lines.map((line) => line.replace(OSC133_ZONE_PREFIX$1, "")));
|
|
14153
14425
|
screen = this.applySearchHighlights(screen, nextLayout);
|
|
14154
14426
|
screen = this.compositeScrollToEndIndicator(screen, nextLayout, width);
|
|
14155
14427
|
screen = this.compositeOverlays(screen, width, height);
|
|
@@ -14246,6 +14518,8 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
14246
14518
|
this.onFramePainted?.();
|
|
14247
14519
|
}
|
|
14248
14520
|
};
|
|
14521
|
+
/** OSC 133 prompt markers at the start of a rendered line. Fullscreen uses them for prompt navigation. */
|
|
14522
|
+
const OSC133_ZONE_PREFIX = /^(?:\x1b\]133;[ABC](?:\x07|\x1b\\))+/;
|
|
14249
14523
|
const KITTY_SEQUENCE_PREFIX = "\x1B_G";
|
|
14250
14524
|
const MAX_RENDER_WRITE_CHARS = 1048576;
|
|
14251
14525
|
const EMPTY_IMAGE_IDS = [];
|
|
@@ -14707,7 +14981,7 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
14707
14981
|
const currentScreenRow = hardwareCursorRow - prevViewportTop;
|
|
14708
14982
|
return targetRow - viewportTop - currentScreenRow;
|
|
14709
14983
|
};
|
|
14710
|
-
let rawLines = this.render(width);
|
|
14984
|
+
let rawLines = this.resolveFakeCursors(this.render(width).map((line) => line.replace(OSC133_ZONE_PREFIX, "")));
|
|
14711
14985
|
if (this.hasOverlayEntries) {
|
|
14712
14986
|
rawLines = this.compositeOverlays(rawLines, width, height);
|
|
14713
14987
|
this.suppressOverlayCoveredSixelBlocks(rawLines);
|
|
@@ -15711,6 +15985,14 @@ const APP_KEYBINDINGS = {
|
|
|
15711
15985
|
scope: "question",
|
|
15712
15986
|
configurable: false
|
|
15713
15987
|
},
|
|
15988
|
+
"interaction.navigateWorkspace": {
|
|
15989
|
+
id: "interaction.navigateWorkspace",
|
|
15990
|
+
defaultKeys: ["alt+w"],
|
|
15991
|
+
description: "Open the Session Workspace without answering the pending interaction",
|
|
15992
|
+
category: "Question",
|
|
15993
|
+
scope: "overlay",
|
|
15994
|
+
configurable: false
|
|
15995
|
+
},
|
|
15714
15996
|
"tasks.open": {
|
|
15715
15997
|
id: "tasks.open",
|
|
15716
15998
|
defaultKeys: ["enter"],
|
|
@@ -16560,12 +16842,14 @@ const SESSIONLESS_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
16560
16842
|
"preset",
|
|
16561
16843
|
"keybindings",
|
|
16562
16844
|
"plugins",
|
|
16845
|
+
"web",
|
|
16563
16846
|
"quit",
|
|
16564
16847
|
"statusline",
|
|
16565
16848
|
"status",
|
|
16566
16849
|
"view-image",
|
|
16567
16850
|
"deliverables",
|
|
16568
|
-
"reload-client"
|
|
16851
|
+
"reload-client",
|
|
16852
|
+
"schedule"
|
|
16569
16853
|
]);
|
|
16570
16854
|
/**
|
|
16571
16855
|
* The LOCAL-execute command set (PR5 v2 §1C-6 narrows its semantic role):
|
|
@@ -16624,10 +16908,12 @@ const LOCAL_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
16624
16908
|
"title",
|
|
16625
16909
|
"transcript",
|
|
16626
16910
|
"yolo",
|
|
16911
|
+
"web",
|
|
16627
16912
|
"view-image",
|
|
16628
16913
|
"deliverables",
|
|
16629
16914
|
"statusline",
|
|
16630
|
-
"reload-client"
|
|
16915
|
+
"reload-client",
|
|
16916
|
+
"schedule"
|
|
16631
16917
|
]);
|
|
16632
16918
|
/**
|
|
16633
16919
|
* The STATIC host-owned command catalog (P1-04): the ownership sets
|
|
@@ -19876,14 +20162,6 @@ var PiTuiExtensionServiceImpl = class PiTuiExtensionServiceImpl extends Service
|
|
|
19876
20162
|
};
|
|
19877
20163
|
//#endregion
|
|
19878
20164
|
//#region src/extensions.ts
|
|
19879
|
-
var extensions_exports = /* @__PURE__ */ __exportAll({
|
|
19880
|
-
API_VERSION: () => 2,
|
|
19881
|
-
PI_TUI_EXTENSIONS_SERVICE: () => PI_TUI_EXTENSIONS_SERVICE,
|
|
19882
|
-
apply: () => apply,
|
|
19883
|
-
describeKey: () => describeKey,
|
|
19884
|
-
inject: () => inject,
|
|
19885
|
-
name: () => name
|
|
19886
|
-
});
|
|
19887
20165
|
/** Stable Cordis plugin name for the extension host row. */
|
|
19888
20166
|
const name = "pi-tui-extension-host";
|
|
19889
20167
|
/** The host mounts only when the TUI startup flags were parsed (same gate
|
|
@@ -19912,4 +20190,4 @@ function apply(ctx) {
|
|
|
19912
20190
|
new PiTuiExtensionServiceImpl(ctx, packageVersion(), () => {}, HOST_COMMAND_CATALOG);
|
|
19913
20191
|
}
|
|
19914
20192
|
//#endregion
|
|
19915
|
-
export { findAltScreenSearchMatches as $,
|
|
20193
|
+
export { findAltScreenSearchMatches as $, isValidKeyId as A, Markdown as B, isTerminalAmbiguousKeyId as C, stripControlChars as Ct, canonicalizeKeyId as D, VIEWER_BLOCKED_PARENT_ACTIONS as E, Editor as F, Spacer as G, ProcessTerminal as H, HStack as I, TuiMainScreen as J, Text as K, Image as L, CURSOR_MARKER as M, CombinedAutocompleteProvider as N, isRuntimeBindableKeyId as O, Container as P, dispatchMouseEvent as Q, Input as R, isPhysicalEscapeAction as S, resolveCommandFooterFallback as St, APP_KEYBINDINGS as T, ScrollView as U, MouseRegion as V, SettingsList as W, decodeKittyPrintable as X, VStack as Y, decodePrintableKey as Z, normalizeSkillInvocation as _, wrapTextWithAnsi as _t, API_VERSION as a, getOsc8LinkAtColumn as at, DEFAULT_LEADER_TIMEOUT_MS as b, isFooterLayout as bt, HOST_COMMAND_CATALOG as c, isKeyRelease as ct, classifyCommandLine as d, parseKey as dt, fuzzyFilter as et, commandIsLocalForAttachments as f, registerKittyImageMetadata as ft, localCommandMayWrite as g, visibleWidth as gt, isPlainExitPrompt as h, truncateToWidth as ht, PI_TUI_EXTENSIONS_SERVICE as i, getKeybindings as it, AltScreenSearchIndex as j, isTextProducingKeyId as k, LOCAL_COMMANDS as l, isKeyRepeat as lt, isLocalCommandLine as m, stripTerminalSequences as mt, inject as n, getCellDimensions as nt, describeKey as o, imageFallback as ot, isBareCommandLine as p, sliceByColumn as pt, TuiAltScreen as q, name as r, getGraphemeSegmenter as rt, InvalidateBatcher as s, isFocusable as st, apply as t, getCapabilities as tt, SESSIONLESS_COMMANDS as u, matchesKey as ut, shouldConsumeAdvertisedMiss as v, defaultHideInTsp as vt, parseUserKeybindings as w, isEditorSubmitPreSubmitKey as x, parseFooterLayout as xt, normalizeInputEvent as y, hideFooterRefInTsp as yt, Key as z };
|