@xmoon76/dsh-pi-tui 0.5.4 → 0.5.5
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 +28 -7
- package/README.md +25 -6
- package/dist/application-runtime-CbBO4bY-.mjs +6860 -0
- package/dist/bootstrap-DLOydLLj.mjs +108410 -0
- package/dist/builtins.mjs +2 -3
- package/dist/client-bootstrap-DwSFzcTW.mjs +872 -0
- package/dist/context-summary-Bz0AGXa1.mjs +12027 -0
- package/dist/{context-summary-DAisTA_7.mjs → context-summary-D9mhxPXL.mjs} +1468 -10
- package/dist/custom-items-CKrOBCox.mjs +655 -0
- package/dist/disposal-BYBbEpVY.mjs +54 -0
- package/dist/dispose-cause-BzcXo4hu.mjs +123 -0
- package/dist/dist-C7QMk0ws.mjs +15431 -0
- package/dist/{entry-control-DvSrndWd.mjs → entry-control-DnduyDiw.mjs} +12 -31
- package/dist/{extensions-CcuMY4n2.mjs → extensions-pcFiH7Qe.mjs} +758 -68
- package/dist/extensions.mjs +1 -1
- package/dist/host-bootstrap-CKdfLkNS.mjs +188 -0
- package/dist/host-foundation-probe-CYHsbAw6.mjs +143 -0
- package/dist/host-prerequisites-9JBTtVNu.mjs +36 -0
- package/dist/host-runtime.d.mts +26 -0
- package/dist/host-runtime.mjs +450 -0
- package/dist/index.d.mts +8 -1
- package/dist/index.mjs +5192 -2118
- package/dist/local-client.mjs +1681 -188
- package/dist/local-discovery-CXnLT4GF.mjs +755 -0
- package/dist/local-discovery-DVFFpfBG.mjs +2 -0
- package/dist/local-host.mjs +927 -78
- package/dist/local-transport-C9aonplC.mjs +513 -0
- package/dist/performance-host.d.mts +2 -2
- package/dist/performance-host.mjs +258 -1
- package/dist/pi-tui-remote-contribution-DRk6Tl3J.mjs +78 -0
- package/dist/pi-tui-terminal-progress-contract-CdBH9j78.mjs +70 -0
- package/dist/pi-tui-terminal-progress-contract-XTQKj-WW.mjs +905 -0
- package/dist/{runtime-vc4mdr-R.mjs → runtime-Bh5OsftD.mjs} +655 -675
- package/dist/runtime-C5ROZqFj.mjs +2 -0
- package/dist/{session-tdJHLnJR.mjs → session-4keoXjk0.mjs} +2341 -217
- package/dist/session-B2zqv4wr.mjs +10869 -0
- package/dist/{startup-JaVZoTIl.mjs → startup-Ct2UUjUL.mjs} +7 -6
- package/dist/startup.d.mts +1 -1
- package/dist/startup.mjs +1 -1
- package/dist/{client-bootstrap-F5DHFI9t.mjs → terminal-progress-source-BhufrZ74.mjs} +3431 -3007
- package/dist/terminal-progress-source-CsBinCJ_.mjs +965 -0
- package/package.json +125 -116
- package/dist/host-bootstrap-DAgKknbY.mjs +0 -119
- package/dist/performance-host-CcDJjjVA.mjs +0 -266
- package/dist/rolldown-runtime-8H4AJuhK.mjs +0 -14
- package/dist/terminal-progress-source-xor3vakJ.mjs +0 -2256
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as TUI_STARTUP_SERVICE } from "./startup-JaVZoTIl.mjs";
|
|
1
|
+
import { n as TUI_STARTUP_SERVICE } from "./startup-Ct2UUjUL.mjs";
|
|
3
2
|
import { createRequire } from "node:module";
|
|
4
3
|
import * as fs from "node:fs";
|
|
5
4
|
import { readFileSync } from "node:fs";
|
|
@@ -19,7 +18,41 @@ import { performance as performance$1 } from "node:perf_hooks";
|
|
|
19
18
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
20
19
|
import { EventEmitter } from "events";
|
|
21
20
|
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
|
|
22
33
|
//#region src/domain/footer/layout.ts
|
|
34
|
+
/** The per-id default `Hide in TSP` value (Owner-frozen): the three items
|
|
35
|
+
* that a capable TSP composer already carries are hidden by default; every
|
|
36
|
+
* other item keeps the historical TSP behavior. This is the EDITOR default
|
|
37
|
+
* (a capability shortage must never turn the editor's On into Off). */
|
|
38
|
+
function defaultHideInTsp(id) {
|
|
39
|
+
return id === "permission-preset" || id === "model" || id === "reasoning";
|
|
40
|
+
}
|
|
41
|
+
/** The ONE TSP effective-visibility decision for one placement. An explicit
|
|
42
|
+
* user boolean always wins; otherwise the three default-On ids hide only
|
|
43
|
+
* when their corresponding composer control is actually available (so the
|
|
44
|
+
* permission state never disappears on an old client without the control),
|
|
45
|
+
* and every other id stays visible. */
|
|
46
|
+
function hideFooterRefInTsp(ref, affordances) {
|
|
47
|
+
if (ref.hideInTsp !== void 0) return ref.hideInTsp;
|
|
48
|
+
if (!defaultHideInTsp(ref.id)) return false;
|
|
49
|
+
switch (ref.id) {
|
|
50
|
+
case "permission-preset": return affordances.permission;
|
|
51
|
+
case "model": return affordances.model;
|
|
52
|
+
case "reasoning": return affordances.reasoning;
|
|
53
|
+
default: return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
23
56
|
/** The semantic tone vocabulary a layout may reference. */
|
|
24
57
|
const TONES = /* @__PURE__ */ new Set([
|
|
25
58
|
"primary",
|
|
@@ -121,6 +154,13 @@ function parseItemRef(input, index) {
|
|
|
121
154
|
};
|
|
122
155
|
ref.importance = input.importance;
|
|
123
156
|
}
|
|
157
|
+
if (input.hideInTsp !== void 0) {
|
|
158
|
+
if (typeof input.hideInTsp !== "boolean") return {
|
|
159
|
+
kind: "error",
|
|
160
|
+
message: `item ${index}: hideInTsp must be a boolean`
|
|
161
|
+
};
|
|
162
|
+
ref.hideInTsp = input.hideInTsp;
|
|
163
|
+
}
|
|
124
164
|
return ref;
|
|
125
165
|
}
|
|
126
166
|
function parseRow(input, index) {
|
|
@@ -3797,12 +3837,65 @@ var TuiBase = class TuiBase extends Container {
|
|
|
3797
3837
|
return component.mouseLayout;
|
|
3798
3838
|
}
|
|
3799
3839
|
overlayFocusRestore = { status: "inactive" };
|
|
3800
|
-
|
|
3840
|
+
/**
|
|
3841
|
+
* The Client-local SIXEL trust port (X072), or undefined for every other
|
|
3842
|
+
* terminal. A Screen never parses a DCS itself: it asks this port, which
|
|
3843
|
+
* only recognizes rasters its own owner encoded.
|
|
3844
|
+
*/
|
|
3845
|
+
sixelScreen;
|
|
3846
|
+
/** Whether `start()` has brought the terminal up (only then may a query go out). */
|
|
3847
|
+
terminalStarted = false;
|
|
3848
|
+
/** Observers of this screen's ONE real `CSI 6;h;w t` parse (X072). */
|
|
3849
|
+
cellSizeListeners = /* @__PURE__ */ new Set();
|
|
3850
|
+
constructor(terminal, showHardwareCursor, logDirectory, sixelScreen) {
|
|
3801
3851
|
super();
|
|
3802
3852
|
this.terminal = terminal;
|
|
3803
3853
|
this.logDirectory = logDirectory;
|
|
3854
|
+
this.sixelScreen = sixelScreen;
|
|
3804
3855
|
if (showHardwareCursor !== void 0) this.showHardwareCursor = showHardwareCursor;
|
|
3805
3856
|
}
|
|
3857
|
+
/**
|
|
3858
|
+
* Whether this line must be treated as an IMAGE by the physical Screen
|
|
3859
|
+
* (X072): a legacy Kitty/iTerm2 placement, or an exact DCS the Client-local
|
|
3860
|
+
* SIXEL owner registered.
|
|
3861
|
+
*
|
|
3862
|
+
* This is a trust question, not a syntax question. A DCS that is not in the
|
|
3863
|
+
* owner's registry stays ordinary text and goes through the normal
|
|
3864
|
+
* normalization/truncation path, so an arbitrary `ESC P…q…ESC \` from a tool
|
|
3865
|
+
* result can never be promoted to a device command.
|
|
3866
|
+
*/
|
|
3867
|
+
isRenderableImageLine(line) {
|
|
3868
|
+
return isImageLine(line) || this.sixelScreen?.footprint(line) !== void 0 || this.sixelScreen?.candidate(line) !== void 0;
|
|
3869
|
+
}
|
|
3870
|
+
/** The registered SIXEL footprint of a trusted anchor line, if any (X072). */
|
|
3871
|
+
sixelFootprint(line) {
|
|
3872
|
+
return this.sixelScreen?.footprint(line);
|
|
3873
|
+
}
|
|
3874
|
+
/**
|
|
3875
|
+
* Observe every real cell-size reply this screen parses, or return the
|
|
3876
|
+
* current value immediately when it is already known (X072).
|
|
3877
|
+
*
|
|
3878
|
+
* There is ONE parser (`consumeCellSizeResponse`); observers never see a
|
|
3879
|
+
* query they issued, only the terminal's actual `CSI 6;h;w t` answer.
|
|
3880
|
+
*/
|
|
3881
|
+
onCellSizeObserved(listener) {
|
|
3882
|
+
this.cellSizeListeners.add(listener);
|
|
3883
|
+
return () => {
|
|
3884
|
+
this.cellSizeListeners.delete(listener);
|
|
3885
|
+
};
|
|
3886
|
+
}
|
|
3887
|
+
/**
|
|
3888
|
+
* Ask the terminal for its cell size in device pixels (`CSI 16t`, answered as
|
|
3889
|
+
* `CSI 6;h;w t`) on behalf of a consumer that needs REAL geometry (X072).
|
|
3890
|
+
*
|
|
3891
|
+
* Unlike the startup probe this refuses before `start()`: a query written to
|
|
3892
|
+
* a terminal this screen does not own yet would be answered into the input
|
|
3893
|
+
* stream of whoever does.
|
|
3894
|
+
*/
|
|
3895
|
+
queryCellSizeForSixel() {
|
|
3896
|
+
if (!this.terminalStarted) return;
|
|
3897
|
+
this.terminal.write("\x1B[16t");
|
|
3898
|
+
}
|
|
3806
3899
|
resetRenderState() {}
|
|
3807
3900
|
beforeTerminalStart() {}
|
|
3808
3901
|
afterTerminalStart() {}
|
|
@@ -4149,6 +4242,7 @@ var TuiBase = class TuiBase extends Container {
|
|
|
4149
4242
|
this.stopped = false;
|
|
4150
4243
|
this.beforeTerminalStart();
|
|
4151
4244
|
this.terminal.start((data) => this.handleTerminalInput(data), () => this.requestRender());
|
|
4245
|
+
this.terminalStarted = true;
|
|
4152
4246
|
this.afterTerminalStart();
|
|
4153
4247
|
this.terminal.hideCursor();
|
|
4154
4248
|
if (this.terminalColorSchemeNotificationsEnabled) this.terminal.write("\x1B[?2031h");
|
|
@@ -4181,6 +4275,7 @@ var TuiBase = class TuiBase extends Container {
|
|
|
4181
4275
|
}
|
|
4182
4276
|
stop(options = {}) {
|
|
4183
4277
|
this.stopped = true;
|
|
4278
|
+
this.terminalStarted = false;
|
|
4184
4279
|
this.cancelRenderTimer();
|
|
4185
4280
|
this.settleBackgroundProbe(void 0);
|
|
4186
4281
|
const failures = [];
|
|
@@ -4363,6 +4458,10 @@ var TuiBase = class TuiBase extends Container {
|
|
|
4363
4458
|
widthPx,
|
|
4364
4459
|
heightPx
|
|
4365
4460
|
});
|
|
4461
|
+
for (const listener of this.cellSizeListeners) listener({
|
|
4462
|
+
widthPx,
|
|
4463
|
+
heightPx
|
|
4464
|
+
});
|
|
4366
4465
|
this.invalidate();
|
|
4367
4466
|
this.requestRender();
|
|
4368
4467
|
return true;
|
|
@@ -4512,14 +4611,38 @@ var TuiBase = class TuiBase extends Container {
|
|
|
4512
4611
|
const reset = SEGMENT_RESET;
|
|
4513
4612
|
for (let i = 0; i < lines.length; i++) {
|
|
4514
4613
|
const line = lines[i];
|
|
4515
|
-
if (!
|
|
4614
|
+
if (!this.isRenderableImageLine(line)) lines[i] = normalizeTerminalOutput(line) + reset;
|
|
4516
4615
|
}
|
|
4517
4616
|
return lines;
|
|
4518
4617
|
}
|
|
4519
4618
|
compositeLineAt(baseLine, overlayLine, startCol, overlayWidth, totalWidth) {
|
|
4619
|
+
if (this.sixelScreen?.footprint(baseLine) !== void 0 || this.sixelScreen?.candidate(baseLine) !== void 0) return compositeTuiLine("", overlayLine, startCol, overlayWidth, totalWidth);
|
|
4520
4620
|
return compositeTuiLine(baseLine, overlayLine, startCol, overlayWidth, totalWidth);
|
|
4521
4621
|
}
|
|
4522
4622
|
/**
|
|
4623
|
+
* The absolute line range a visible overlay painted on this frame (X072).
|
|
4624
|
+
*
|
|
4625
|
+
* Overlay placements are viewport-relative, exactly like the compositor's own
|
|
4626
|
+
* `workingHeight - termHeight` origin, so the mapping is derived from the same
|
|
4627
|
+
* inputs instead of being guessed by the caller.
|
|
4628
|
+
*/
|
|
4629
|
+
overlayPaintedLineRange(overlayRow, overlayHeight, totalLines) {
|
|
4630
|
+
const first = Math.max(0, totalLines - this.terminal.rows) + overlayRow;
|
|
4631
|
+
return {
|
|
4632
|
+
first,
|
|
4633
|
+
last: first + overlayHeight - 1
|
|
4634
|
+
};
|
|
4635
|
+
}
|
|
4636
|
+
/** Whether a visible overlay painted any cell on any of these absolute lines. */
|
|
4637
|
+
linesCoveredByOverlay(firstLine, lastLine, totalLines) {
|
|
4638
|
+
for (const layout of this.renderedOverlayLayouts) {
|
|
4639
|
+
const range = this.overlayPaintedLineRange(layout.row, layout.height, totalLines);
|
|
4640
|
+
if (range.last < firstLine || range.first > lastLine) continue;
|
|
4641
|
+
return true;
|
|
4642
|
+
}
|
|
4643
|
+
return false;
|
|
4644
|
+
}
|
|
4645
|
+
/**
|
|
4523
4646
|
* Find and extract cursor position from rendered lines.
|
|
4524
4647
|
* Searches for CURSOR_MARKER, calculates its position, and strips it from the output.
|
|
4525
4648
|
* Only scans the bottom terminal height lines (visible viewport).
|
|
@@ -11029,6 +11152,18 @@ function parseKeyboardProtocolNegotiationSequence(sequence) {
|
|
|
11029
11152
|
function isKeyboardProtocolNegotiationSequencePrefix(sequence) {
|
|
11030
11153
|
return sequence === "\x1B[" || /^\x1b\[\?[\d;]*$/.test(sequence);
|
|
11031
11154
|
}
|
|
11155
|
+
/**
|
|
11156
|
+
* Whether a complete PRIMARY device-attributes reply (`CSI ? ... c`) declares
|
|
11157
|
+
* the SIXEL attribute (`4`), or `undefined` when this is not a primary DA1.
|
|
11158
|
+
*
|
|
11159
|
+
* Parameters are compared as whole tokens: a substring test would wrongly
|
|
11160
|
+
* accept `14`, `42` or `24` as evidence of SIXEL support (X071).
|
|
11161
|
+
*/
|
|
11162
|
+
function primaryDeviceAttributesDeclareSixel(sequence) {
|
|
11163
|
+
const match = /^\x1b\[\?([\d;]*)c$/.exec(sequence);
|
|
11164
|
+
if (!match) return void 0;
|
|
11165
|
+
return match[1].split(";").some((token) => token !== "" && Number.parseInt(token, 10) === 4);
|
|
11166
|
+
}
|
|
11032
11167
|
function isAppleTerminalSession() {
|
|
11033
11168
|
return process.platform === "darwin" && process.env.TERM_PROGRAM === "Apple_Terminal";
|
|
11034
11169
|
}
|
|
@@ -11091,6 +11226,14 @@ var ProcessTerminal = class {
|
|
|
11091
11226
|
pendingKeyboardProtocolDeviceAttributes = 0;
|
|
11092
11227
|
keyboardProtocolNegotiationBuffer = "";
|
|
11093
11228
|
keyboardProtocolBufferFlushTimer;
|
|
11229
|
+
/** Passive DA1 SIXEL observers (X071). One store; no reply replay buffer. */
|
|
11230
|
+
sixelObservers = /* @__PURE__ */ new Set();
|
|
11231
|
+
/**
|
|
11232
|
+
* Last observed primary-DA1 SIXEL answer for the PHYSICAL terminal this
|
|
11233
|
+
* instance represents (X071). Survives `stop()` and `start()`: the same
|
|
11234
|
+
* hardware cannot un-learn the capability between a Main and an Alt screen.
|
|
11235
|
+
*/
|
|
11236
|
+
lastObservedSixel = void 0;
|
|
11094
11237
|
stdinBuffer;
|
|
11095
11238
|
stdinDataHandler;
|
|
11096
11239
|
progressInterval;
|
|
@@ -11175,6 +11318,7 @@ var ProcessTerminal = class {
|
|
|
11175
11318
|
this.scheduleKeyboardProtocolNegotiationBufferFlush();
|
|
11176
11319
|
return;
|
|
11177
11320
|
}
|
|
11321
|
+
if (negotiation?.parsed.type === "device-attributes") this.observeSixelDeviceAttributes(negotiation.sequence);
|
|
11178
11322
|
if (negotiation && this.handleKeyboardProtocolNegotiationSequence(negotiation.parsed)) return;
|
|
11179
11323
|
this.forwardInputSequence(negotiation?.sequence ?? sequence);
|
|
11180
11324
|
});
|
|
@@ -11215,6 +11359,33 @@ var ProcessTerminal = class {
|
|
|
11215
11359
|
process.stdout.write(`${KITTY_KEYBOARD_PROTOCOL_QUERY}${programStatusQuery}${DEVICE_ATTRIBUTES_QUERY}`);
|
|
11216
11360
|
this.writeProgramStatus();
|
|
11217
11361
|
}
|
|
11362
|
+
/**
|
|
11363
|
+
* Passive DA1 observation; see `Terminal.onSixelSupport` (X071). The
|
|
11364
|
+
* registration is committed BEFORE any synchronous delivery so a listener
|
|
11365
|
+
* that unsubscribes itself (or disposes its owner) inside the callback
|
|
11366
|
+
* observes the already-committed state.
|
|
11367
|
+
*/
|
|
11368
|
+
onSixelSupport(listener) {
|
|
11369
|
+
this.sixelObservers.add(listener);
|
|
11370
|
+
const known = this.lastObservedSixel;
|
|
11371
|
+
if (known !== void 0) listener(known);
|
|
11372
|
+
return () => {
|
|
11373
|
+
this.sixelObservers.delete(listener);
|
|
11374
|
+
};
|
|
11375
|
+
}
|
|
11376
|
+
/**
|
|
11377
|
+
* Record the SIXEL attribute of one COMPLETE primary DA1 reply (X071).
|
|
11378
|
+
*
|
|
11379
|
+
* Called before the keyboard-negotiation sentinel may consume the same
|
|
11380
|
+
* reply. A repeated identical answer does not notify again.
|
|
11381
|
+
*/
|
|
11382
|
+
observeSixelDeviceAttributes(sequence) {
|
|
11383
|
+
const supported = primaryDeviceAttributesDeclareSixel(sequence);
|
|
11384
|
+
if (supported === void 0) return;
|
|
11385
|
+
if (this.lastObservedSixel === supported) return;
|
|
11386
|
+
this.lastObservedSixel = supported;
|
|
11387
|
+
for (const listener of [...this.sixelObservers]) listener(supported);
|
|
11388
|
+
}
|
|
11218
11389
|
handleKeyboardProtocolNegotiationSequence(negotiationSequence) {
|
|
11219
11390
|
this.clearKeyboardProtocolNegotiationBuffer();
|
|
11220
11391
|
if (negotiationSequence.type === "device-attributes") {
|
|
@@ -11739,6 +11910,8 @@ var AltScreenFlashContainer = class {
|
|
|
11739
11910
|
}
|
|
11740
11911
|
};
|
|
11741
11912
|
const OSC133_ZONE_PREFIX$1 = /^(?:\x1b\]133;[ABC](?:\x07|\x1b\\))+/;
|
|
11913
|
+
/** The largest number of image body rows an upward crop search may cross (X074). */
|
|
11914
|
+
const MAX_SIXEL_CROP_SCAN_ROWS = 12;
|
|
11742
11915
|
function intersect(a, b) {
|
|
11743
11916
|
const x = Math.max(a.x, b.x);
|
|
11744
11917
|
const y = Math.max(a.y, b.y);
|
|
@@ -11969,14 +12142,17 @@ function getScrollbarGeometry(box, includeHiddenAuto = false) {
|
|
|
11969
12142
|
maxScrollTop
|
|
11970
12143
|
};
|
|
11971
12144
|
}
|
|
11972
|
-
function paintScrollbar(box, screen, totalWidth) {
|
|
12145
|
+
function paintScrollbar(box, screen, totalWidth, sixelScreen) {
|
|
11973
12146
|
const geometry = getScrollbarGeometry(box);
|
|
11974
12147
|
if (!geometry || !box.scrollView) return;
|
|
11975
12148
|
for (let offset = 0; offset < geometry.trackHeight; offset++) {
|
|
11976
12149
|
const row = geometry.trackTop + offset;
|
|
11977
12150
|
if (row < box.clip.y || row >= box.clip.y + box.clip.height || row < 0 || row >= screen.length) continue;
|
|
11978
12151
|
const replacement = row >= geometry.thumbTop && row < geometry.thumbTop + geometry.thumbHeight ? box.scrollView.scrollbarThumbStyle(box.scrollView.isScrollbarActive ? "█" : "┃") : box.scrollView.scrollbarTrackStyle("│");
|
|
11979
|
-
|
|
12152
|
+
const line = screen[row] ?? "";
|
|
12153
|
+
const footprint = sixelScreen?.footprint(line);
|
|
12154
|
+
if (footprint !== void 0 && footprint.columns <= geometry.column) continue;
|
|
12155
|
+
screen[row] = replaceScrollbarCell(footprint === void 0 ? line : "", geometry.column, totalWidth, replacement, box.scrollView.scrollbar !== "always");
|
|
11980
12156
|
}
|
|
11981
12157
|
}
|
|
11982
12158
|
/** The managed virtual image row bound; only this window may be scanned. */
|
|
@@ -12017,7 +12193,22 @@ function findRelocatedVirtualAnchor(box, firstRow, lastRow) {
|
|
|
12017
12193
|
};
|
|
12018
12194
|
}
|
|
12019
12195
|
}
|
|
12020
|
-
function
|
|
12196
|
+
function sixelBlock(line, port) {
|
|
12197
|
+
if (port === void 0) return void 0;
|
|
12198
|
+
const candidate = port.candidate(line);
|
|
12199
|
+
if (candidate !== void 0) return {
|
|
12200
|
+
kind: "candidate",
|
|
12201
|
+
rows: candidate.layoutRows,
|
|
12202
|
+
fallback: candidate.fallback
|
|
12203
|
+
};
|
|
12204
|
+
const footprint = port.footprint(line);
|
|
12205
|
+
if (footprint !== void 0) return {
|
|
12206
|
+
kind: "dcs",
|
|
12207
|
+
rows: footprint.rows
|
|
12208
|
+
};
|
|
12209
|
+
}
|
|
12210
|
+
function paintBox(box, screen, totalWidth, context) {
|
|
12211
|
+
const sixelScreen = context.sixelScreen;
|
|
12021
12212
|
if (box.lines) {
|
|
12022
12213
|
const offset = box.lineOffset ?? 0;
|
|
12023
12214
|
const firstRow = Math.max(box.rect.y, box.clip.y, 0);
|
|
@@ -12036,6 +12227,34 @@ function paintBox(box, screen, totalWidth) {
|
|
|
12036
12227
|
line = line.slice(marker.sequence.length);
|
|
12037
12228
|
}
|
|
12038
12229
|
if (relocated !== void 0 && sourceIndex === relocated.sourceIndex) line = relocated.sequence + line;
|
|
12230
|
+
const block = sixelBlock(line, sixelScreen);
|
|
12231
|
+
if (block !== void 0) {
|
|
12232
|
+
const fullWidthCell = box.rect.x === 0 && box.rect.width >= totalWidth;
|
|
12233
|
+
const clipBottom = Math.min(screen.length, box.clip.y + box.clip.height);
|
|
12234
|
+
const visibleRows = Math.min(block.rows, clipBottom - row);
|
|
12235
|
+
const scrollbar = box.scrollView === void 0 ? void 0 : getScrollbarGeometry(box);
|
|
12236
|
+
const scrollbarClaimsRow = scrollbar !== void 0 && row <= scrollbar.trackTop + scrollbar.trackHeight - 1 && row + visibleRows - 1 >= scrollbar.trackTop;
|
|
12237
|
+
if (block.kind === "candidate") {
|
|
12238
|
+
if (fullWidthCell && visibleRows > 0 && !scrollbarClaimsRow) {
|
|
12239
|
+
context.sixelDemands.push({
|
|
12240
|
+
line,
|
|
12241
|
+
cropTopRows: 0,
|
|
12242
|
+
visibleRows,
|
|
12243
|
+
physicalRow: row
|
|
12244
|
+
});
|
|
12245
|
+
screen[row] = sixelScreen?.materialize(line, 0, visibleRows) ?? block.fallback;
|
|
12246
|
+
} else screen[row] = block.fallback;
|
|
12247
|
+
continue;
|
|
12248
|
+
}
|
|
12249
|
+
if (fullWidthCell && visibleRows > 0) {
|
|
12250
|
+
if (visibleRows >= block.rows) screen[row] = line;
|
|
12251
|
+
else {
|
|
12252
|
+
const cropped = sixelScreen?.crop(line, 0, visibleRows);
|
|
12253
|
+
screen[row] = cropped ?? "";
|
|
12254
|
+
}
|
|
12255
|
+
}
|
|
12256
|
+
continue;
|
|
12257
|
+
}
|
|
12039
12258
|
const imageMetadata = getKittyImageMetadata(line);
|
|
12040
12259
|
if (imageMetadata) {
|
|
12041
12260
|
const clipBottom = Math.min(screen.length, box.clip.y + box.clip.height);
|
|
@@ -12046,23 +12265,47 @@ function paintBox(box, screen, totalWidth) {
|
|
|
12046
12265
|
else screen[row] = compositeTuiLine(screen[row] ?? "", line, box.rect.x, box.rect.width, totalWidth);
|
|
12047
12266
|
}
|
|
12048
12267
|
}
|
|
12049
|
-
for (const child of box.children) paintBox(child, screen, totalWidth);
|
|
12050
|
-
if (box.scrollView && box.scrollContentLines && box.scrollView.scrollTop > 0 && box.rect.height > 0)
|
|
12051
|
-
const
|
|
12052
|
-
|
|
12053
|
-
|
|
12054
|
-
const
|
|
12055
|
-
if (
|
|
12056
|
-
const
|
|
12057
|
-
|
|
12268
|
+
for (const child of box.children) paintBox(child, screen, totalWidth, context);
|
|
12269
|
+
if (box.scrollView && box.scrollContentLines && box.scrollView.scrollTop > 0 && box.rect.height > 0) {
|
|
12270
|
+
const scanFloor = Math.max(0, box.scrollView.scrollTop - MAX_SIXEL_CROP_SCAN_ROWS);
|
|
12271
|
+
for (let imageRow = box.scrollView.scrollTop - 1; imageRow >= 0; imageRow--) {
|
|
12272
|
+
const imageLine = box.scrollContentLines[imageRow] ?? "";
|
|
12273
|
+
const block = sixelBlock(imageLine, sixelScreen);
|
|
12274
|
+
if (block !== void 0) {
|
|
12275
|
+
const hiddenRows = box.scrollView.scrollTop - imageRow;
|
|
12276
|
+
const visibleRows = Math.min(box.rect.height, block.rows - hiddenRows);
|
|
12277
|
+
if (hiddenRows < block.rows && visibleRows > 0 && box.rect.x === 0 && box.rect.width >= totalWidth) {
|
|
12278
|
+
if (block.kind === "candidate") {
|
|
12279
|
+
context.sixelDemands.push({
|
|
12280
|
+
line: imageLine,
|
|
12281
|
+
cropTopRows: hiddenRows,
|
|
12282
|
+
visibleRows,
|
|
12283
|
+
physicalRow: box.rect.y
|
|
12284
|
+
});
|
|
12285
|
+
screen[box.rect.y] = sixelScreen?.materialize(imageLine, hiddenRows, visibleRows) ?? block.fallback;
|
|
12286
|
+
} else {
|
|
12287
|
+
const cropped = sixelScreen?.crop(imageLine, hiddenRows, visibleRows);
|
|
12288
|
+
if (cropped !== void 0) screen[box.rect.y] = cropped;
|
|
12289
|
+
}
|
|
12290
|
+
}
|
|
12291
|
+
break;
|
|
12058
12292
|
}
|
|
12059
|
-
|
|
12293
|
+
const metadata = getKittyImageMetadata(imageLine);
|
|
12294
|
+
if (metadata) {
|
|
12295
|
+
const hiddenRows = box.scrollView.scrollTop - imageRow;
|
|
12296
|
+
if (hiddenRows < metadata.rows) {
|
|
12297
|
+
const cropped = cropKittyImageLine(imageLine, hiddenRows, Math.min(box.rect.height, metadata.rows - hiddenRows));
|
|
12298
|
+
if (box.rect.x === 0 && box.rect.width >= totalWidth) screen[box.rect.y] = cropped;
|
|
12299
|
+
}
|
|
12300
|
+
break;
|
|
12301
|
+
}
|
|
12302
|
+
if (imageLine !== "") break;
|
|
12303
|
+
if (sixelScreen !== void 0 && imageRow <= scanFloor) break;
|
|
12060
12304
|
}
|
|
12061
|
-
if (imageLine !== "") break;
|
|
12062
12305
|
}
|
|
12063
|
-
paintScrollbar(box, screen, totalWidth);
|
|
12306
|
+
paintScrollbar(box, screen, totalWidth, sixelScreen);
|
|
12064
12307
|
}
|
|
12065
|
-
function renderLayoutFrame(root, width, height, requestRender) {
|
|
12308
|
+
function renderLayoutFrame(root, width, height, requestRender, sixelScreen) {
|
|
12066
12309
|
const safeWidth = Math.max(1, Math.floor(width));
|
|
12067
12310
|
const safeHeight = Math.max(1, Math.floor(height));
|
|
12068
12311
|
const context = {
|
|
@@ -12073,7 +12316,9 @@ function renderLayoutFrame(root, width, height, requestRender) {
|
|
|
12073
12316
|
renderCache: /* @__PURE__ */ new Map(),
|
|
12074
12317
|
maxWidthCache: /* @__PURE__ */ new Map(),
|
|
12075
12318
|
requestRender,
|
|
12076
|
-
primaryScrollView: void 0
|
|
12319
|
+
primaryScrollView: void 0,
|
|
12320
|
+
sixelScreen,
|
|
12321
|
+
sixelDemands: []
|
|
12077
12322
|
};
|
|
12078
12323
|
const rootBox = layoutComponent(context, root, 0, 0, safeWidth, safeHeight, {
|
|
12079
12324
|
x: 0,
|
|
@@ -12082,12 +12327,13 @@ function renderLayoutFrame(root, width, height, requestRender) {
|
|
|
12082
12327
|
height: safeHeight
|
|
12083
12328
|
});
|
|
12084
12329
|
const lines = Array.from({ length: safeHeight }, () => "");
|
|
12085
|
-
paintBox(rootBox, lines, safeWidth);
|
|
12330
|
+
paintBox(rootBox, lines, safeWidth, context);
|
|
12086
12331
|
return {
|
|
12087
12332
|
root: rootBox,
|
|
12088
12333
|
width: safeWidth,
|
|
12089
12334
|
height: safeHeight,
|
|
12090
12335
|
lines,
|
|
12336
|
+
sixelDemands: context.sixelDemands,
|
|
12091
12337
|
...context.primaryScrollView === void 0 ? {} : { primaryScrollView: context.primaryScrollView }
|
|
12092
12338
|
};
|
|
12093
12339
|
}
|
|
@@ -12236,6 +12482,14 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12236
12482
|
imageProtocolOverride;
|
|
12237
12483
|
savedCapabilities;
|
|
12238
12484
|
uploadedKittyImages = /* @__PURE__ */ new Map();
|
|
12485
|
+
/**
|
|
12486
|
+
* Per-row trusted SIXEL block height of the LAST painted frame (X074).
|
|
12487
|
+
*
|
|
12488
|
+
* Cached instead of re-derived from the line: the previous anchor is a
|
|
12489
|
+
* registered DCS only while its owner lives, and a disposed raster must still
|
|
12490
|
+
* have its whole footprint erased.
|
|
12491
|
+
*/
|
|
12492
|
+
previousSixelRows = [];
|
|
12239
12493
|
selectionAnchor;
|
|
12240
12494
|
selectionFocus;
|
|
12241
12495
|
selectionGranularity = "character";
|
|
@@ -12294,7 +12548,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12294
12548
|
onBeforeViewportInput;
|
|
12295
12549
|
scrollbarBoundaryNotified;
|
|
12296
12550
|
constructor(terminal, showHardwareCursor, logDirectory, options = {}) {
|
|
12297
|
-
super(terminal, showHardwareCursor, logDirectory);
|
|
12551
|
+
super(terminal, showHardwareCursor, logDirectory, options.sixelScreen);
|
|
12298
12552
|
this.implicitDocument = {
|
|
12299
12553
|
render: (width) => super.render(width),
|
|
12300
12554
|
handleMouse: (event) => super.handleMouse(event),
|
|
@@ -12479,8 +12733,8 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12479
12733
|
if (options.preserveScreen) this.terminal.write(`${BEGIN_SYNCHRONIZED_OUTPUT}${EXIT_ALT_SCREEN}\x1b[?25h${END_SYNCHRONIZED_OUTPUT}`);
|
|
12480
12734
|
else {
|
|
12481
12735
|
const width = Math.max(1, this.terminal.columns);
|
|
12482
|
-
const documentLines = this.render(width).map((line) => line.replace(OSC133_ZONE_PREFIX, ""));
|
|
12483
|
-
this.lastDocument = this.applyLineResets(documentLines.map((line) => line.replaceAll(CURSOR_MARKER, ""))).map((line) => isImageLine(line) || visibleWidth(line) <= width ? line : sliceByColumn(line, 0, width, true));
|
|
12736
|
+
const documentLines = this.render(width).map((line) => line.replace(OSC133_ZONE_PREFIX, "")).map((line) => this.sixelScreen?.candidate(line)?.fallback ?? line);
|
|
12737
|
+
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));
|
|
12484
12738
|
let buffer = `${BEGIN_SYNCHRONIZED_OUTPUT}${EXIT_ALT_SCREEN}${DISABLE_AUTOWRAP}`;
|
|
12485
12739
|
for (let row = 0; row < this.lastDocument.length; row++) {
|
|
12486
12740
|
if (row > 0) buffer += "\r\n";
|
|
@@ -12539,10 +12793,75 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12539
12793
|
}
|
|
12540
12794
|
resetRenderState() {
|
|
12541
12795
|
this.previousScreen = [];
|
|
12796
|
+
this.previousSixelRows = [];
|
|
12542
12797
|
this.previousScreenWidth = 0;
|
|
12543
12798
|
this.previousScreenHeight = 0;
|
|
12544
12799
|
this.currentLayout = void 0;
|
|
12545
12800
|
}
|
|
12801
|
+
/**
|
|
12802
|
+
* Per-row trusted SIXEL block heights for this frame, dropping any block a
|
|
12803
|
+
* visible overlay paints over (X074).
|
|
12804
|
+
*
|
|
12805
|
+
* The raster is ONE command covering its whole footprint and it is written
|
|
12806
|
+
* LAST, so a per-row decision would either cover the overlay text or leave
|
|
12807
|
+
* half a picture. Such a block yields this frame; its identity row above stays
|
|
12808
|
+
* on screen and the block returns when the overlay is gone (the anchor line
|
|
12809
|
+
* changes, so the next frame re-enters the changed range).
|
|
12810
|
+
*/
|
|
12811
|
+
/**
|
|
12812
|
+
* Report this frame's physical SIXEL set after the write (X074).
|
|
12813
|
+
*
|
|
12814
|
+
* `sixelDemands` is the final layout's visible set; a block that materialized
|
|
12815
|
+
* is retained with its exact DCS (emitted only when this frame really wrote
|
|
12816
|
+
* that row), while a granted-but-unready block has no DCS and simply keeps
|
|
12817
|
+
* its grant for the owner to task the lane.
|
|
12818
|
+
*/
|
|
12819
|
+
commitSixelFrame(frame, screen, changedRows, repainted) {
|
|
12820
|
+
const port = this.sixelScreen;
|
|
12821
|
+
if (port === void 0) return;
|
|
12822
|
+
const retained = [];
|
|
12823
|
+
for (const demand of frame.sixelDemands) {
|
|
12824
|
+
const row = demand.physicalRow;
|
|
12825
|
+
const line = screen[row] ?? "";
|
|
12826
|
+
const footprint = port.footprint(line);
|
|
12827
|
+
if (footprint === void 0) continue;
|
|
12828
|
+
retained.push({
|
|
12829
|
+
row,
|
|
12830
|
+
line: demand.line,
|
|
12831
|
+
dcs: line,
|
|
12832
|
+
cropTopRows: demand.cropTopRows,
|
|
12833
|
+
visibleRows: footprint.rows,
|
|
12834
|
+
emitted: repainted || changedRows[row] !== false
|
|
12835
|
+
});
|
|
12836
|
+
}
|
|
12837
|
+
retained.sort((left, right) => right.row - left.row);
|
|
12838
|
+
port.framePainted(this, retained.map(({ line, dcs, cropTopRows, visibleRows, emitted }) => ({
|
|
12839
|
+
line,
|
|
12840
|
+
dcs,
|
|
12841
|
+
cropTopRows,
|
|
12842
|
+
visibleRows,
|
|
12843
|
+
emitted
|
|
12844
|
+
})));
|
|
12845
|
+
}
|
|
12846
|
+
prepareSixelRows(screen) {
|
|
12847
|
+
const rows = new Array(screen.length).fill(0);
|
|
12848
|
+
let any = false;
|
|
12849
|
+
for (let row = 0; row < screen.length; row++) {
|
|
12850
|
+
const footprint = this.sixelFootprint(screen[row] ?? "");
|
|
12851
|
+
if (footprint === void 0) continue;
|
|
12852
|
+
rows[row] = footprint.rows;
|
|
12853
|
+
any = true;
|
|
12854
|
+
}
|
|
12855
|
+
if (!any) return rows;
|
|
12856
|
+
if (this.hasOverlayEntries) for (let row = 0; row < rows.length; row++) {
|
|
12857
|
+
const height = rows[row] ?? 0;
|
|
12858
|
+
if (height === 0) continue;
|
|
12859
|
+
if (!this.linesCoveredByOverlay(row, row + height - 1, screen.length)) continue;
|
|
12860
|
+
screen[row] = "";
|
|
12861
|
+
rows[row] = 0;
|
|
12862
|
+
}
|
|
12863
|
+
return rows;
|
|
12864
|
+
}
|
|
12546
12865
|
scrollBy(lines) {
|
|
12547
12866
|
this.getPrimaryScrollView().scrollBy(lines);
|
|
12548
12867
|
this.requestRender();
|
|
@@ -12649,7 +12968,9 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
12649
12968
|
return false;
|
|
12650
12969
|
}
|
|
12651
12970
|
const shouldRevealSelection = search.selectionMode !== "retain";
|
|
12652
|
-
const
|
|
12971
|
+
const isEmptyImageRow = (line) => this.sixelFootprint(line) !== void 0 || this.sixelScreen?.candidate(line) !== void 0;
|
|
12972
|
+
const corpus = lines.some(isEmptyImageRow) ? lines.map((line) => isEmptyImageRow(line) ? "" : line) : lines;
|
|
12973
|
+
const result = search.index.search(corpus, search.query);
|
|
12653
12974
|
const matches = result.matches;
|
|
12654
12975
|
search.matches = matches;
|
|
12655
12976
|
if (!result.changed && search.selectionMode === "retain") return false;
|
|
@@ -13584,6 +13905,10 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13584
13905
|
const lines = [];
|
|
13585
13906
|
for (let row = selection.start.row; row <= selection.end.row; row++) {
|
|
13586
13907
|
const line = sourceLines[row] ?? "";
|
|
13908
|
+
if (this.isRenderableImageLine(line)) {
|
|
13909
|
+
lines.push("");
|
|
13910
|
+
continue;
|
|
13911
|
+
}
|
|
13587
13912
|
const columns = this.getSelectionColumns(line, row, selection);
|
|
13588
13913
|
const sliced = stripTerminalSequences(sliceByColumn(line, columns.start, Math.max(0, columns.end - columns.start), true)).trimEnd();
|
|
13589
13914
|
lines.push(columns.start === 0 ? sliced.replace(/^ {1,3}/, "") : sliced);
|
|
@@ -13691,7 +14016,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13691
14016
|
const result = [...screen];
|
|
13692
14017
|
for (const [row, ranges] of rangesByRow) {
|
|
13693
14018
|
let line = result[row] ?? "";
|
|
13694
|
-
if (
|
|
14019
|
+
if (this.isRenderableImageLine(line)) continue;
|
|
13695
14020
|
const lineWidth = visibleWidth(line);
|
|
13696
14021
|
for (const range of ranges.sort((a, b) => b.startCol - a.startCol)) {
|
|
13697
14022
|
const startCol = Math.min(range.startCol, lineWidth);
|
|
@@ -13759,7 +14084,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13759
14084
|
};
|
|
13760
14085
|
}
|
|
13761
14086
|
return screen.map((line, row) => {
|
|
13762
|
-
if (row < minRow || row > maxRow || row < screenSelection.start.row || row > screenSelection.end.row ||
|
|
14087
|
+
if (row < minRow || row > maxRow || row < screenSelection.start.row || row > screenSelection.end.row || this.isRenderableImageLine(line)) return line;
|
|
13763
14088
|
const lineWidth = visibleWidth(line);
|
|
13764
14089
|
const columns = this.getSelectionColumns(line, row, screenSelection, minColumn, maxColumn);
|
|
13765
14090
|
if (columns.end <= columns.start) return line;
|
|
@@ -13782,7 +14107,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13782
14107
|
const clip = box?.clip;
|
|
13783
14108
|
if (!clip || clip.width <= 0 || clip.height <= 0) return screen;
|
|
13784
14109
|
const row = clip.y + clip.height - 1;
|
|
13785
|
-
if (row >= screen.length ||
|
|
14110
|
+
if (row >= screen.length || this.isRenderableImageLine(screen[row] ?? "")) return screen;
|
|
13786
14111
|
const scrollbarColumn = box ? getScrollbarGeometry(box)?.column : void 0;
|
|
13787
14112
|
const label = truncateToWidth(this.scrollToEndIndicator(), clip.width, "");
|
|
13788
14113
|
const labelWidth = visibleWidth(label);
|
|
@@ -13809,6 +14134,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13809
14134
|
const line = flashLines[row];
|
|
13810
14135
|
const flashWidth = visibleWidth(line);
|
|
13811
14136
|
if (flashWidth === 0) continue;
|
|
14137
|
+
if (this.isRenderableImageLine(result[row] ?? "")) continue;
|
|
13812
14138
|
result[row] = compositeTuiLine(result[row] ?? "", line, width - flashWidth, flashWidth, width);
|
|
13813
14139
|
}
|
|
13814
14140
|
return result;
|
|
@@ -13818,8 +14144,11 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13818
14144
|
const width = Math.max(1, this.terminal.columns);
|
|
13819
14145
|
const height = Math.max(1, this.terminal.rows);
|
|
13820
14146
|
const root = this.layoutRoot ?? this.implicitScrollView;
|
|
13821
|
-
let nextLayout = renderLayoutFrame(root, width, height, () => this.requestRender());
|
|
13822
|
-
if (this.refreshSearch(nextLayout)) nextLayout = renderLayoutFrame(root, width, height, () => this.requestRender());
|
|
14147
|
+
let nextLayout = renderLayoutFrame(root, width, height, () => this.requestRender(), this.sixelScreen);
|
|
14148
|
+
if (this.refreshSearch(nextLayout)) nextLayout = renderLayoutFrame(root, width, height, () => this.requestRender(), this.sixelScreen);
|
|
14149
|
+
if (this.sixelScreen !== void 0) {
|
|
14150
|
+
if (this.sixelScreen.reconcileVisible(this, nextLayout.sixelDemands)) nextLayout = renderLayoutFrame(root, width, height, () => this.requestRender(), this.sixelScreen);
|
|
14151
|
+
}
|
|
13823
14152
|
let screen = nextLayout.lines.map((line) => line.replace(OSC133_ZONE_PREFIX, ""));
|
|
13824
14153
|
screen = this.applySearchHighlights(screen, nextLayout);
|
|
13825
14154
|
screen = this.compositeScrollToEndIndicator(screen, nextLayout, width);
|
|
@@ -13828,14 +14157,25 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13828
14157
|
if (this.overlaySelectionOrigin !== void 0 && !this.isOverlayTextSelectionRegionLive(this.overlaySelectionOrigin)) this.clearTextSelection();
|
|
13829
14158
|
screen = this.applySelection(screen, nextLayout);
|
|
13830
14159
|
screen = this.compositeFlashes(screen, width, height);
|
|
14160
|
+
const sixelRows = this.prepareSixelRows(screen);
|
|
14161
|
+
if (this.sixelScreen !== void 0) {
|
|
14162
|
+
const paintedDemands = nextLayout.sixelDemands.filter((demand) => !this.linesCoveredByOverlay(demand.physicalRow, demand.physicalRow + demand.visibleRows - 1, screen.length));
|
|
14163
|
+
if (paintedDemands.length !== nextLayout.sixelDemands.length) this.sixelScreen.reconcileVisible(this, paintedDemands);
|
|
14164
|
+
}
|
|
13831
14165
|
const cursorPos = this.extractCursorPosition(screen, height);
|
|
13832
14166
|
screen = this.applyLineResets(screen).map((line) => {
|
|
13833
|
-
if (
|
|
14167
|
+
if (this.isRenderableImageLine(line) || visibleWidth(line) <= width) return line;
|
|
13834
14168
|
return sliceByColumn(line, 0, width, true);
|
|
13835
14169
|
});
|
|
13836
14170
|
const fullRedraw = this.previousScreen.length === 0 || this.previousScreenWidth !== width || this.previousScreenHeight !== height;
|
|
13837
14171
|
const changedRows = screen.map((line, row) => line !== this.previousScreen[row]);
|
|
13838
|
-
const imageAnchorsNeedRedraw = screen.some((line, row) => changedRows[row] && (
|
|
14172
|
+
const imageAnchorsNeedRedraw = screen.some((line, row) => changedRows[row] && (this.isRenderableImageLine(line) || this.isRenderableImageLine(this.previousScreen[row] ?? "")));
|
|
14173
|
+
const sixelCoveredRows = /* @__PURE__ */ new Set();
|
|
14174
|
+
for (const declared of [this.previousSixelRows, sixelRows]) for (let row = 0; row < declared.length; row++) {
|
|
14175
|
+
const rows = declared[row] ?? 0;
|
|
14176
|
+
for (let offset = 0; offset < rows; offset++) sixelCoveredRows.add(row + offset);
|
|
14177
|
+
}
|
|
14178
|
+
const sixelNeedRedraw = changedRows.some((changed, row) => changed && (sixelCoveredRows.has(row) || (sixelRows[row] ?? 0) > 0));
|
|
13839
14179
|
const isWezTerm = Boolean(process.env.WEZTERM_PANE) || process.env.TERM_PROGRAM?.toLowerCase() === "wezterm";
|
|
13840
14180
|
const imageCellsNeedRedraw = !imageAnchorsNeedRedraw && isWezTerm && this.imageProtocol === "kitty" && changedRows.some(Boolean) && screen.some((line, row) => {
|
|
13841
14181
|
const placementRows = getKittyImagePlacementRows(line);
|
|
@@ -13875,9 +14215,21 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13875
14215
|
if (!isImageLine(preparedKittyScreen.lines[row] ?? "")) continue;
|
|
13876
14216
|
buffer += `\x1b[${row + 1};1H${preparedKittyScreen.lines[row] ?? ""}`;
|
|
13877
14217
|
}
|
|
13878
|
-
} else
|
|
13879
|
-
if (
|
|
13880
|
-
|
|
14218
|
+
} else {
|
|
14219
|
+
if (sixelNeedRedraw) for (const row of [...sixelCoveredRows].sort((left, right) => left - right)) {
|
|
14220
|
+
if (row < 0 || row >= height) continue;
|
|
14221
|
+
buffer += `\x1b[${row + 1};1H\x1b[2K`;
|
|
14222
|
+
}
|
|
14223
|
+
for (let row = 0; row < height; row++) {
|
|
14224
|
+
const clearedBySixel = sixelNeedRedraw && sixelCoveredRows.has(row);
|
|
14225
|
+
if (!fullRedraw && !imagesNeedRedraw && !clearedBySixel && screen[row] === this.previousScreen[row]) continue;
|
|
14226
|
+
if ((sixelRows[row] ?? 0) > 0) continue;
|
|
14227
|
+
buffer += `\x1b[${row + 1};1H\x1b[2K${preparedKittyScreen.lines[row] ?? ""}`;
|
|
14228
|
+
}
|
|
14229
|
+
if (fullRedraw || sixelNeedRedraw) for (let row = 0; row < height; row++) {
|
|
14230
|
+
if ((sixelRows[row] ?? 0) === 0) continue;
|
|
14231
|
+
buffer += `\x1b[${row + 1};1H${screen[row]}`;
|
|
14232
|
+
}
|
|
13881
14233
|
}
|
|
13882
14234
|
if (cursorPos) {
|
|
13883
14235
|
buffer += `\x1b[${cursorPos.row + 1};${Math.min(width, cursorPos.col) + 1}H`;
|
|
@@ -13885,7 +14237,9 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
13885
14237
|
} else buffer += "\x1B[?25l";
|
|
13886
14238
|
buffer += END_SYNCHRONIZED_OUTPUT;
|
|
13887
14239
|
this.terminal.write(buffer);
|
|
14240
|
+
this.commitSixelFrame(nextLayout, screen, changedRows, fullRedraw || sixelNeedRedraw);
|
|
13888
14241
|
this.previousScreen = screen;
|
|
14242
|
+
this.previousSixelRows = sixelRows;
|
|
13889
14243
|
this.previousScreenWidth = width;
|
|
13890
14244
|
this.previousScreenHeight = height;
|
|
13891
14245
|
this.currentLayout = nextLayout;
|
|
@@ -13989,12 +14343,36 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
13989
14343
|
/** Per-line kitty image ids of the previous frame, aligned with previousRawLines. */
|
|
13990
14344
|
previousLineImageIds = [];
|
|
13991
14345
|
previousKittyImageIds = /* @__PURE__ */ new Set();
|
|
14346
|
+
/**
|
|
14347
|
+
* Declared image rows of the previous frame, aligned with
|
|
14348
|
+
* {@link previousLines}: a Kitty `r=`/registered placement row count, or a
|
|
14349
|
+
* trusted SIXEL footprint. Cached instead of re-deriving from the line,
|
|
14350
|
+
* because a raster whose component was disposed is no longer registered —
|
|
14351
|
+
* the OLD block must still be erased (X073).
|
|
14352
|
+
*/
|
|
14353
|
+
previousLineImageRows = [];
|
|
14354
|
+
/**
|
|
14355
|
+
* Per-line TRUSTED SIXEL footprint height of the previous frame (0 = no
|
|
14356
|
+
* SIXEL block). Unlike the Kitty row count this is exact, so it never has to
|
|
14357
|
+
* be re-derived by scanning blank body rows — a scan would collapse under an
|
|
14358
|
+
* overlay or a text row that landed inside the block. (X073.)
|
|
14359
|
+
*/
|
|
14360
|
+
previousLineSixelRows = [];
|
|
13992
14361
|
previousWidth = 0;
|
|
13993
14362
|
previousHeight = 0;
|
|
13994
14363
|
cursorRow = 0;
|
|
13995
14364
|
hardwareCursorRow = 0;
|
|
13996
14365
|
maxLinesRendered = 0;
|
|
13997
14366
|
previousViewportTop = 0;
|
|
14367
|
+
/** Per-row token -> DCS the current frame materialized (X073). */
|
|
14368
|
+
sixelFrameRasters = /* @__PURE__ */ new Map();
|
|
14369
|
+
/**
|
|
14370
|
+
* @param sixelScreen - the Client-local SIXEL trust port (X072). Absent for
|
|
14371
|
+
* every non-SIXEL terminal, and then this screen is byte-for-byte upstream.
|
|
14372
|
+
*/
|
|
14373
|
+
constructor(terminal, showHardwareCursor, logDirectory, sixelScreen) {
|
|
14374
|
+
super(terminal, showHardwareCursor, logDirectory, sixelScreen);
|
|
14375
|
+
}
|
|
13998
14376
|
captureRenderState() {
|
|
13999
14377
|
return {
|
|
14000
14378
|
previousLines: [...this.previousLines],
|
|
@@ -14007,9 +14385,11 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
14007
14385
|
};
|
|
14008
14386
|
}
|
|
14009
14387
|
restoreRenderState(state) {
|
|
14010
|
-
this.previousLines = state.previousLines.map((line) =>
|
|
14388
|
+
this.previousLines = state.previousLines.map((line) => this.isRenderableImageLine(line) ? "" : line);
|
|
14011
14389
|
this.previousRawLines = [];
|
|
14012
14390
|
this.previousLineImageIds = [];
|
|
14391
|
+
this.previousLineImageRows = [];
|
|
14392
|
+
this.previousLineSixelRows = [];
|
|
14013
14393
|
this.previousKittyImageIds = /* @__PURE__ */ new Set();
|
|
14014
14394
|
this.previousWidth = state.previousWidth;
|
|
14015
14395
|
this.previousHeight = state.previousHeight;
|
|
@@ -14022,6 +14402,8 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
14022
14402
|
this.previousLines = [];
|
|
14023
14403
|
this.previousRawLines = [];
|
|
14024
14404
|
this.previousLineImageIds = [];
|
|
14405
|
+
this.previousLineImageRows = [];
|
|
14406
|
+
this.previousLineSixelRows = [];
|
|
14025
14407
|
this.previousWidth = -1;
|
|
14026
14408
|
this.previousHeight = -1;
|
|
14027
14409
|
this.cursorRow = 0;
|
|
@@ -14047,33 +14429,191 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
14047
14429
|
for (const id of ids) buffer += deleteKittyImage(id);
|
|
14048
14430
|
return buffer;
|
|
14049
14431
|
}
|
|
14050
|
-
|
|
14051
|
-
|
|
14432
|
+
/**
|
|
14433
|
+
* Project the frame's candidate markers into what this Screen may write.
|
|
14434
|
+
*
|
|
14435
|
+
* The component tree only ever emits an inert candidate marker per block; the
|
|
14436
|
+
* final viewport decides which occurrences are granted residency. Rows above
|
|
14437
|
+
* the viewport keep their previous physical line when the SAME occurrence is
|
|
14438
|
+
* still there: a residency-only change must not rewrite committed scrollback
|
|
14439
|
+
* (a rewrite above the viewport would force `fullRender(true)` and `3J`).
|
|
14440
|
+
*/
|
|
14441
|
+
projectSixelCandidates(rawLines, height, viewportTop, width, reconcile) {
|
|
14442
|
+
const port = this.sixelScreen;
|
|
14443
|
+
const lines = [...rawLines];
|
|
14444
|
+
const rasters = /* @__PURE__ */ new Map();
|
|
14445
|
+
const preserved = /* @__PURE__ */ new Set();
|
|
14446
|
+
if (port === void 0) return {
|
|
14447
|
+
lines,
|
|
14448
|
+
rasters,
|
|
14449
|
+
preserved,
|
|
14450
|
+
recompose: false
|
|
14451
|
+
};
|
|
14452
|
+
const visible = [];
|
|
14453
|
+
for (let row = viewportTop; row < Math.min(rawLines.length, viewportTop + height); row += 1) {
|
|
14454
|
+
const info = port.candidate(rawLines[row] ?? "");
|
|
14455
|
+
if (info === void 0) continue;
|
|
14456
|
+
const visibleRows = Math.min(info.layoutRows, viewportTop + height - row);
|
|
14457
|
+
if (visibleRows <= 0) continue;
|
|
14458
|
+
visible.push({
|
|
14459
|
+
row,
|
|
14460
|
+
fallback: info.fallback,
|
|
14461
|
+
cropTopRows: 0,
|
|
14462
|
+
visibleRows
|
|
14463
|
+
});
|
|
14464
|
+
}
|
|
14465
|
+
visible.sort((left, right) => right.row - left.row);
|
|
14466
|
+
if (reconcile) {
|
|
14467
|
+
if (port.reconcileVisible(this, visible.map((entry) => ({
|
|
14468
|
+
line: rawLines[entry.row],
|
|
14469
|
+
cropTopRows: entry.cropTopRows,
|
|
14470
|
+
visibleRows: entry.visibleRows,
|
|
14471
|
+
physicalRow: entry.row
|
|
14472
|
+
})))) return {
|
|
14473
|
+
lines,
|
|
14474
|
+
rasters,
|
|
14475
|
+
preserved,
|
|
14476
|
+
recompose: true
|
|
14477
|
+
};
|
|
14478
|
+
}
|
|
14479
|
+
for (const entry of visible) {
|
|
14480
|
+
const token = rawLines[entry.row];
|
|
14481
|
+
const dcs = port.materialize(token, entry.cropTopRows, entry.visibleRows);
|
|
14482
|
+
if (dcs === void 0) {
|
|
14483
|
+
lines[entry.row] = entry.fallback;
|
|
14484
|
+
continue;
|
|
14485
|
+
}
|
|
14486
|
+
lines[entry.row] = dcs;
|
|
14487
|
+
const footprint = port.footprint(dcs);
|
|
14488
|
+
rasters.set(entry.row, {
|
|
14489
|
+
line: token,
|
|
14490
|
+
dcs,
|
|
14491
|
+
cropTopRows: entry.cropTopRows,
|
|
14492
|
+
visibleRows: footprint?.rows ?? entry.visibleRows
|
|
14493
|
+
});
|
|
14494
|
+
}
|
|
14495
|
+
for (let row = 0; row < viewportTop && row < rawLines.length; row += 1) {
|
|
14496
|
+
const token = rawLines[row] ?? "";
|
|
14497
|
+
const info = port.candidate(token);
|
|
14498
|
+
if (info === void 0) continue;
|
|
14499
|
+
const previous = this.previousLines[row] ?? "";
|
|
14500
|
+
if (this.previousRawLines[row] === token && this.sixelFootprint(previous) !== void 0) {
|
|
14501
|
+
lines[row] = previous;
|
|
14502
|
+
preserved.add(row);
|
|
14503
|
+
} else if (this.previousRawLines[row] === token) {
|
|
14504
|
+
let fallback = info.fallback;
|
|
14505
|
+
if (visibleWidth(fallback) > width) fallback = sliceByColumn(fallback, 0, width, true);
|
|
14506
|
+
fallback = normalizeTerminalOutput(fallback) + SEGMENT_RESET;
|
|
14507
|
+
this.previousLines[row] = fallback;
|
|
14508
|
+
this.previousLineSixelRows[row] = 0;
|
|
14509
|
+
this.previousLineImageRows[row] = 0;
|
|
14510
|
+
this.previousLineImageIds[row] = [];
|
|
14511
|
+
lines[row] = fallback;
|
|
14512
|
+
preserved.add(row);
|
|
14513
|
+
} else lines[row] = info.fallback;
|
|
14514
|
+
}
|
|
14515
|
+
return {
|
|
14516
|
+
lines,
|
|
14517
|
+
rasters,
|
|
14518
|
+
preserved,
|
|
14519
|
+
recompose: false
|
|
14520
|
+
};
|
|
14521
|
+
}
|
|
14522
|
+
/**
|
|
14523
|
+
* Report the frame's physical raster set to the owner after a real write.
|
|
14524
|
+
*
|
|
14525
|
+
* `emitted` rasters are the ones this frame materialized; a row the diff kept
|
|
14526
|
+
* (byte-identical to the previous frame) still shows its old pixels and pins
|
|
14527
|
+
* its occurrence. Rows above the viewport are never reported: their pixels are
|
|
14528
|
+
* native scrollback, not a frame reference.
|
|
14529
|
+
*/
|
|
14530
|
+
commitSixelFrame(frameLines, viewportTop, height) {
|
|
14531
|
+
const port = this.sixelScreen;
|
|
14532
|
+
if (port === void 0) return;
|
|
14533
|
+
const retained = [];
|
|
14534
|
+
for (const row of [...this.sixelFrameRasters.keys()].sort((left, right) => right - left)) {
|
|
14535
|
+
const raster = this.sixelFrameRasters.get(row);
|
|
14536
|
+
if (row < viewportTop || row >= viewportTop + height) continue;
|
|
14537
|
+
retained.push({
|
|
14538
|
+
...raster,
|
|
14539
|
+
emitted: true
|
|
14540
|
+
});
|
|
14541
|
+
}
|
|
14542
|
+
const last = Math.min(frameLines.length, viewportTop + height) - 1;
|
|
14543
|
+
for (let row = last; row >= viewportTop; row -= 1) {
|
|
14544
|
+
if (this.sixelFrameRasters.has(row)) continue;
|
|
14545
|
+
const token = this.previousRawLines[row];
|
|
14546
|
+
if (token === void 0 || port.candidate(token) === void 0) continue;
|
|
14547
|
+
const previous = this.previousLines[row];
|
|
14548
|
+
if (previous === void 0 || previous !== frameLines[row]) continue;
|
|
14549
|
+
const footprint = port.footprint(previous);
|
|
14550
|
+
if (footprint === void 0) continue;
|
|
14551
|
+
retained.push({
|
|
14552
|
+
line: token,
|
|
14553
|
+
dcs: previous,
|
|
14554
|
+
cropTopRows: 0,
|
|
14555
|
+
visibleRows: footprint.rows,
|
|
14556
|
+
emitted: false
|
|
14557
|
+
});
|
|
14558
|
+
}
|
|
14559
|
+
this.sixelFrameRasters = /* @__PURE__ */ new Map();
|
|
14560
|
+
port.framePainted(this, retained);
|
|
14561
|
+
}
|
|
14562
|
+
/**
|
|
14563
|
+
* The image rows one line DECLARES: a Kitty `r=`/registered placement, or a
|
|
14564
|
+
* trusted SIXEL footprint. `0` for a non-image line, so callers can decide
|
|
14565
|
+
* "is an image" and "how tall" from one number.
|
|
14566
|
+
*/
|
|
14567
|
+
declaredImageRows(line) {
|
|
14568
|
+
const candidate = this.sixelScreen?.candidate(line);
|
|
14569
|
+
if (candidate !== void 0) return candidate.layoutRows;
|
|
14570
|
+
const footprint = this.sixelFootprint(line);
|
|
14571
|
+
if (footprint !== void 0) return footprint.rows;
|
|
14572
|
+
return isImageLine(line) ? extractKittyImageRows(line) : 0;
|
|
14573
|
+
}
|
|
14574
|
+
/** The trusted SIXEL footprint height of one line, or 0 when it is not a
|
|
14575
|
+
* registered raster. */
|
|
14576
|
+
sixelBlockRows(line) {
|
|
14577
|
+
const candidate = this.sixelScreen?.candidate(line);
|
|
14578
|
+
if (candidate !== void 0) return candidate.layoutRows;
|
|
14579
|
+
return this.sixelFootprint(line)?.rows ?? 0;
|
|
14580
|
+
}
|
|
14581
|
+
/**
|
|
14582
|
+
* The rows an image block really occupies in `lines`, starting at `index`.
|
|
14583
|
+
*
|
|
14584
|
+
* `declared` is the per-line declared row count of the SAME frame (cached for
|
|
14585
|
+
* the previous frame), so a raster that is no longer registered still
|
|
14586
|
+
* reports its real old height. The scan stops at the first body row another
|
|
14587
|
+
* image owns or at the first row with cell content.
|
|
14588
|
+
*/
|
|
14589
|
+
getImageReservedRows(lines, declared, sixel, index, maxIndex = lines.length - 1) {
|
|
14590
|
+
const rows = declared[index] ?? 0;
|
|
14052
14591
|
if (rows <= 1) return 1;
|
|
14053
14592
|
const maxRows = Math.min(rows, maxIndex - index + 1, lines.length - index);
|
|
14593
|
+
if ((sixel[index] ?? 0) > 0) return maxRows;
|
|
14054
14594
|
let reservedRows = 1;
|
|
14055
14595
|
while (reservedRows < maxRows) {
|
|
14056
14596
|
const line = lines[index + reservedRows] ?? "";
|
|
14057
|
-
if (
|
|
14597
|
+
if ((declared[index + reservedRows] ?? 0) > 0 || visibleWidth(line) > 0) break;
|
|
14058
14598
|
reservedRows++;
|
|
14059
14599
|
}
|
|
14060
14600
|
return reservedRows;
|
|
14061
14601
|
}
|
|
14062
|
-
|
|
14602
|
+
expandChangedRangeForImages(firstChanged, lastChanged, newLines, newLineImageRows, newLineSixelRows) {
|
|
14063
14603
|
let expandedFirstChanged = firstChanged;
|
|
14064
14604
|
let expandedLastChanged = lastChanged;
|
|
14065
|
-
const expandForLines = (lines,
|
|
14605
|
+
const expandForLines = (lines, declared, sixel) => {
|
|
14066
14606
|
for (let i = 0; i < lines.length; i++) {
|
|
14067
|
-
if ((
|
|
14068
|
-
const blockEnd = i + this.
|
|
14607
|
+
if ((declared[i] ?? 0) === 0) continue;
|
|
14608
|
+
const blockEnd = i + this.getImageReservedRows(lines, declared, sixel, i) - 1;
|
|
14069
14609
|
if (i >= firstChanged || i <= lastChanged && blockEnd >= firstChanged) {
|
|
14070
14610
|
expandedFirstChanged = Math.min(expandedFirstChanged, i);
|
|
14071
14611
|
expandedLastChanged = Math.max(expandedLastChanged, blockEnd);
|
|
14072
14612
|
}
|
|
14073
14613
|
}
|
|
14074
14614
|
};
|
|
14075
|
-
expandForLines(this.previousLines, this.
|
|
14076
|
-
expandForLines(newLines,
|
|
14615
|
+
expandForLines(this.previousLines, this.previousLineImageRows, this.previousLineSixelRows);
|
|
14616
|
+
expandForLines(newLines, newLineImageRows, newLineSixelRows);
|
|
14077
14617
|
return {
|
|
14078
14618
|
firstChanged: expandedFirstChanged,
|
|
14079
14619
|
lastChanged: expandedLastChanged
|
|
@@ -14086,6 +14626,73 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
14086
14626
|
for (let i = firstChanged; i <= maxLine; i++) for (const id of this.previousLineImageIds[i] ?? EMPTY_IMAGE_IDS) ids.add(id);
|
|
14087
14627
|
return this.deleteKittyImages(ids);
|
|
14088
14628
|
}
|
|
14629
|
+
/**
|
|
14630
|
+
* Drop the DCS of every trusted SIXEL block that a visible overlay paints
|
|
14631
|
+
* over (X073).
|
|
14632
|
+
*
|
|
14633
|
+
* One raster is one command covering its whole footprint, so "clear only the
|
|
14634
|
+
* row the overlay touched" is impossible: the pixels would either cover the
|
|
14635
|
+
* overlay text or leave a ghost. The block therefore yields this frame — the
|
|
14636
|
+
* component's own identity row above it still names the attachment — and the
|
|
14637
|
+
* next frame after the overlay closes restores it, because the anchor line
|
|
14638
|
+
* changes and the block re-enters the changed range.
|
|
14639
|
+
*/
|
|
14640
|
+
suppressOverlayCoveredSixelBlocks(lines) {
|
|
14641
|
+
for (let i = 0; i < lines.length; i++) {
|
|
14642
|
+
const rows = this.sixelBlockRows(lines[i] ?? "");
|
|
14643
|
+
if (rows === 0) continue;
|
|
14644
|
+
if (!this.linesCoveredByOverlay(i, i + rows - 1, lines.length)) continue;
|
|
14645
|
+
lines[i] = "";
|
|
14646
|
+
}
|
|
14647
|
+
}
|
|
14648
|
+
/**
|
|
14649
|
+
* Write every deferred trusted SIXEL anchor at its own absolute row, then
|
|
14650
|
+
* leave the cursor on `finalCursorRow`.
|
|
14651
|
+
*
|
|
14652
|
+
* `CSI 999A` (cursor up, clamped at the top margin) is the one deterministic
|
|
14653
|
+
* origin the main screen has: it cannot scroll and it lands on the physical
|
|
14654
|
+
* top row, which this screen's bookkeeping maps to buffer row `viewportTop`.
|
|
14655
|
+
* From there a bounded `CSI nB` reaches any visible row exactly. Each DCS is
|
|
14656
|
+
* wrapped in DECSC/DECRC because its post-command cursor position is
|
|
14657
|
+
* terminal-defined, never assumed to be zero.
|
|
14658
|
+
*
|
|
14659
|
+
* Returns false when an anchor is not inside the painted viewport; the caller
|
|
14660
|
+
* then falls back to a full redraw instead of painting outside it.
|
|
14661
|
+
*/
|
|
14662
|
+
writeDeferredSixelAnchors(output, anchors, lines, viewportTop, height, finalCursorRow) {
|
|
14663
|
+
for (const anchor of anchors) {
|
|
14664
|
+
const screenRow = anchor - viewportTop;
|
|
14665
|
+
if (screenRow < 0 || screenRow >= height) return false;
|
|
14666
|
+
output.append("\x1B[999A");
|
|
14667
|
+
if (screenRow > 0) output.append(`\x1b[${screenRow}B`);
|
|
14668
|
+
output.append("\x1B7");
|
|
14669
|
+
output.append(lines[anchor] ?? "");
|
|
14670
|
+
output.append("\x1B8");
|
|
14671
|
+
}
|
|
14672
|
+
const endScreenRow = Math.max(0, Math.min(height - 1, finalCursorRow - viewportTop));
|
|
14673
|
+
output.append("\x1B[999A");
|
|
14674
|
+
if (endScreenRow > 0) output.append(`\x1b[${endScreenRow}B`);
|
|
14675
|
+
output.append("\r");
|
|
14676
|
+
return true;
|
|
14677
|
+
}
|
|
14678
|
+
/**
|
|
14679
|
+
* Write one image anchor at the cursor's current row.
|
|
14680
|
+
*
|
|
14681
|
+
* A Kitty placement leaves the cursor where it was; a SIXEL DCS does not, and
|
|
14682
|
+
* its post-command position is terminal-defined. The anchor is therefore
|
|
14683
|
+
* SAVED before the command and RESTORED after it (DECSC/DECRC), and the
|
|
14684
|
+
* caller then moves the cursor explicitly — "the DCS left it at 0" is never
|
|
14685
|
+
* assumed. (dsh-pi-tui divergence X073.)
|
|
14686
|
+
*/
|
|
14687
|
+
appendImageCommand(output, line, sixel) {
|
|
14688
|
+
if (!sixel) {
|
|
14689
|
+
output.append(line);
|
|
14690
|
+
return;
|
|
14691
|
+
}
|
|
14692
|
+
output.append("\x1B7");
|
|
14693
|
+
output.append(line);
|
|
14694
|
+
output.append("\x1B8");
|
|
14695
|
+
}
|
|
14089
14696
|
doRender() {
|
|
14090
14697
|
if (this.stopped) return;
|
|
14091
14698
|
const width = this.terminal.columns;
|
|
@@ -14100,29 +14707,46 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
14100
14707
|
const currentScreenRow = hardwareCursorRow - prevViewportTop;
|
|
14101
14708
|
return targetRow - viewportTop - currentScreenRow;
|
|
14102
14709
|
};
|
|
14103
|
-
let
|
|
14104
|
-
if (this.hasOverlayEntries)
|
|
14710
|
+
let rawLines = this.render(width);
|
|
14711
|
+
if (this.hasOverlayEntries) {
|
|
14712
|
+
rawLines = this.compositeOverlays(rawLines, width, height);
|
|
14713
|
+
this.suppressOverlayCoveredSixelBlocks(rawLines);
|
|
14714
|
+
}
|
|
14715
|
+
const frameViewportTop = Math.max(0, rawLines.length - height);
|
|
14716
|
+
let projection = this.projectSixelCandidates(rawLines, height, frameViewportTop, width, true);
|
|
14717
|
+
if (projection.recompose) projection = this.projectSixelCandidates(rawLines, height, frameViewportTop, width, false);
|
|
14718
|
+
this.sixelFrameRasters = projection.rasters;
|
|
14719
|
+
const preservedRows = projection.preserved;
|
|
14720
|
+
let newLines = projection.lines;
|
|
14105
14721
|
const cursorPos = this.extractCursorPosition(newLines, height);
|
|
14106
|
-
const rawLines = newLines;
|
|
14107
14722
|
const reuseProcessed = !widthChanged && this.previousRawLines.length > 0;
|
|
14108
|
-
const processedLines = new Array(
|
|
14109
|
-
const lineImageIds = new Array(
|
|
14110
|
-
|
|
14111
|
-
|
|
14112
|
-
|
|
14723
|
+
const processedLines = new Array(newLines.length);
|
|
14724
|
+
const lineImageIds = new Array(newLines.length);
|
|
14725
|
+
const lineImageRows = new Array(newLines.length);
|
|
14726
|
+
const lineSixelRows = new Array(newLines.length);
|
|
14727
|
+
for (let i = 0; i < newLines.length; i++) {
|
|
14728
|
+
const marker = rawLines[i] ?? "";
|
|
14729
|
+
const isCandidate = this.sixelScreen?.candidate(marker) !== void 0;
|
|
14730
|
+
if (preservedRows.has(i) || !isCandidate && reuseProcessed && marker === this.previousRawLines[i]) {
|
|
14113
14731
|
processedLines[i] = this.previousLines[i];
|
|
14114
14732
|
lineImageIds[i] = this.previousLineImageIds[i];
|
|
14733
|
+
lineImageRows[i] = this.previousLineImageRows[i];
|
|
14734
|
+
lineSixelRows[i] = this.previousLineSixelRows[i];
|
|
14115
14735
|
continue;
|
|
14116
14736
|
}
|
|
14117
|
-
let line =
|
|
14737
|
+
let line = newLines[i];
|
|
14118
14738
|
let imageIds = EMPTY_IMAGE_IDS;
|
|
14119
|
-
|
|
14739
|
+
const sixelRows = this.sixelBlockRows(line);
|
|
14740
|
+
const declaredImageRows = this.declaredImageRows(line);
|
|
14741
|
+
if (declaredImageRows > 0) imageIds = extractKittyImageIds(line);
|
|
14120
14742
|
else {
|
|
14121
14743
|
if ((asciiVisibleWidthEarlyExit(line, width) ?? visibleWidth(line)) > width) line = sliceByColumn(line, 0, width, true);
|
|
14122
14744
|
line = normalizeTerminalOutput(line) + SEGMENT_RESET;
|
|
14123
14745
|
}
|
|
14124
14746
|
processedLines[i] = line;
|
|
14125
14747
|
lineImageIds[i] = imageIds;
|
|
14748
|
+
lineImageRows[i] = declaredImageRows;
|
|
14749
|
+
lineSixelRows[i] = sixelRows;
|
|
14126
14750
|
}
|
|
14127
14751
|
newLines = processedLines;
|
|
14128
14752
|
const fullRender = (clear) => {
|
|
@@ -14136,19 +14760,21 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
14136
14760
|
for (let i = 0; i < newLines.length; i++) {
|
|
14137
14761
|
if (i > 0) output.append("\r\n");
|
|
14138
14762
|
const line = newLines[i];
|
|
14139
|
-
const
|
|
14763
|
+
const isSixel = (lineSixelRows[i] ?? 0) > 0;
|
|
14764
|
+
const imageReservedRows = isSixel || isImageLine(line) ? this.getImageReservedRows(newLines, lineImageRows, lineSixelRows, i) : 1;
|
|
14140
14765
|
if (imageReservedRows > 1 && imageReservedRows <= height) {
|
|
14141
14766
|
for (let row = 1; row < imageReservedRows; row++) output.append("\r\n");
|
|
14142
14767
|
output.append(`\x1b[${imageReservedRows - 1}A`);
|
|
14143
|
-
|
|
14768
|
+
this.appendImageCommand(output, line, isSixel);
|
|
14144
14769
|
output.append(`\x1b[${imageReservedRows - 1}B`);
|
|
14145
14770
|
i += imageReservedRows - 1;
|
|
14146
14771
|
continue;
|
|
14147
14772
|
}
|
|
14148
|
-
|
|
14773
|
+
this.appendImageCommand(output, line, isSixel);
|
|
14149
14774
|
}
|
|
14150
14775
|
output.append("\x1B[?2026l");
|
|
14151
14776
|
output.flush();
|
|
14777
|
+
this.commitSixelFrame(newLines, frameViewportTop, height);
|
|
14152
14778
|
this.cursorRow = Math.max(0, newLines.length - 1);
|
|
14153
14779
|
this.hardwareCursorRow = this.cursorRow;
|
|
14154
14780
|
if (clear) this.maxLinesRendered = newLines.length;
|
|
@@ -14159,6 +14785,8 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
14159
14785
|
this.previousLines = newLines;
|
|
14160
14786
|
this.previousRawLines = rawLines;
|
|
14161
14787
|
this.previousLineImageIds = lineImageIds;
|
|
14788
|
+
this.previousLineImageRows = lineImageRows;
|
|
14789
|
+
this.previousLineSixelRows = lineSixelRows;
|
|
14162
14790
|
this.previousKittyImageIds = this.unionKittyImageIds(lineImageIds);
|
|
14163
14791
|
this.previousWidth = width;
|
|
14164
14792
|
this.previousHeight = height;
|
|
@@ -14204,7 +14832,7 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
14204
14832
|
lastChanged = newLines.length - 1;
|
|
14205
14833
|
}
|
|
14206
14834
|
if (firstChanged !== -1) {
|
|
14207
|
-
const expandedRange = this.
|
|
14835
|
+
const expandedRange = this.expandChangedRangeForImages(firstChanged, lastChanged, newLines, lineImageRows, lineSixelRows);
|
|
14208
14836
|
firstChanged = expandedRange.firstChanged;
|
|
14209
14837
|
lastChanged = expandedRange.lastChanged;
|
|
14210
14838
|
}
|
|
@@ -14215,6 +14843,8 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
14215
14843
|
this.previousHeight = height;
|
|
14216
14844
|
this.previousRawLines = rawLines;
|
|
14217
14845
|
this.previousLineImageIds = lineImageIds;
|
|
14846
|
+
this.previousLineImageRows = lineImageRows;
|
|
14847
|
+
this.previousLineSixelRows = lineSixelRows;
|
|
14218
14848
|
return;
|
|
14219
14849
|
}
|
|
14220
14850
|
if (firstChanged >= newLines.length) {
|
|
@@ -14248,6 +14878,7 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
14248
14878
|
if (moveBack > 0) output.append(`\x1b[${moveBack}A`);
|
|
14249
14879
|
output.append("\x1B[?2026l");
|
|
14250
14880
|
output.flush();
|
|
14881
|
+
this.commitSixelFrame(newLines, frameViewportTop, height);
|
|
14251
14882
|
this.cursorRow = targetRow;
|
|
14252
14883
|
this.hardwareCursorRow = targetRow;
|
|
14253
14884
|
}
|
|
@@ -14255,6 +14886,8 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
14255
14886
|
this.previousLines = newLines;
|
|
14256
14887
|
this.previousRawLines = rawLines;
|
|
14257
14888
|
this.previousLineImageIds = lineImageIds;
|
|
14889
|
+
this.previousLineImageRows = lineImageRows;
|
|
14890
|
+
this.previousLineSixelRows = lineSixelRows;
|
|
14258
14891
|
this.previousKittyImageIds = this.unionKittyImageIds(lineImageIds);
|
|
14259
14892
|
this.previousWidth = width;
|
|
14260
14893
|
this.previousHeight = height;
|
|
@@ -14286,22 +14919,25 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
14286
14919
|
else if (lineDiff < 0) output.append(`\x1b[${-lineDiff}A`);
|
|
14287
14920
|
output.append(appendStart ? "\r\n" : "\r");
|
|
14288
14921
|
const renderEnd = Math.min(lastChanged, newLines.length - 1);
|
|
14922
|
+
const deferredSixelAnchors = [];
|
|
14289
14923
|
for (let i = firstChanged; i <= renderEnd; i++) {
|
|
14290
14924
|
if (i > firstChanged) output.append("\r\n");
|
|
14291
14925
|
const line = newLines[i];
|
|
14292
|
-
const
|
|
14293
|
-
const
|
|
14926
|
+
const isSixel = (lineSixelRows[i] ?? 0) > 0;
|
|
14927
|
+
const isImage = isSixel || isImageLine(line);
|
|
14928
|
+
const imageReservedRows = isImage ? this.getImageReservedRows(newLines, lineImageRows, lineSixelRows, i, renderEnd) : 1;
|
|
14294
14929
|
if (imageReservedRows > 1) {
|
|
14295
14930
|
const imageStartScreenRow = i - viewportTop;
|
|
14296
14931
|
if (imageStartScreenRow < 0 || imageStartScreenRow + imageReservedRows > height) {
|
|
14297
|
-
logRedraw(`
|
|
14932
|
+
logRedraw(`image pre-clear would scroll (${imageStartScreenRow} + ${imageReservedRows} > ${height})`);
|
|
14298
14933
|
fullRender(true);
|
|
14299
14934
|
return;
|
|
14300
14935
|
}
|
|
14301
14936
|
output.append("\x1B[2K");
|
|
14302
14937
|
for (let row = 1; row < imageReservedRows; row++) output.append("\r\n\x1B[2K");
|
|
14303
14938
|
output.append(`\x1b[${imageReservedRows - 1}A`);
|
|
14304
|
-
|
|
14939
|
+
if (isSixel) deferredSixelAnchors.push(i);
|
|
14940
|
+
else output.append(line);
|
|
14305
14941
|
output.append(`\x1b[${imageReservedRows - 1}B`);
|
|
14306
14942
|
i += imageReservedRows - 1;
|
|
14307
14943
|
continue;
|
|
@@ -14331,7 +14967,8 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
14331
14967
|
].join("\n");
|
|
14332
14968
|
throw new Error(errorMsg);
|
|
14333
14969
|
}
|
|
14334
|
-
|
|
14970
|
+
if (isSixel) deferredSixelAnchors.push(i);
|
|
14971
|
+
else output.append(line);
|
|
14335
14972
|
}
|
|
14336
14973
|
let finalCursorRow = renderEnd;
|
|
14337
14974
|
if (this.previousLines.length > newLines.length) {
|
|
@@ -14344,6 +14981,13 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
14344
14981
|
for (let i = newLines.length; i < this.previousLines.length; i++) output.append("\r\n\x1B[2K");
|
|
14345
14982
|
output.append(`\x1b[${extraLines}A`);
|
|
14346
14983
|
}
|
|
14984
|
+
if (deferredSixelAnchors.length > 0) {
|
|
14985
|
+
if (!this.writeDeferredSixelAnchors(output, deferredSixelAnchors, newLines, viewportTop, height, finalCursorRow)) {
|
|
14986
|
+
logRedraw("deferred SIXEL anchor is not inside the painted viewport");
|
|
14987
|
+
fullRender(true);
|
|
14988
|
+
return;
|
|
14989
|
+
}
|
|
14990
|
+
}
|
|
14347
14991
|
output.append("\x1B[?2026l");
|
|
14348
14992
|
if (process.env.PI_TUI_DEBUG === "1") {
|
|
14349
14993
|
const debugDir = "/tmp/tui";
|
|
@@ -14374,6 +15018,7 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
14374
15018
|
fs.writeFileSync(debugPath, debugData);
|
|
14375
15019
|
}
|
|
14376
15020
|
output.flush();
|
|
15021
|
+
this.commitSixelFrame(newLines, frameViewportTop, height);
|
|
14377
15022
|
this.cursorRow = Math.max(0, newLines.length - 1);
|
|
14378
15023
|
this.hardwareCursorRow = finalCursorRow;
|
|
14379
15024
|
this.maxLinesRendered = Math.max(this.maxLinesRendered, newLines.length);
|
|
@@ -14382,6 +15027,8 @@ var TuiMainScreen = class extends TuiBase {
|
|
|
14382
15027
|
this.previousLines = newLines;
|
|
14383
15028
|
this.previousRawLines = rawLines;
|
|
14384
15029
|
this.previousLineImageIds = lineImageIds;
|
|
15030
|
+
this.previousLineImageRows = lineImageRows;
|
|
15031
|
+
this.previousLineSixelRows = lineSixelRows;
|
|
14385
15032
|
this.previousKittyImageIds = this.unionKittyImageIds(lineImageIds);
|
|
14386
15033
|
this.previousWidth = width;
|
|
14387
15034
|
this.previousHeight = height;
|
|
@@ -15917,7 +16564,8 @@ const SESSIONLESS_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
15917
16564
|
"statusline",
|
|
15918
16565
|
"status",
|
|
15919
16566
|
"view-image",
|
|
15920
|
-
"deliverables"
|
|
16567
|
+
"deliverables",
|
|
16568
|
+
"reload-client"
|
|
15921
16569
|
]);
|
|
15922
16570
|
/**
|
|
15923
16571
|
* The LOCAL-execute command set (PR5 v2 §1C-6 narrows its semantic role):
|
|
@@ -15978,7 +16626,8 @@ const LOCAL_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
15978
16626
|
"yolo",
|
|
15979
16627
|
"view-image",
|
|
15980
16628
|
"deliverables",
|
|
15981
|
-
"statusline"
|
|
16629
|
+
"statusline",
|
|
16630
|
+
"reload-client"
|
|
15982
16631
|
]);
|
|
15983
16632
|
/**
|
|
15984
16633
|
* The STATIC host-owned command catalog (P1-04): the ownership sets
|
|
@@ -16158,6 +16807,47 @@ function shouldConsumeAdvertisedMiss(execution, wasAdvertised) {
|
|
|
16158
16807
|
function isPlainExitPrompt(text) {
|
|
16159
16808
|
return text.trim() === "exit";
|
|
16160
16809
|
}
|
|
16810
|
+
/**
|
|
16811
|
+
* The TUI-local commands whose OWN handler performs no persistent Host write
|
|
16812
|
+
* (they read/browse/stage locally, open a read-only panel, or are the reload
|
|
16813
|
+
* command itself). Their execution never holds the accepted-command reload
|
|
16814
|
+
* lifetime — a `/reload` catalog/settings refresh or `/exit` must not block a
|
|
16815
|
+
* manual Client reload.
|
|
16816
|
+
*
|
|
16817
|
+
* Every OTHER local command is treated as a potential persisted writer
|
|
16818
|
+
* (fail-safe): its accepted execution — including the asynchronous preparation
|
|
16819
|
+
* that precedes a configuration write — keeps the Client reload gate closed
|
|
16820
|
+
* until the handler settles. A new write-capable local command is therefore
|
|
16821
|
+
* protected by default instead of requiring an addition to this set.
|
|
16822
|
+
*/
|
|
16823
|
+
const READ_ONLY_LOCAL_COMMANDS = /* @__PURE__ */ new Set([
|
|
16824
|
+
"reload-client",
|
|
16825
|
+
"reload",
|
|
16826
|
+
"exit",
|
|
16827
|
+
"quit",
|
|
16828
|
+
"help",
|
|
16829
|
+
"keybindings",
|
|
16830
|
+
"copy",
|
|
16831
|
+
"attach",
|
|
16832
|
+
"image",
|
|
16833
|
+
"export",
|
|
16834
|
+
"transcript",
|
|
16835
|
+
"deliverables",
|
|
16836
|
+
"view-image",
|
|
16837
|
+
"sessions",
|
|
16838
|
+
"resume",
|
|
16839
|
+
"search",
|
|
16840
|
+
"tasks"
|
|
16841
|
+
]);
|
|
16842
|
+
/**
|
|
16843
|
+
* Whether one TUI-local command may perform a persistent Host write during its
|
|
16844
|
+
* own handler execution. Fail-safe: anything not explicitly read-only is
|
|
16845
|
+
* treated as a possible writer.
|
|
16846
|
+
* @param name - the local command name (bare token).
|
|
16847
|
+
*/
|
|
16848
|
+
function localCommandMayWrite(name) {
|
|
16849
|
+
return !READ_ONLY_LOCAL_COMMANDS.has(name);
|
|
16850
|
+
}
|
|
16161
16851
|
//#endregion
|
|
16162
16852
|
//#region src/extension/internal/batcher.ts
|
|
16163
16853
|
/** Coalescing invalidate dispatcher. `flush()` is idempotent per tick. */
|
|
@@ -19222,4 +19912,4 @@ function apply(ctx) {
|
|
|
19222
19912
|
new PiTuiExtensionServiceImpl(ctx, packageVersion(), () => {}, HOST_COMMAND_CATALOG);
|
|
19223
19913
|
}
|
|
19224
19914
|
//#endregion
|
|
19225
|
-
export {
|
|
19915
|
+
export { findAltScreenSearchMatches as $, isTextProducingKeyId as A, Markdown as B, isPhysicalEscapeAction as C, __exportAll as Ct, VIEWER_BLOCKED_PARENT_ACTIONS as D, APP_KEYBINDINGS as E, Editor as F, Spacer as G, ProcessTerminal as H, HStack as I, TuiMainScreen as J, Text as K, Image as L, AltScreenSearchIndex as M, CombinedAutocompleteProvider as N, canonicalizeKeyId as O, Container as P, dispatchMouseEvent as Q, Input as R, isEditorSubmitPreSubmitKey as S, stripControlChars as St, parseUserKeybindings as T, ScrollView as U, MouseRegion as V, SettingsList as W, decodeKittyPrintable as X, VStack as Y, decodePrintableKey as Z, localCommandMayWrite as _, defaultHideInTsp as _t, PI_TUI_EXTENSIONS_SERVICE as a, imageFallback as at, normalizeInputEvent as b, parseFooterLayout as bt, InvalidateBatcher as c, isKeyRepeat as ct, SESSIONLESS_COMMANDS as d, registerKittyImageMetadata as dt, fuzzyFilter as et, classifyCommandLine as f, sliceByColumn as ft, isPlainExitPrompt as g, wrapTextWithAnsi as gt, isLocalCommandLine as h, visibleWidth as ht, name as i, getKeybindings as it, isValidKeyId as j, isRuntimeBindableKeyId as k, HOST_COMMAND_CATALOG as l, matchesKey as lt, isBareCommandLine as m, truncateToWidth as mt, extensions_exports as n, getCellDimensions as nt, API_VERSION as o, isFocusable as ot, commandIsLocalForAttachments as p, stripTerminalSequences as pt, TuiAltScreen as q, inject as r, getGraphemeSegmenter as rt, describeKey as s, isKeyRelease as st, apply as t, getCapabilities as tt, LOCAL_COMMANDS as u, parseKey as ut, normalizeSkillInvocation as v, hideFooterRefInTsp as vt, isTerminalAmbiguousKeyId as w, DEFAULT_LEADER_TIMEOUT_MS as x, resolveCommandFooterFallback as xt, shouldConsumeAdvertisedMiss as y, isFooterLayout as yt, Key as z };
|