@fractaal/pi-tui 0.85.3 → 0.86.1
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.md +175 -19
- package/dist/alt-screen-search.d.ts +46 -0
- package/dist/alt-screen-search.d.ts.map +1 -0
- package/dist/alt-screen-search.js +282 -0
- package/dist/alt-screen-search.js.map +1 -0
- package/dist/autocomplete.d.ts +2 -1
- package/dist/autocomplete.d.ts.map +1 -1
- package/dist/autocomplete.js +85 -24
- package/dist/autocomplete.js.map +1 -1
- package/dist/colors.d.ts +73 -0
- package/dist/colors.d.ts.map +1 -0
- package/dist/colors.js +273 -0
- package/dist/colors.js.map +1 -0
- package/dist/components/alt-screen-flash.d.ts +13 -0
- package/dist/components/alt-screen-flash.d.ts.map +1 -0
- package/dist/components/alt-screen-flash.js +37 -0
- package/dist/components/alt-screen-flash.js.map +1 -0
- package/dist/components/box.d.ts +3 -1
- package/dist/components/box.d.ts.map +1 -1
- package/dist/components/box.js +38 -8
- package/dist/components/box.js.map +1 -1
- package/dist/components/cancellable-loader.d.ts.map +1 -1
- package/dist/components/cancellable-loader.js.map +1 -1
- package/dist/components/editor.d.ts +6 -1
- package/dist/components/editor.d.ts.map +1 -1
- package/dist/components/editor.js +118 -24
- package/dist/components/editor.js.map +1 -1
- package/dist/components/h-stack.d.ts +7 -0
- package/dist/components/h-stack.d.ts.map +1 -0
- package/dist/components/h-stack.js +43 -0
- package/dist/components/h-stack.js.map +1 -0
- package/dist/components/image.d.ts +12 -0
- package/dist/components/image.d.ts.map +1 -1
- package/dist/components/image.js +36 -3
- package/dist/components/image.js.map +1 -1
- package/dist/components/input.d.ts +12 -1
- package/dist/components/input.d.ts.map +1 -1
- package/dist/components/input.js +44 -5
- package/dist/components/input.js.map +1 -1
- package/dist/components/loader.d.ts +2 -0
- package/dist/components/loader.d.ts.map +1 -1
- package/dist/components/loader.js +10 -3
- package/dist/components/loader.js.map +1 -1
- package/dist/components/markdown.d.ts +5 -0
- package/dist/components/markdown.d.ts.map +1 -1
- package/dist/components/markdown.js +150 -9
- package/dist/components/markdown.js.map +1 -1
- package/dist/components/mouse-region.d.ts +12 -0
- package/dist/components/mouse-region.d.ts.map +1 -0
- package/dist/components/mouse-region.js +21 -0
- package/dist/components/mouse-region.js.map +1 -0
- package/dist/components/scroll-view.d.ts +59 -0
- package/dist/components/scroll-view.d.ts.map +1 -0
- package/dist/components/scroll-view.js +195 -0
- package/dist/components/scroll-view.js.map +1 -0
- package/dist/components/select-list.d.ts +4 -1
- package/dist/components/select-list.d.ts.map +1 -1
- package/dist/components/select-list.js +49 -2
- package/dist/components/select-list.js.map +1 -1
- package/dist/components/settings-list.d.ts +13 -3
- package/dist/components/settings-list.d.ts.map +1 -1
- package/dist/components/settings-list.js +82 -15
- package/dist/components/settings-list.js.map +1 -1
- package/dist/components/spacer.d.ts.map +1 -1
- package/dist/components/spacer.js.map +1 -1
- package/dist/components/stack.d.ts +32 -0
- package/dist/components/stack.d.ts.map +1 -0
- package/dist/components/stack.js +111 -0
- package/dist/components/stack.js.map +1 -0
- package/dist/components/text.d.ts.map +1 -1
- package/dist/components/text.js +7 -5
- package/dist/components/text.js.map +1 -1
- package/dist/components/truncated-text.d.ts.map +1 -1
- package/dist/components/truncated-text.js.map +1 -1
- package/dist/components/v-stack.d.ts +8 -0
- package/dist/components/v-stack.d.ts.map +1 -0
- package/dist/components/v-stack.js +26 -0
- package/dist/components/v-stack.js.map +1 -0
- package/dist/editor-component.d.ts.map +1 -1
- package/dist/fuzzy.d.ts.map +1 -1
- package/dist/fuzzy.js +23 -22
- package/dist/fuzzy.js.map +1 -1
- package/dist/index.d.ts +18 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -6
- package/dist/index.js.map +1 -1
- package/dist/keybindings.d.ts +82 -2
- package/dist/keybindings.d.ts.map +1 -1
- package/dist/keybindings.js +61 -2
- package/dist/keybindings.js.map +1 -1
- package/dist/keys.d.ts.map +1 -1
- package/dist/keys.js.map +1 -1
- package/dist/kill-ring.d.ts.map +1 -1
- package/dist/kill-ring.js.map +1 -1
- package/dist/latex.d.ts +10 -0
- package/dist/latex.d.ts.map +1 -0
- package/dist/latex.js +1378 -0
- package/dist/latex.js.map +1 -0
- package/dist/layout-node.d.ts +40 -0
- package/dist/layout-node.d.ts.map +1 -0
- package/dist/layout-node.js +6 -0
- package/dist/layout-node.js.map +1 -0
- package/dist/layout.d.ts +42 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +344 -0
- package/dist/layout.js.map +1 -0
- package/dist/native-modifiers.d.ts +2 -1
- package/dist/native-modifiers.d.ts.map +1 -1
- package/dist/native-modifiers.js +3 -43
- package/dist/native-modifiers.js.map +1 -1
- package/dist/native-module-path.d.ts +7 -0
- package/dist/native-module-path.d.ts.map +1 -0
- package/dist/native-module-path.js +19 -0
- package/dist/native-module-path.js.map +1 -0
- package/dist/native-platform.d.ts +20 -0
- package/dist/native-platform.d.ts.map +1 -0
- package/dist/native-platform.js +42 -0
- package/dist/native-platform.js.map +1 -0
- package/dist/oklab.d.ts +43 -0
- package/dist/oklab.d.ts.map +1 -0
- package/dist/oklab.js +210 -0
- package/dist/oklab.js.map +1 -0
- package/dist/stdin-buffer.d.ts +8 -2
- package/dist/stdin-buffer.d.ts.map +1 -1
- package/dist/stdin-buffer.js +7 -2
- package/dist/stdin-buffer.js.map +1 -1
- package/dist/terminal-colors.d.ts +19 -2
- package/dist/terminal-colors.d.ts.map +1 -1
- package/dist/terminal-colors.js +13 -8
- package/dist/terminal-colors.js.map +1 -1
- package/dist/terminal-image.d.ts +29 -1
- package/dist/terminal-image.d.ts.map +1 -1
- package/dist/terminal-image.js +223 -18
- package/dist/terminal-image.js.map +1 -1
- package/dist/terminal.d.ts +16 -0
- package/dist/terminal.d.ts.map +1 -1
- package/dist/terminal.js +62 -46
- package/dist/terminal.js.map +1 -1
- package/dist/tui-alt-screen.d.ts +166 -0
- package/dist/tui-alt-screen.d.ts.map +1 -0
- package/dist/tui-alt-screen.js +1546 -0
- package/dist/tui-alt-screen.js.map +1 -0
- package/dist/tui-main-screen.d.ts +39 -0
- package/dist/tui-main-screen.d.ts.map +1 -0
- package/dist/tui-main-screen.js +594 -0
- package/dist/tui-main-screen.js.map +1 -0
- package/dist/tui.d.ts +178 -60
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +303 -641
- package/dist/tui.js.map +1 -1
- package/dist/undo-stack.d.ts.map +1 -1
- package/dist/undo-stack.js.map +1 -1
- package/dist/utils.d.ts +22 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +245 -63
- package/dist/utils.js.map +1 -1
- package/dist/wheel-scroll.d.ts +23 -0
- package/dist/wheel-scroll.d.ts.map +1 -0
- package/dist/wheel-scroll.js +73 -0
- package/dist/wheel-scroll.js.map +1 -0
- package/dist/word-navigation.d.ts.map +1 -1
- package/dist/word-navigation.js.map +1 -1
- package/native/clipboard.h +208 -0
- package/native/darwin/README.md +22 -0
- package/native/darwin/build.sh +69 -0
- package/native/darwin/prebuilds/darwin-arm64/{darwin-modifiers.node → darwin-platform.node} +0 -0
- package/native/darwin/prebuilds/darwin-x64/darwin-platform.node +0 -0
- package/native/darwin/src/darwin-platform.m +132 -0
- package/native/linux/README.md +23 -0
- package/native/linux/build.sh +65 -0
- package/native/linux/prebuilds/linux-arm64/linux-platform-x11.node +0 -0
- package/native/linux/prebuilds/linux-x64/linux-platform-x11.node +0 -0
- package/native/linux/src/clipboard-worker.h +70 -0
- package/native/linux/src/linux-platform-x11.c +274 -0
- package/native/napi.h +91 -0
- package/native/win32/README.md +31 -0
- package/native/win32/build.mjs +232 -0
- package/native/win32/prebuilds/win32-arm64/win32-platform.node +0 -0
- package/native/win32/prebuilds/win32-x64/win32-platform.node +0 -0
- package/native/win32/src/win32-platform.c +241 -0
- package/package.json +19 -4
- package/native/darwin/prebuilds/darwin-x64/darwin-modifiers.node +0 -0
- package/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
- package/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tui-main-screen.js","sourceRoot":"","sources":["../src/tui-main-screen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAY,OAAO,EAAuB,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,qBAAqB,GAAG,QAAQ,CAAC;AACvC,MAAM,sBAAsB,GAAG,IAAI,GAAG,IAAI,CAAC;AAE3C;;;;;;GAMG;AACH,MAAM,qBAAqB;IAClB,MAAM,GAAG,EAAE,CAAC;IACZ,YAAY,GAAG,CAAC,CAAC;IACR,KAAK,CAAyB;IAE/C,YAAY,KAA6B;QACxC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACpB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,KAAa;QACnB,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,OAAO,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;YAC9B,MAAM,QAAQ,GAAG,sBAAsB,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;YAC7D,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;gBACpB,IAAI,CAAC,KAAK,EAAE,CAAC;gBACb,SAAS;YACV,CAAC;YAED,IAAI,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC,CAAC;YACpD,IACC,GAAG,GAAG,KAAK,CAAC,MAAM;gBAClB,KAAK,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,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,EAAE,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC;QACvE,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;QAE7C,8CAA8C;QAC9C,MAAM,QAAQ,GAAG,SAAS,GAAG,IAAI,CAAC,iBAAiB,CAAC;QACpD,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;YAClB,MAAM,IAAI,QAAQ,QAAQ,GAAG,CAAC,CAAC,YAAY;QAC5C,CAAC;aAAM,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,QAAQ,CAAC,QAAQ,GAAG,CAAC,CAAC,UAAU;QAC3C,CAAC;QACD,sCAAsC;QACtC,MAAM,IAAI,QAAQ,SAAS,GAAG,CAAC,GAAG,CAAC;QAEnC,IAAI,MAAM,EAAE,CAAC;YACZ,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC7B,CAAC;QAED,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;QACnC,IAAI,IAAI,CAAC,qBAAqB,EAAE,EAAE,CAAC;YAClC,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;QAC5B,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;QAC5B,CAAC;IACF,CAAC;CACD","sourcesContent":["import * as fs from \"node:fs\";\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\nimport { deleteKittyImage, isImageLine } from \"./terminal-image.ts\";\nimport { type TUI, TuiBase, type TuiStopOptions } from \"./tui.ts\";\nimport { visibleWidth } from \"./utils.ts\";\n\nconst KITTY_SEQUENCE_PREFIX = \"\\x1b_G\";\nconst MAX_RENDER_WRITE_CHARS = 1024 * 1024;\n\n/**\n * Streams terminal output in 1 MiB chunks so a full render never forms one string large enough to exceed V8's limit.\n *\n * `append()` fills the current chunk and flushes it when full. Oversized input is split at chunk boundaries, preserving\n * surrogate pairs so each write remains valid UTF-16. Callers append synchronized-output begin/end sequences themselves;\n * the final `flush()` writes any remainder, including the end sequence.\n */\nclass BoundedTerminalWriter {\n\tprivate buffer = \"\";\n\tprivate writtenChars = 0;\n\tprivate readonly write: (data: string) => void;\n\n\tconstructor(write: (data: string) => void) {\n\t\tthis.write = write;\n\t}\n\n\t/**\n\t * Append terminal data, flushing full chunks as needed. Callers must call `flush()` after the final append.\n\t * @param value Terminal data to write in order; oversized values are split without splitting surrogate pairs.\n\t */\n\tappend(value: string): void {\n\t\tlet offset = 0;\n\t\twhile (offset < value.length) {\n\t\t\tconst capacity = MAX_RENDER_WRITE_CHARS - this.buffer.length;\n\t\t\tif (capacity === 0) {\n\t\t\t\tthis.flush();\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tlet end = Math.min(value.length, offset + capacity);\n\t\t\tif (\n\t\t\t\tend < value.length &&\n\t\t\t\tvalue.charCodeAt(end - 1) >= 0xd800 &&\n\t\t\t\tvalue.charCodeAt(end - 1) <= 0xdbff &&\n\t\t\t\tvalue.charCodeAt(end) >= 0xdc00 &&\n\t\t\t\tvalue.charCodeAt(end) <= 0xdfff\n\t\t\t) {\n\t\t\t\tend--;\n\t\t\t}\n\t\t\tif (end === offset) {\n\t\t\t\tthis.flush();\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tthis.buffer += value.slice(offset, end);\n\t\t\toffset = end;\n\t\t\tif (this.buffer.length === MAX_RENDER_WRITE_CHARS) {\n\t\t\t\tthis.flush();\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Write the current chunk, if any, and retain only its character count for debug output. */\n\tflush(): void {\n\t\tif (!this.buffer) return;\n\t\tthis.write(this.buffer);\n\t\tthis.writtenChars += this.buffer.length;\n\t\tthis.buffer = \"\";\n\t}\n\n\tget length(): number {\n\t\treturn this.writtenChars + this.buffer.length;\n\t}\n}\n\ninterface KittyImageHeader {\n\tids: number[];\n\trows: number;\n}\n\nfunction parseKittyImageHeader(line: string): KittyImageHeader | undefined {\n\tconst sequenceStart = line.indexOf(KITTY_SEQUENCE_PREFIX);\n\tif (sequenceStart === -1) return undefined;\n\tconst paramsStart = sequenceStart + KITTY_SEQUENCE_PREFIX.length;\n\tconst paramsEnd = line.indexOf(\";\", paramsStart);\n\tif (paramsEnd === -1) return undefined;\n\n\tconst ids: number[] = [];\n\tlet rows = 1;\n\tfor (const param of line.slice(paramsStart, paramsEnd).split(\",\")) {\n\t\tconst [key, value] = param.split(\"=\", 2);\n\t\tif (value === undefined) continue;\n\t\tconst numberValue = Number(value);\n\t\tif (!Number.isInteger(numberValue) || numberValue <= 0 || numberValue > 0xffffffff) continue;\n\t\tif (key === \"i\") ids.push(numberValue);\n\t\telse if (key === \"r\") rows = numberValue;\n\t}\n\treturn { ids, rows };\n}\n\nfunction extractKittyImageIds(line: string): number[] {\n\treturn parseKittyImageHeader(line)?.ids ?? [];\n}\n\nfunction extractKittyImageRows(line: string): number {\n\treturn parseKittyImageHeader(line)?.rows ?? 1;\n}\n\nfunction isTermuxSession(): boolean {\n\treturn Boolean(process.env.TERMUX_VERSION);\n}\n\nexport interface TuiMainScreenRenderState {\n\tpreviousLines: string[];\n\tpreviousWidth: number;\n\tpreviousHeight: number;\n\tcursorRow: number;\n\thardwareCursorRow: number;\n\tmaxLinesRendered: number;\n\tpreviousViewportTop: number;\n}\n\n/** TUI implementation that renders into the terminal's main screen and scrollback. */\nexport class TuiMainScreen extends TuiBase implements TUI {\n\treadonly mode = \"regular\" as const;\n\tprivate previousLines: string[] = [];\n\tprivate previousKittyImageIds = new Set<number>();\n\tprivate previousWidth = 0;\n\tprivate previousHeight = 0;\n\tprivate cursorRow = 0;\n\tprivate hardwareCursorRow = 0;\n\tprivate maxLinesRendered = 0;\n\tprivate previousViewportTop = 0;\n\n\tcaptureRenderState(): TuiMainScreenRenderState {\n\t\treturn {\n\t\t\tpreviousLines: [...this.previousLines],\n\t\t\tpreviousWidth: this.previousWidth,\n\t\t\tpreviousHeight: this.previousHeight,\n\t\t\tcursorRow: this.cursorRow,\n\t\t\thardwareCursorRow: this.hardwareCursorRow,\n\t\t\tmaxLinesRendered: this.maxLinesRendered,\n\t\t\tpreviousViewportTop: this.previousViewportTop,\n\t\t};\n\t}\n\n\trestoreRenderState(state: TuiMainScreenRenderState): void {\n\t\tthis.previousLines = state.previousLines.map((line) => (isImageLine(line) ? \"\" : line));\n\t\tthis.previousKittyImageIds = new Set();\n\t\tthis.previousWidth = state.previousWidth;\n\t\tthis.previousHeight = state.previousHeight;\n\t\tthis.cursorRow = state.cursorRow;\n\t\tthis.hardwareCursorRow = state.hardwareCursorRow;\n\t\tthis.maxLinesRendered = state.maxLinesRendered;\n\t\tthis.previousViewportTop = state.previousViewportTop;\n\t}\n\n\tprotected override resetRenderState(): void {\n\t\tthis.previousLines = [];\n\t\tthis.previousWidth = -1;\n\t\tthis.previousHeight = -1;\n\t\tthis.cursorRow = 0;\n\t\tthis.hardwareCursorRow = 0;\n\t\tthis.maxLinesRendered = 0;\n\t\tthis.previousViewportTop = 0;\n\t}\n\n\tprotected override beforeTerminalStop(options: TuiStopOptions): void {\n\t\tif (options.preserveScreen || this.previousLines.length === 0) return;\n\t\tthis.terminal.write(\" \");\n\t\tconst targetRow = this.previousLines.length;\n\t\tconst lineDiff = targetRow - this.hardwareCursorRow;\n\t\tif (lineDiff > 0) this.terminal.write(`\\x1b[${lineDiff}B`);\n\t\telse if (lineDiff < 0) this.terminal.write(`\\x1b[${-lineDiff}A`);\n\t\tthis.terminal.write(\"\\r\\n\");\n\t}\n\n\tprivate collectKittyImageIds(lines: string[]): Set<number> {\n\t\tconst ids = new Set<number>();\n\t\tfor (const line of lines) {\n\t\t\tfor (const id of extractKittyImageIds(line)) {\n\t\t\t\tids.add(id);\n\t\t\t}\n\t\t}\n\t\treturn ids;\n\t}\n\n\tprivate deleteKittyImages(ids: Iterable<number>): string {\n\t\tlet buffer = \"\";\n\t\tfor (const id of ids) {\n\t\t\tbuffer += deleteKittyImage(id);\n\t\t}\n\t\treturn buffer;\n\t}\n\n\tprivate getKittyImageReservedRows(lines: string[], index: number, maxIndex = lines.length - 1): number {\n\t\tconst rows = extractKittyImageRows(lines[index] ?? \"\");\n\t\tif (rows <= 1) return 1;\n\n\t\tconst maxRows = Math.min(rows, maxIndex - index + 1, lines.length - index);\n\t\tlet reservedRows = 1;\n\t\twhile (reservedRows < maxRows) {\n\t\t\tconst line = lines[index + reservedRows] ?? \"\";\n\t\t\tif (isImageLine(line) || visibleWidth(line) > 0) break;\n\t\t\treservedRows++;\n\t\t}\n\t\treturn reservedRows;\n\t}\n\n\tprivate expandChangedRangeForKittyImages(\n\t\tfirstChanged: number,\n\t\tlastChanged: number,\n\t\tnewLines: string[],\n\t): { firstChanged: number; lastChanged: number } {\n\t\tlet expandedFirstChanged = firstChanged;\n\t\tlet expandedLastChanged = lastChanged;\n\t\tconst expandForLines = (lines: string[]): void => {\n\t\t\tfor (let i = 0; i < lines.length; i++) {\n\t\t\t\tif (extractKittyImageIds(lines[i]).length === 0) continue;\n\t\t\t\tconst blockEnd = i + this.getKittyImageReservedRows(lines, i) - 1;\n\t\t\t\tif (i >= firstChanged || (i <= lastChanged && blockEnd >= firstChanged)) {\n\t\t\t\t\texpandedFirstChanged = Math.min(expandedFirstChanged, i);\n\t\t\t\t\texpandedLastChanged = Math.max(expandedLastChanged, blockEnd);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\texpandForLines(this.previousLines);\n\t\texpandForLines(newLines);\n\t\treturn { firstChanged: expandedFirstChanged, lastChanged: expandedLastChanged };\n\t}\n\n\tprivate deleteChangedKittyImages(firstChanged: number, lastChanged: number): string {\n\t\tif (firstChanged < 0 || lastChanged < firstChanged) return \"\";\n\n\t\tconst ids = new Set<number>();\n\t\tconst maxLine = Math.min(lastChanged, this.previousLines.length - 1);\n\t\tfor (let i = firstChanged; i <= maxLine; i++) {\n\t\t\tfor (const id of extractKittyImageIds(this.previousLines[i] ?? \"\")) {\n\t\t\t\tids.add(id);\n\t\t\t}\n\t\t}\n\n\t\treturn this.deleteKittyImages(ids);\n\t}\n\n\tprotected doRender(): void {\n\t\tif (this.stopped) return;\n\t\tconst width = this.terminal.columns;\n\t\tconst height = this.terminal.rows;\n\t\tconst widthChanged = this.previousWidth !== 0 && this.previousWidth !== width;\n\t\tconst heightChanged = this.previousHeight !== 0 && this.previousHeight !== height;\n\t\tconst previousBufferLength = this.previousHeight > 0 ? this.previousViewportTop + this.previousHeight : height;\n\t\tlet prevViewportTop = heightChanged ? Math.max(0, previousBufferLength - height) : this.previousViewportTop;\n\t\tlet viewportTop = prevViewportTop;\n\t\tlet hardwareCursorRow = this.hardwareCursorRow;\n\t\tconst computeLineDiff = (targetRow: number): number => {\n\t\t\tconst currentScreenRow = hardwareCursorRow - prevViewportTop;\n\t\t\tconst targetScreenRow = targetRow - viewportTop;\n\t\t\treturn targetScreenRow - currentScreenRow;\n\t\t};\n\n\t\t// Render all components to get new lines\n\t\tlet newLines = this.render(width);\n\n\t\t// Composite overlays into the rendered lines (before differential compare)\n\t\tif (this.hasOverlayEntries) {\n\t\t\tnewLines = this.compositeOverlays(newLines, width, height);\n\t\t}\n\n\t\t// Extract cursor position before applying line resets (marker must be found first)\n\t\tconst cursorPos = this.extractCursorPosition(newLines, height);\n\n\t\tnewLines = this.applyLineResets(newLines);\n\n\t\t// Helper to clear scrollback and viewport and render all new lines\n\t\tconst fullRender = (clear: boolean): void => {\n\t\t\tthis.fullRedrawCount += 1;\n\t\t\tconst output = new BoundedTerminalWriter((data) => this.terminal.write(data));\n\t\t\toutput.append(\"\\x1b[?2026h\"); // Begin synchronized output\n\t\t\tif (clear) {\n\t\t\t\toutput.append(this.deleteKittyImages(this.previousKittyImageIds));\n\t\t\t\toutput.append(\"\\x1b[2J\\x1b[H\\x1b[3J\"); // Clear screen, home, then clear scrollback\n\t\t\t}\n\t\t\tfor (let i = 0; i < newLines.length; i++) {\n\t\t\t\tif (i > 0) output.append(\"\\r\\n\");\n\t\t\t\tconst line = newLines[i];\n\t\t\t\tconst isImage = isImageLine(line);\n\t\t\t\tconst imageReservedRows = isImage ? this.getKittyImageReservedRows(newLines, i) : 1;\n\t\t\t\tif (imageReservedRows > 1 && imageReservedRows <= height) {\n\t\t\t\t\tfor (let row = 1; row < imageReservedRows; row++) {\n\t\t\t\t\t\toutput.append(\"\\r\\n\");\n\t\t\t\t\t}\n\t\t\t\t\toutput.append(`\\x1b[${imageReservedRows - 1}A`);\n\t\t\t\t\toutput.append(line);\n\t\t\t\t\toutput.append(`\\x1b[${imageReservedRows - 1}B`);\n\t\t\t\t\ti += imageReservedRows - 1;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\toutput.append(line);\n\t\t\t}\n\t\t\toutput.append(\"\\x1b[?2026l\"); // End synchronized output\n\t\t\toutput.flush();\n\t\t\tthis.cursorRow = Math.max(0, newLines.length - 1);\n\t\t\tthis.hardwareCursorRow = this.cursorRow;\n\t\t\t// Reset max lines when clearing, otherwise track growth\n\t\t\tif (clear) {\n\t\t\t\tthis.maxLinesRendered = newLines.length;\n\t\t\t} else {\n\t\t\t\tthis.maxLinesRendered = Math.max(this.maxLinesRendered, newLines.length);\n\t\t\t}\n\t\t\tconst bufferLength = Math.max(height, newLines.length);\n\t\t\tthis.previousViewportTop = Math.max(0, bufferLength - height);\n\t\t\tthis.positionHardwareCursor(cursorPos, newLines.length);\n\t\t\tthis.previousLines = newLines;\n\t\t\tthis.previousKittyImageIds = this.collectKittyImageIds(newLines);\n\t\t\tthis.previousWidth = width;\n\t\t\tthis.previousHeight = height;\n\t\t};\n\n\t\tconst redrawLogDirectory = process.env.PI_TUI_DEBUG_REDRAW === \"1\" ? this.logDirectory : undefined;\n\t\tconst logRedraw = (reason: string): void => {\n\t\t\tif (redrawLogDirectory === undefined) return;\n\t\t\tconst logPath = path.join(redrawLogDirectory, \"pi-tui-debug.log\");\n\t\t\tconst msg = `[${new Date().toISOString()}] fullRender: ${reason} (prev=${this.previousLines.length}, new=${newLines.length}, height=${height})\\n`;\n\t\t\tfs.mkdirSync(path.dirname(logPath), { recursive: true });\n\t\t\tfs.appendFileSync(logPath, msg);\n\t\t};\n\n\t\t// First render - just output everything without clearing (assumes clean screen)\n\t\tif (this.previousLines.length === 0 && !widthChanged && !heightChanged) {\n\t\t\tlogRedraw(\"first render\");\n\t\t\tfullRender(false);\n\t\t\treturn;\n\t\t}\n\n\t\t// Width changes always need a full re-render because wrapping changes.\n\t\tif (widthChanged) {\n\t\t\tlogRedraw(`terminal width changed (${this.previousWidth} -> ${width})`);\n\t\t\tfullRender(true);\n\t\t\treturn;\n\t\t}\n\n\t\t// Height changes normally need a full re-render to keep the visible viewport aligned,\n\t\t// but Termux changes height when the software keyboard shows or hides.\n\t\t// In that environment, a full redraw causes the entire history to replay on every toggle.\n\t\tif (heightChanged && !isTermuxSession()) {\n\t\t\tlogRedraw(`terminal height changed (${this.previousHeight} -> ${height})`);\n\t\t\tfullRender(true);\n\t\t\treturn;\n\t\t}\n\n\t\t// Content shrunk below the working area and no overlays - re-render to clear empty rows\n\t\t// (overlays need the padding, so only do this when no overlays are active)\n\t\t// Configurable via setClearOnShrink()\n\t\tif (this.getClearOnShrink() && newLines.length < this.maxLinesRendered && !this.hasOverlayEntries) {\n\t\t\tlogRedraw(`clearOnShrink (maxLinesRendered=${this.maxLinesRendered})`);\n\t\t\tfullRender(true);\n\t\t\treturn;\n\t\t}\n\n\t\t// Find first and last changed lines\n\t\tlet firstChanged = -1;\n\t\tlet lastChanged = -1;\n\t\tconst maxLines = Math.max(newLines.length, this.previousLines.length);\n\t\tfor (let i = 0; i < maxLines; i++) {\n\t\t\tconst oldLine = i < this.previousLines.length ? this.previousLines[i] : \"\";\n\t\t\tconst newLine = i < newLines.length ? newLines[i] : \"\";\n\n\t\t\tif (oldLine !== newLine) {\n\t\t\t\tif (firstChanged === -1) {\n\t\t\t\t\tfirstChanged = i;\n\t\t\t\t}\n\t\t\t\tlastChanged = i;\n\t\t\t}\n\t\t}\n\t\tconst appendedLines = newLines.length > this.previousLines.length;\n\t\tif (appendedLines) {\n\t\t\tif (firstChanged === -1) {\n\t\t\t\tfirstChanged = this.previousLines.length;\n\t\t\t}\n\t\t\tlastChanged = newLines.length - 1;\n\t\t}\n\t\tif (firstChanged !== -1) {\n\t\t\tconst expandedRange = this.expandChangedRangeForKittyImages(firstChanged, lastChanged, newLines);\n\t\t\tfirstChanged = expandedRange.firstChanged;\n\t\t\tlastChanged = expandedRange.lastChanged;\n\t\t}\n\t\tconst appendStart = appendedLines && firstChanged === this.previousLines.length && firstChanged > 0;\n\n\t\t// No changes - but still need to update hardware cursor position if it moved\n\t\tif (firstChanged === -1) {\n\t\t\tthis.positionHardwareCursor(cursorPos, newLines.length);\n\t\t\tthis.previousViewportTop = prevViewportTop;\n\t\t\tthis.previousHeight = height;\n\t\t\treturn;\n\t\t}\n\n\t\t// All changes are in deleted lines (nothing to render, just clear)\n\t\tif (firstChanged >= newLines.length) {\n\t\t\tif (this.previousLines.length > newLines.length) {\n\t\t\t\tconst output = new BoundedTerminalWriter((data) => this.terminal.write(data));\n\t\t\t\toutput.append(\"\\x1b[?2026h\");\n\t\t\t\toutput.append(this.deleteChangedKittyImages(firstChanged, lastChanged));\n\t\t\t\t// Move to end of new content (clamp to 0 for empty content)\n\t\t\t\tconst targetRow = Math.max(0, newLines.length - 1);\n\t\t\t\tif (targetRow < prevViewportTop) {\n\t\t\t\t\tlogRedraw(`deleted lines moved viewport up (${targetRow} < ${prevViewportTop})`);\n\t\t\t\t\tfullRender(true);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst lineDiff = computeLineDiff(targetRow);\n\t\t\t\tif (lineDiff > 0) output.append(`\\x1b[${lineDiff}B`);\n\t\t\t\telse if (lineDiff < 0) output.append(`\\x1b[${-lineDiff}A`);\n\t\t\t\toutput.append(\"\\r\");\n\t\t\t\t// Clear extra lines without scrolling\n\t\t\t\tconst extraLines = this.previousLines.length - newLines.length;\n\t\t\t\tif (extraLines > height) {\n\t\t\t\t\tlogRedraw(`extraLines > height (${extraLines} > ${height})`);\n\t\t\t\t\tfullRender(true);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst clearStartOffset = newLines.length === 0 ? 0 : 1;\n\t\t\t\tif (extraLines > 0 && clearStartOffset > 0) {\n\t\t\t\t\toutput.append(`\\x1b[${clearStartOffset}B`);\n\t\t\t\t}\n\t\t\t\tfor (let i = 0; i < extraLines; i++) {\n\t\t\t\t\toutput.append(\"\\r\\x1b[2K\");\n\t\t\t\t\tif (i < extraLines - 1) output.append(\"\\x1b[1B\");\n\t\t\t\t}\n\t\t\t\tconst moveBack = Math.max(0, extraLines - 1 + clearStartOffset);\n\t\t\t\tif (moveBack > 0) {\n\t\t\t\t\toutput.append(`\\x1b[${moveBack}A`);\n\t\t\t\t}\n\t\t\t\toutput.append(\"\\x1b[?2026l\");\n\t\t\t\toutput.flush();\n\t\t\t\tthis.cursorRow = targetRow;\n\t\t\t\tthis.hardwareCursorRow = targetRow;\n\t\t\t}\n\t\t\tthis.positionHardwareCursor(cursorPos, newLines.length);\n\t\t\tthis.previousLines = newLines;\n\t\t\tthis.previousKittyImageIds = this.collectKittyImageIds(newLines);\n\t\t\tthis.previousWidth = width;\n\t\t\tthis.previousHeight = height;\n\t\t\tthis.previousViewportTop = prevViewportTop;\n\t\t\treturn;\n\t\t}\n\n\t\t// Differential rendering can only touch what was actually visible.\n\t\t// If the first changed line is above the previous viewport, we need a full redraw.\n\t\tif (firstChanged < prevViewportTop) {\n\t\t\tlogRedraw(`firstChanged < viewportTop (${firstChanged} < ${prevViewportTop})`);\n\t\t\tfullRender(true);\n\t\t\treturn;\n\t\t}\n\n\t\t// Render from first changed line to end\n\t\t// Keep updates wrapped in synchronized output while writing bounded chunks.\n\t\tconst output = new BoundedTerminalWriter((data) => this.terminal.write(data));\n\t\toutput.append(\"\\x1b[?2026h\"); // Begin synchronized output\n\t\toutput.append(this.deleteChangedKittyImages(firstChanged, lastChanged));\n\t\tconst prevViewportBottom = prevViewportTop + height - 1;\n\t\tconst moveTargetRow = appendStart ? firstChanged - 1 : firstChanged;\n\t\tif (moveTargetRow > prevViewportBottom) {\n\t\t\tconst currentScreenRow = Math.max(0, Math.min(height - 1, hardwareCursorRow - prevViewportTop));\n\t\t\tconst moveToBottom = height - 1 - currentScreenRow;\n\t\t\tif (moveToBottom > 0) {\n\t\t\t\toutput.append(`\\x1b[${moveToBottom}B`);\n\t\t\t}\n\t\t\tconst scroll = moveTargetRow - prevViewportBottom;\n\t\t\toutput.append(\"\\r\\n\".repeat(scroll));\n\t\t\tprevViewportTop += scroll;\n\t\t\tviewportTop += scroll;\n\t\t\thardwareCursorRow = moveTargetRow;\n\t\t}\n\n\t\t// Move cursor to first changed line (use hardwareCursorRow for actual position)\n\t\tconst lineDiff = computeLineDiff(moveTargetRow);\n\t\tif (lineDiff > 0) {\n\t\t\toutput.append(`\\x1b[${lineDiff}B`); // Move down\n\t\t} else if (lineDiff < 0) {\n\t\t\toutput.append(`\\x1b[${-lineDiff}A`); // Move up\n\t\t}\n\n\t\toutput.append(appendStart ? \"\\r\\n\" : \"\\r\"); // Move to column 0\n\n\t\t// Only render changed lines (firstChanged to lastChanged), not all lines to end\n\t\t// This reduces flicker when only a single line changes (e.g., spinner animation)\n\t\tconst renderEnd = Math.min(lastChanged, newLines.length - 1);\n\t\tfor (let i = firstChanged; i <= renderEnd; i++) {\n\t\t\tif (i > firstChanged) output.append(\"\\r\\n\");\n\t\t\tconst line = newLines[i];\n\t\t\tconst isImage = isImageLine(line);\n\t\t\tconst imageReservedRows = isImage ? this.getKittyImageReservedRows(newLines, i, renderEnd) : 1;\n\t\t\tif (imageReservedRows > 1) {\n\t\t\t\tconst imageStartScreenRow = i - viewportTop;\n\t\t\t\tif (imageStartScreenRow < 0 || imageStartScreenRow + imageReservedRows > height) {\n\t\t\t\t\tlogRedraw(\n\t\t\t\t\t\t`kitty image pre-clear would scroll (${imageStartScreenRow} + ${imageReservedRows} > ${height})`,\n\t\t\t\t\t);\n\t\t\t\t\tfullRender(true);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\toutput.append(\"\\x1b[2K\");\n\t\t\t\tfor (let row = 1; row < imageReservedRows; row++) {\n\t\t\t\t\toutput.append(\"\\r\\n\\x1b[2K\");\n\t\t\t\t}\n\t\t\t\toutput.append(`\\x1b[${imageReservedRows - 1}A`);\n\t\t\t\toutput.append(line);\n\t\t\t\toutput.append(`\\x1b[${imageReservedRows - 1}B`);\n\t\t\t\ti += imageReservedRows - 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\toutput.append(\"\\x1b[2K\"); // Clear current line\n\t\t\tif (!isImage && visibleWidth(line) > width) {\n\t\t\t\t// Log all lines to crash file for debugging\n\t\t\t\tconst crashLogPath = path.join(this.logDirectory ?? os.tmpdir(), \"pi-tui-crash.log\");\n\t\t\t\tconst crashData = [\n\t\t\t\t\t`Crash at ${new Date().toISOString()}`,\n\t\t\t\t\t`Terminal width: ${width}`,\n\t\t\t\t\t`Line ${i} visible width: ${visibleWidth(line)}`,\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"=== All rendered lines ===\",\n\t\t\t\t\t...newLines.map((l, idx) => `[${idx}] (w=${visibleWidth(l)}) ${l}`),\n\t\t\t\t\t\"\",\n\t\t\t\t].join(\"\\n\");\n\t\t\t\tfs.mkdirSync(path.dirname(crashLogPath), { recursive: true });\n\t\t\t\tfs.writeFileSync(crashLogPath, crashData);\n\n\t\t\t\t// Clean up terminal state before throwing\n\t\t\t\tthis.stop();\n\n\t\t\t\tconst errorMsg = [\n\t\t\t\t\t`Rendered line ${i} exceeds terminal width (${visibleWidth(line)} > ${width}).`,\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"This is likely caused by a custom TUI component not truncating its output.\",\n\t\t\t\t\t\"Use visibleWidth() to measure and truncateToWidth() to truncate lines.\",\n\t\t\t\t\t\"\",\n\t\t\t\t\t`Debug log written to: ${crashLogPath}`,\n\t\t\t\t].join(\"\\n\");\n\t\t\t\tthrow new Error(errorMsg);\n\t\t\t}\n\t\t\toutput.append(line);\n\t\t}\n\n\t\t// Track where cursor ended up after rendering\n\t\tlet finalCursorRow = renderEnd;\n\n\t\t// If we had more lines before, clear them and move cursor back\n\t\tif (this.previousLines.length > newLines.length) {\n\t\t\t// Move to end of new content first if we stopped before it\n\t\t\tif (renderEnd < newLines.length - 1) {\n\t\t\t\tconst moveDown = newLines.length - 1 - renderEnd;\n\t\t\t\toutput.append(`\\x1b[${moveDown}B`);\n\t\t\t\tfinalCursorRow = newLines.length - 1;\n\t\t\t}\n\t\t\tconst extraLines = this.previousLines.length - newLines.length;\n\t\t\tfor (let i = newLines.length; i < this.previousLines.length; i++) {\n\t\t\t\toutput.append(\"\\r\\n\\x1b[2K\");\n\t\t\t}\n\t\t\t// Move cursor back to end of new content\n\t\t\toutput.append(`\\x1b[${extraLines}A`);\n\t\t}\n\n\t\toutput.append(\"\\x1b[?2026l\"); // End synchronized output\n\n\t\tif (process.env.PI_TUI_DEBUG === \"1\") {\n\t\t\tconst debugDir = \"/tmp/tui\";\n\t\t\tfs.mkdirSync(debugDir, { recursive: true });\n\t\t\tconst debugPath = path.join(debugDir, `render-${Date.now()}-${Math.random().toString(36).slice(2)}.log`);\n\t\t\tconst debugData = [\n\t\t\t\t`firstChanged: ${firstChanged}`,\n\t\t\t\t`viewportTop: ${viewportTop}`,\n\t\t\t\t`cursorRow: ${this.cursorRow}`,\n\t\t\t\t`height: ${height}`,\n\t\t\t\t`lineDiff: ${lineDiff}`,\n\t\t\t\t`hardwareCursorRow: ${hardwareCursorRow}`,\n\t\t\t\t`renderEnd: ${renderEnd}`,\n\t\t\t\t`finalCursorRow: ${finalCursorRow}`,\n\t\t\t\t`cursorPos: ${JSON.stringify(cursorPos)}`,\n\t\t\t\t`newLines.length: ${newLines.length}`,\n\t\t\t\t`previousLines.length: ${this.previousLines.length}`,\n\t\t\t\t\"\",\n\t\t\t\t\"=== newLines ===\",\n\t\t\t\tJSON.stringify(newLines, null, 2),\n\t\t\t\t\"\",\n\t\t\t\t\"=== previousLines ===\",\n\t\t\t\tJSON.stringify(this.previousLines, null, 2),\n\t\t\t\t\"\",\n\t\t\t\t\"=== buffer ===\",\n\t\t\t\t`[${output.length} chars written in bounded chunks]`,\n\t\t\t].join(\"\\n\");\n\t\t\tfs.writeFileSync(debugPath, debugData);\n\t\t}\n\n\t\toutput.flush();\n\n\t\t// Track cursor position for next render\n\t\t// cursorRow tracks end of content (for viewport calculation)\n\t\t// hardwareCursorRow tracks actual terminal cursor position (for movement)\n\t\tthis.cursorRow = Math.max(0, newLines.length - 1);\n\t\tthis.hardwareCursorRow = finalCursorRow;\n\t\t// Track terminal's working area (grows but doesn't shrink unless cleared)\n\t\tthis.maxLinesRendered = Math.max(this.maxLinesRendered, newLines.length);\n\t\tthis.previousViewportTop = Math.max(prevViewportTop, finalCursorRow - height + 1);\n\n\t\t// Position hardware cursor for IME\n\t\tthis.positionHardwareCursor(cursorPos, newLines.length);\n\n\t\tthis.previousLines = newLines;\n\t\tthis.previousKittyImageIds = this.collectKittyImageIds(newLines);\n\t\tthis.previousWidth = width;\n\t\tthis.previousHeight = height;\n\t}\n\n\t/**\n\t * Position the hardware cursor for IME candidate window.\n\t * @param cursorPos The cursor position extracted from rendered output, or null\n\t * @param totalLines Total number of rendered lines\n\t */\n\tprivate positionHardwareCursor(cursorPos: { row: number; col: number } | null, totalLines: number): void {\n\t\tif (!cursorPos || totalLines <= 0) {\n\t\t\tthis.terminal.hideCursor();\n\t\t\treturn;\n\t\t}\n\n\t\t// Clamp cursor position to valid range\n\t\tconst targetRow = Math.max(0, Math.min(cursorPos.row, totalLines - 1));\n\t\tconst targetCol = Math.max(0, cursorPos.col);\n\n\t\t// Move cursor from current position to target\n\t\tconst rowDelta = targetRow - this.hardwareCursorRow;\n\t\tlet buffer = \"\";\n\t\tif (rowDelta > 0) {\n\t\t\tbuffer += `\\x1b[${rowDelta}B`; // Move down\n\t\t} else if (rowDelta < 0) {\n\t\t\tbuffer += `\\x1b[${-rowDelta}A`; // Move up\n\t\t}\n\t\t// Move to absolute column (1-indexed)\n\t\tbuffer += `\\x1b[${targetCol + 1}G`;\n\n\t\tif (buffer) {\n\t\t\tthis.terminal.write(buffer);\n\t\t}\n\n\t\tthis.hardwareCursorRow = targetRow;\n\t\tif (this.getShowHardwareCursor()) {\n\t\t\tthis.terminal.showCursor();\n\t\t} else {\n\t\t\tthis.terminal.hideCursor();\n\t\t}\n\t}\n}\n"]}
|
package/dist/tui.d.ts
CHANGED
|
@@ -2,11 +2,69 @@
|
|
|
2
2
|
* Minimal TUI implementation with differential rendering
|
|
3
3
|
*/
|
|
4
4
|
import type { Terminal } from "./terminal.ts";
|
|
5
|
-
import { type
|
|
5
|
+
import { type TerminalColorScheme, type TerminalColors } from "./terminal-colors.ts";
|
|
6
6
|
import { visibleWidth } from "./utils.ts";
|
|
7
7
|
/**
|
|
8
8
|
* Component interface - all components must implement this
|
|
9
9
|
*/
|
|
10
|
+
export type TuiMouseEventType = "press" | "release" | "move" | "drag" | "click" | "wheel";
|
|
11
|
+
export type TuiMouseButton = "left" | "middle" | "right" | "none";
|
|
12
|
+
/** Normalized cell-based mouse event. Coordinates are zero-based. */
|
|
13
|
+
export interface TuiMouseEvent {
|
|
14
|
+
type: TuiMouseEventType;
|
|
15
|
+
button: TuiMouseButton;
|
|
16
|
+
/** Coordinates local to the receiving component. */
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
/** Absolute terminal coordinates. */
|
|
20
|
+
screenX: number;
|
|
21
|
+
screenY: number;
|
|
22
|
+
/** Current component bounds. */
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
shift: boolean;
|
|
26
|
+
alt: boolean;
|
|
27
|
+
ctrl: boolean;
|
|
28
|
+
/** Logical lines. Negative values scroll up. */
|
|
29
|
+
wheelDelta?: number;
|
|
30
|
+
/** Consecutive click count when type is click. */
|
|
31
|
+
clickCount?: number;
|
|
32
|
+
}
|
|
33
|
+
export interface TuiMouseEventResult {
|
|
34
|
+
/** Stop propagation and suppress renderer-level fallback behavior. */
|
|
35
|
+
handled?: boolean;
|
|
36
|
+
/** Route subsequent drag/release events to this component. Implies handled. */
|
|
37
|
+
capture?: boolean;
|
|
38
|
+
/** Give keyboard focus to this component. Implies handled. */
|
|
39
|
+
focus?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Explicitly request or suppress a render. Move and release default to false;
|
|
42
|
+
* press, click, drag, and wheel default to true.
|
|
43
|
+
*/
|
|
44
|
+
render?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/** Internal target metadata used by containers and alternate-screen dispatch. */
|
|
47
|
+
export interface TuiMouseDispatchTarget {
|
|
48
|
+
component: Component;
|
|
49
|
+
originX: number;
|
|
50
|
+
originY: number;
|
|
51
|
+
width: number;
|
|
52
|
+
height: number;
|
|
53
|
+
}
|
|
54
|
+
/** Result of dispatching to a concrete component. */
|
|
55
|
+
export interface TuiMouseDispatchResult extends TuiMouseEventResult {
|
|
56
|
+
handled: true;
|
|
57
|
+
target: TuiMouseDispatchTarget;
|
|
58
|
+
/** Keyboard focus target, which may be a delegating parent container. */
|
|
59
|
+
focusTarget?: Component;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Dispatch an event to a component and retain the exact target and coordinate
|
|
63
|
+
* transform. Containers use this when forwarding events to nested children.
|
|
64
|
+
*/
|
|
65
|
+
export declare function dispatchMouseEvent(component: Component, event: TuiMouseEvent): TuiMouseDispatchResult | undefined;
|
|
66
|
+
/** Recreate local coordinates for a previously dispatched mouse target. */
|
|
67
|
+
export declare function retargetMouseEvent(event: TuiMouseEvent, target: TuiMouseDispatchTarget): TuiMouseEvent;
|
|
10
68
|
export interface Component {
|
|
11
69
|
/**
|
|
12
70
|
* Render the component to lines for the given viewport width
|
|
@@ -14,10 +72,10 @@ export interface Component {
|
|
|
14
72
|
* @returns Array of strings, each representing a line
|
|
15
73
|
*/
|
|
16
74
|
render(width: number): string[];
|
|
17
|
-
/**
|
|
18
|
-
* Optional handler for keyboard input when component has focus
|
|
19
|
-
*/
|
|
75
|
+
/** Optional handler for keyboard input when component has focus. */
|
|
20
76
|
handleInput?(data: string): void;
|
|
77
|
+
/** Optional normalized mouse handler. */
|
|
78
|
+
handleMouse?(event: TuiMouseEvent): TuiMouseEventResult | undefined;
|
|
21
79
|
/**
|
|
22
80
|
* If true, component receives key release events (Kitty protocol).
|
|
23
81
|
* Default is false - release events are filtered out.
|
|
@@ -29,11 +87,11 @@ export interface Component {
|
|
|
29
87
|
*/
|
|
30
88
|
invalidate(): void;
|
|
31
89
|
}
|
|
32
|
-
type
|
|
90
|
+
export type TuiInputListenerResult = {
|
|
33
91
|
consume?: boolean;
|
|
34
92
|
data?: string;
|
|
35
93
|
} | undefined;
|
|
36
|
-
type
|
|
94
|
+
export type TuiInputListener = (data: string) => TuiInputListenerResult;
|
|
37
95
|
/**
|
|
38
96
|
* Interface for components that can receive focus and display a hardware cursor.
|
|
39
97
|
* When focused, the component should emit CURSOR_MARKER at the cursor position
|
|
@@ -106,6 +164,13 @@ export interface OverlayUnfocusOptions {
|
|
|
106
164
|
/** Explicit target to focus after releasing this overlay. */
|
|
107
165
|
target: Component | null;
|
|
108
166
|
}
|
|
167
|
+
/** Last rendered terminal-relative overlay rectangle. */
|
|
168
|
+
export interface OverlayBounds {
|
|
169
|
+
row: number;
|
|
170
|
+
col: number;
|
|
171
|
+
width: number;
|
|
172
|
+
height: number;
|
|
173
|
+
}
|
|
109
174
|
/**
|
|
110
175
|
* Handle returned by showOverlay for controlling the overlay
|
|
111
176
|
*/
|
|
@@ -122,62 +187,113 @@ export interface OverlayHandle {
|
|
|
122
187
|
unfocus(options?: OverlayUnfocusOptions): void;
|
|
123
188
|
/** Check if this overlay currently has focus */
|
|
124
189
|
isFocused(): boolean;
|
|
190
|
+
/** Get the most recent rendered bounds for a visible overlay. */
|
|
191
|
+
getBounds(): OverlayBounds | undefined;
|
|
125
192
|
}
|
|
126
193
|
/**
|
|
127
194
|
* Container - a component that contains other components
|
|
128
195
|
*/
|
|
129
196
|
export declare class Container implements Component {
|
|
130
197
|
children: Component[];
|
|
198
|
+
private mouseLayout?;
|
|
131
199
|
addChild(component: Component): void;
|
|
132
200
|
removeChild(component: Component): void;
|
|
133
201
|
clear(): void;
|
|
134
202
|
invalidate(): void;
|
|
203
|
+
handleMouse(event: TuiMouseEvent): TuiMouseDispatchResult | undefined;
|
|
135
204
|
render(width: number): string[];
|
|
136
205
|
}
|
|
137
|
-
/**
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
export
|
|
206
|
+
/** Composite overlay content into a terminal line at a fixed column. */
|
|
207
|
+
export declare function compositeTuiLine(baseLine: string, overlayLine: string, startCol: number, overlayWidth: number, totalWidth: number): string;
|
|
208
|
+
export type TuiMode = "regular" | "fullscreen";
|
|
209
|
+
export interface TuiStopOptions {
|
|
210
|
+
/** Leave renderer output in place for another TUI taking over the same terminal. */
|
|
211
|
+
preserveScreen?: boolean;
|
|
212
|
+
}
|
|
213
|
+
export interface TUI extends Component {
|
|
214
|
+
readonly mode: TuiMode;
|
|
215
|
+
children: Component[];
|
|
216
|
+
terminal: Terminal;
|
|
217
|
+
onDebug?: () => void;
|
|
218
|
+
readonly fullRedraws: number;
|
|
219
|
+
addChild(component: Component): void;
|
|
220
|
+
removeChild(component: Component): void;
|
|
221
|
+
clear(): void;
|
|
222
|
+
getShowHardwareCursor(): boolean;
|
|
223
|
+
setShowHardwareCursor(enabled: boolean): void;
|
|
224
|
+
getClearOnShrink(): boolean;
|
|
225
|
+
setClearOnShrink(enabled: boolean): void;
|
|
226
|
+
setFocus(component: Component | null): void;
|
|
227
|
+
showOverlay(component: Component, options?: OverlayOptions): OverlayHandle;
|
|
228
|
+
hideOverlay(): void;
|
|
229
|
+
hasOverlay(): boolean;
|
|
230
|
+
start(): void;
|
|
231
|
+
stop(options?: TuiStopOptions): void;
|
|
232
|
+
renderNow(force?: boolean): void;
|
|
233
|
+
requestRender(force?: boolean): void;
|
|
234
|
+
addInputListener(listener: TuiInputListener): () => void;
|
|
235
|
+
removeInputListener(listener: TuiInputListener): void;
|
|
236
|
+
onTerminalColorSchemeChange(listener: (scheme: TerminalColorScheme) => void): () => void;
|
|
237
|
+
setTerminalColorSchemeNotifications(enabled: boolean): void;
|
|
238
|
+
queryTerminalColors(options: {
|
|
239
|
+
timeoutMs: number;
|
|
240
|
+
onLateReply?: (colors: TerminalColors) => void;
|
|
241
|
+
}): Promise<TerminalColors>;
|
|
242
|
+
}
|
|
243
|
+
export declare const VIEWPORT_TUI: unique symbol;
|
|
244
|
+
export interface ViewportTUI extends TUI {
|
|
245
|
+
readonly [VIEWPORT_TUI]: true;
|
|
246
|
+
setLayoutRoot(component: Component | undefined): void;
|
|
247
|
+
}
|
|
248
|
+
export declare function isViewportTUI(tui: TUI): tui is ViewportTUI;
|
|
249
|
+
export declare abstract class TuiBase extends Container implements TUI {
|
|
250
|
+
abstract readonly mode: TuiMode;
|
|
141
251
|
terminal: Terminal;
|
|
142
|
-
private previousLines;
|
|
143
|
-
private previousKittyImageIds;
|
|
144
|
-
private previousWidth;
|
|
145
|
-
private previousHeight;
|
|
146
252
|
private focusedComponent;
|
|
147
253
|
private inputListeners;
|
|
148
254
|
/** Global callback for debug key (Shift+Ctrl+D). Called before input is forwarded to focused component. */
|
|
149
255
|
onDebug?: () => void;
|
|
150
256
|
private renderRequested;
|
|
257
|
+
private immediateRenderScheduled;
|
|
151
258
|
private renderTimer;
|
|
152
259
|
private lastRenderAt;
|
|
153
260
|
private static readonly MIN_RENDER_INTERVAL_MS;
|
|
154
|
-
private cursorRow;
|
|
155
|
-
private hardwareCursorRow;
|
|
156
261
|
private showHardwareCursor;
|
|
157
262
|
private clearOnShrink;
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
263
|
+
protected fullRedrawCount: number;
|
|
264
|
+
protected stopped: boolean;
|
|
265
|
+
/**
|
|
266
|
+
* Color queries waiting for their DA1 reply, oldest first. Terminals answer in order, so color
|
|
267
|
+
* replies belong to the oldest one. Queries stay here after a timeout to collect late replies.
|
|
268
|
+
*/
|
|
269
|
+
private pendingTerminalColorQueries;
|
|
164
270
|
private terminalColorSchemeListeners;
|
|
165
271
|
private terminalColorSchemeNotificationsEnabled;
|
|
166
|
-
|
|
272
|
+
/** Directory for debug/crash logs. When undefined, debug logging is disabled and crash dumps fall back to the OS temp directory. */
|
|
273
|
+
protected readonly logDirectory: string | undefined;
|
|
167
274
|
private focusOrderCounter;
|
|
168
275
|
private overlayStack;
|
|
276
|
+
private renderedOverlayLayouts;
|
|
277
|
+
get hasOverlayEntries(): boolean;
|
|
169
278
|
private overlayFocusRestore;
|
|
170
279
|
constructor(terminal: Terminal, showHardwareCursor?: boolean, logDirectory?: string);
|
|
280
|
+
protected abstract doRender(): void;
|
|
281
|
+
protected resetRenderState(): void;
|
|
282
|
+
protected beforeTerminalStart(): void;
|
|
283
|
+
protected afterTerminalStart(): void;
|
|
284
|
+
protected beforeTerminalStop(_options: TuiStopOptions): void;
|
|
285
|
+
protected afterTerminalStop(_options: TuiStopOptions): void;
|
|
171
286
|
get fullRedraws(): number;
|
|
172
287
|
getShowHardwareCursor(): boolean;
|
|
173
288
|
setShowHardwareCursor(enabled: boolean): void;
|
|
174
289
|
getClearOnShrink(): boolean;
|
|
175
290
|
/**
|
|
176
291
|
* Set whether to trigger full re-render when content shrinks.
|
|
177
|
-
* When true
|
|
178
|
-
* When false, empty rows remain (reduces redraws on slower terminals).
|
|
292
|
+
* When true, empty rows are cleared when content shrinks.
|
|
293
|
+
* When false (default), empty rows remain (reduces redraws on slower terminals).
|
|
179
294
|
*/
|
|
180
295
|
setClearOnShrink(enabled: boolean): void;
|
|
296
|
+
getFocusedComponent(): Component | null;
|
|
181
297
|
setFocus(component: Component | null): void;
|
|
182
298
|
private setFocusInternal;
|
|
183
299
|
private clearOverlayFocusRestore;
|
|
@@ -186,6 +302,7 @@ export declare class TUI extends Container {
|
|
|
186
302
|
private getVisibleOverlayFocusRestore;
|
|
187
303
|
private isOverlayFocusAncestor;
|
|
188
304
|
private retargetOverlayPreFocus;
|
|
305
|
+
protected getMountedRoots(): readonly Component[];
|
|
189
306
|
private isComponentMounted;
|
|
190
307
|
private containsComponent;
|
|
191
308
|
/**
|
|
@@ -195,24 +312,40 @@ export declare class TUI extends Container {
|
|
|
195
312
|
showOverlay(component: Component, options?: OverlayOptions): OverlayHandle;
|
|
196
313
|
/** Hide the topmost overlay and restore previous focus. */
|
|
197
314
|
hideOverlay(): void;
|
|
315
|
+
/** Hide the cursor while running. After stop(), the shell owns the cursor and it must stay visible. */
|
|
316
|
+
private hideTerminalCursor;
|
|
198
317
|
/** Check if there are any visible overlays */
|
|
199
318
|
hasOverlay(): boolean;
|
|
319
|
+
/** Check if the focused component is a visible overlay */
|
|
320
|
+
protected isOverlayFocused(): boolean;
|
|
321
|
+
/** Keep overlay containers as keyboard focus owners when a nested control is clicked. */
|
|
322
|
+
protected resolveMouseFocusTarget(component: Component): Component;
|
|
323
|
+
/** Dispatch to the visually topmost overlay under the pointer. */
|
|
324
|
+
protected dispatchMouseToOverlay(event: TuiMouseEvent): {
|
|
325
|
+
hit: boolean;
|
|
326
|
+
result?: TuiMouseDispatchResult;
|
|
327
|
+
};
|
|
200
328
|
/** Check if an overlay entry is currently visible */
|
|
201
329
|
private isOverlayVisible;
|
|
202
330
|
/** Find the visual-frontmost visible capturing overlay, if any */
|
|
203
331
|
private getTopmostVisibleOverlay;
|
|
204
332
|
invalidate(): void;
|
|
205
333
|
start(): void;
|
|
206
|
-
addInputListener(listener:
|
|
207
|
-
removeInputListener(listener:
|
|
334
|
+
addInputListener(listener: TuiInputListener): () => void;
|
|
335
|
+
removeInputListener(listener: TuiInputListener): void;
|
|
208
336
|
onTerminalColorSchemeChange(listener: (scheme: TerminalColorScheme) => void): () => void;
|
|
209
337
|
setTerminalColorSchemeNotifications(enabled: boolean): void;
|
|
210
338
|
private queryCellSize;
|
|
211
|
-
stop(): void;
|
|
339
|
+
stop(options?: TuiStopOptions): void;
|
|
340
|
+
renderNow(force?: boolean): void;
|
|
212
341
|
requestRender(force?: boolean): void;
|
|
342
|
+
private requestImmediateRender;
|
|
343
|
+
private cancelRenderTimer;
|
|
213
344
|
private scheduleRender;
|
|
214
|
-
private
|
|
215
|
-
private
|
|
345
|
+
private handleTerminalInput;
|
|
346
|
+
private consumeTerminalColorResponse;
|
|
347
|
+
private terminalColorQueryResult;
|
|
348
|
+
private completeTerminalColorQuery;
|
|
216
349
|
private consumeTerminalColorSchemeReport;
|
|
217
350
|
private consumeCellSizeResponse;
|
|
218
351
|
/**
|
|
@@ -223,15 +356,8 @@ export declare class TUI extends Container {
|
|
|
223
356
|
private resolveAnchorRow;
|
|
224
357
|
private resolveAnchorCol;
|
|
225
358
|
/** Composite all overlays into content lines (sorted by focusOrder, higher = on top). */
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
private applyLineResets;
|
|
229
|
-
private collectKittyImageIds;
|
|
230
|
-
private deleteKittyImages;
|
|
231
|
-
private getKittyImageReservedRows;
|
|
232
|
-
private expandChangedRangeForKittyImages;
|
|
233
|
-
private deleteChangedKittyImages;
|
|
234
|
-
/** Splice overlay content into a base line at a specific column. Single-pass optimized. */
|
|
359
|
+
protected compositeOverlays(lines: string[], termWidth: number, termHeight: number): string[];
|
|
360
|
+
protected applyLineResets(lines: string[]): string[];
|
|
235
361
|
private compositeLineAt;
|
|
236
362
|
/**
|
|
237
363
|
* Find and extract cursor position from rendered lines.
|
|
@@ -241,29 +367,21 @@ export declare class TUI extends Container {
|
|
|
241
367
|
* @param height - Terminal height (visible viewport size)
|
|
242
368
|
* @returns Cursor position { row, col } or null if no marker found
|
|
243
369
|
*/
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
* @param cursorPos The cursor position extracted from rendered output, or null
|
|
249
|
-
* @param totalLines Total number of rendered lines
|
|
250
|
-
*/
|
|
251
|
-
private positionHardwareCursor;
|
|
252
|
-
/**
|
|
253
|
-
* Query the terminal's default background color with OSC 11 (`ESC ] 11 ; ? BEL`).
|
|
254
|
-
* @param timeoutMs Query timeout in milliseconds.
|
|
255
|
-
* @returns Promise containing the parsed RGB color, or undefined if it times out or fails to parse.
|
|
256
|
-
*/
|
|
257
|
-
queryTerminalBackgroundColor({ timeoutMs }: {
|
|
258
|
-
timeoutMs: number;
|
|
259
|
-
}): Promise<RgbColor | undefined>;
|
|
370
|
+
protected extractCursorPosition(lines: string[], height: number): {
|
|
371
|
+
row: number;
|
|
372
|
+
col: number;
|
|
373
|
+
} | null;
|
|
260
374
|
/**
|
|
261
|
-
* Query the terminal's
|
|
262
|
-
*
|
|
263
|
-
*
|
|
375
|
+
* Query the terminal's theme colors: the default foreground (OSC 10), the default background
|
|
376
|
+
* (OSC 11), and ANSI colors 0-15 (OSC 4), followed by a DA1 request that marks the end of the
|
|
377
|
+
* replies. Resolves when the DA1 reply or all color replies arrive, or when the timeout expires.
|
|
378
|
+
* Colors the terminal did not report are undefined; the palette is only set when all 16 arrived.
|
|
379
|
+
* @param timeoutMs Query timeout in milliseconds, for terminals that do not answer DA1 either.
|
|
380
|
+
* @param onLateReply Receives the replies if the query completes after the timeout, e.g. over slow links.
|
|
264
381
|
*/
|
|
265
|
-
|
|
382
|
+
queryTerminalColors({ timeoutMs, onLateReply, }: {
|
|
266
383
|
timeoutMs: number;
|
|
267
|
-
|
|
384
|
+
onLateReply?: (colors: TerminalColors) => void;
|
|
385
|
+
}): Promise<TerminalColors>;
|
|
268
386
|
}
|
|
269
387
|
//# sourceMappingURL=tui.d.ts.map
|