@bastani/atomic-tui 0.9.88-alpha.1 → 0.9.89-alpha.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/dist/autocomplete.d.ts +1 -0
- package/dist/autocomplete.d.ts.map +1 -1
- package/dist/autocomplete.js +9 -9
- package/dist/autocomplete.js.map +1 -1
- package/dist/components/editor.d.ts +16 -0
- package/dist/components/editor.d.ts.map +1 -1
- package/dist/components/editor.js +71 -17
- package/dist/components/editor.js.map +1 -1
- package/dist/components/markdown.d.ts +2 -0
- package/dist/components/markdown.d.ts.map +1 -1
- package/dist/components/markdown.js +7 -4
- package/dist/components/markdown.js.map +1 -1
- package/dist/components/scroll-view.d.ts +1 -1
- package/dist/components/scroll-view.d.ts.map +1 -1
- package/dist/components/scroll-view.js +2 -2
- package/dist/components/scroll-view.js.map +1 -1
- package/dist/components/select-list.d.ts +1 -0
- package/dist/components/select-list.d.ts.map +1 -1
- package/dist/components/select-list.js +11 -7
- package/dist/components/select-list.js.map +1 -1
- package/dist/components/windowed-container.d.ts +68 -0
- package/dist/components/windowed-container.d.ts.map +1 -0
- package/dist/components/windowed-container.js +357 -0
- package/dist/components/windowed-container.js.map +1 -0
- package/dist/editor-component.d.ts +1 -0
- package/dist/editor-component.d.ts.map +1 -1
- package/dist/editor-component.js.map +1 -1
- package/dist/fuzzy.d.ts.map +1 -1
- package/dist/fuzzy.js +7 -4
- package/dist/fuzzy.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/layout-node.d.ts +2 -1
- package/dist/layout-node.d.ts.map +1 -1
- package/dist/layout-node.js.map +1 -1
- package/dist/layout.d.ts +4 -0
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +56 -5
- package/dist/layout.js.map +1 -1
- package/dist/stdin-buffer.d.ts.map +1 -1
- package/dist/stdin-buffer.js +5 -0
- package/dist/stdin-buffer.js.map +1 -1
- package/dist/terminal-image.d.ts.map +1 -1
- package/dist/terminal-image.js +20 -13
- package/dist/terminal-image.js.map +1 -1
- package/dist/terminal.d.ts +3 -1
- package/dist/terminal.d.ts.map +1 -1
- package/dist/terminal.js +27 -24
- package/dist/terminal.js.map +1 -1
- package/dist/tui-alt-screen.d.ts +27 -1
- package/dist/tui-alt-screen.d.ts.map +1 -1
- package/dist/tui-alt-screen.js +294 -54
- package/dist/tui-alt-screen.js.map +1 -1
- package/dist/tui-main-screen.d.ts.map +1 -1
- package/dist/tui-main-screen.js +17 -6
- package/dist/tui-main-screen.js.map +1 -1
- package/dist/tui.d.ts +38 -1
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +58 -17
- package/dist/tui.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"windowed-container.js","sourceRoot":"","sources":["../../src/components/windowed-container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAE,MAAM,WAAW,CAAC;AAmBtD,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAChC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAc5B,MAAM,OAAO,GAAG,IAAI,OAAO,EAAoB,CAAC;AAChD,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB,SAAS,SAAS,CAAC,GAAe;IACjC,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;AAC3B,CAAC;AAED,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IAC/C,mGAAmG;IAC3F,UAAU,CAAgC;IAClD,qEAAqE;IAC7D,YAAY,CAAgC;IACpD,sFAAsF;IAC9E,UAAU,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;IAClC,OAAO,GAAY,EAAE,CAAC;IACtB,OAAO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,GAAG,SAAS,CAAC;QACvB,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC;QAC9B,IAAI,KAAK,CAAC,IAAI;YAAE,IAAI,CAAC,eAAe,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAC1D,CAAC;CACD","sourcesContent":["import { type Component, Container } from \"../tui.ts\";\n\nexport interface WindowRows {\n\treadonly length: number;\n\tat(index: number): string | undefined;\n}\n\nexport interface WindowRequest {\n\treadonly width: number;\n\treadonly top: number;\n\treadonly height: number;\n\treadonly followEnd: boolean;\n\treadonly requestRender: () => void;\n}\n\nexport interface WindowLayout extends WindowRows {\n\treadonly top: number;\n}\n\nconst SLICE_BUDGET_MS = 8;\nconst SLICE_CHILDREN = 48;\nconst SWEEP_INTERVAL_MS = 1_000;\nconst MAX_WINDOW_PASSES = 4;\n\ninterface Entry {\n\treadonly component: Component;\n\t/** The windowed container whose children include `component`. */\n\towner: WindowedContainer | undefined;\n\tlines: readonly string[];\n\twidth: number;\n\tcurrent: boolean;\n\theight: number;\n\tindex: number;\n\trenderedIn: number;\n}\n\nconst entries = new WeakMap<Component, Entry>();\nlet staleChanges = 0;\n\nfunction yieldThen(run: () => void): void {\n\tsetImmediate(run).unref();\n}\n\nexport class WindowedContainer extends Container {\n\t/** The container that last laid this one out among its own rows, when this one is nested in it. */\n\tprivate windowHost: WindowedContainer | undefined;\n\t/** The windowed container this one is a child of, in that layout. */\n\tprivate windowParent: WindowedContainer | undefined;\n\t/** The host's laid-out entries this container's children occupied, `[first, end)`. */\n\tprivate windowSpan = { first: 0, end: 0 };\n\tprivate laidOut: Entry[] = [];\n\tprivate offsets: number[] = [0];\n\tprivate staleOffsetsFrom = Number.POSITIVE_INFINITY;\n\tprivate width = 0;\n\tprivate layouts = 0;\n\tprivate windowStart = 0;\n\tprivate windowEnd = 0;\n\tprivate measuredRows = 0;\n\tprivate measuredChildren = 0;\n\tprivate lastRowIndex = 0;\n\tprivate lastTop = 0;\n\tprivate requestRender: (() => void) | undefined;\n\tprivate sweep: { stale: number; up: number; down: number; full: boolean } | undefined;\n\tprivate sweepScheduled = false;\n\tprivate lastFullSweepAt = Number.NEGATIVE_INFINITY;\n\tprivate sweptStale = -1;\n\n\tprotected windowChildren(): readonly Component[] {\n\t\treturn this.children;\n\t}\n\n\toverride invalidate(): void {\n\t\tfor (const child of this.windowChildren()) {\n\t\t\tconst entry = entries.get(child);\n\t\t\tif (entry?.current) {\n\t\t\t\tentry.current = false;\n\t\t\t\tstaleChanges++;\n\t\t\t}\n\t\t}\n\t\tsuper.invalidate();\n\t}\n\n\tlayoutWindow(request: WindowRequest): WindowLayout {\n\t\tconst width = Math.max(1, Math.floor(request.width));\n\t\tconst height = Math.max(0, Math.floor(request.height));\n\t\tthis.requestRender = request.requestRender;\n\t\tconst anchor = request.top === this.lastTop ? this.locateAnchor(request.top) : undefined;\n\t\tif (width !== this.width) {\n\t\t\tthis.width = width;\n\t\t\tfor (const entry of this.laidOut) entry.current = false;\n\t\t\tstaleChanges++;\n\t\t}\n\t\tthis.syncEntries();\n\t\tthis.updateOffsets();\n\t\tconst layout = ++this.layouts;\n\t\tlet top = this.topFor(request, anchor, height);\n\t\tfor (let pass = 0; pass < MAX_WINDOW_PASSES; pass++) {\n\t\t\tif (!this.renderRows(top - height, top + 2 * height, width, layout)) break;\n\t\t\tthis.updateOffsets();\n\t\t\ttop = this.topFor(request, anchor, height);\n\t\t}\n\t\tthis.scheduleSweep();\n\t\tthis.lastTop = top;\n\t\tconst length = this.rowCount();\n\t\treturn { top, length, at: (index) => this.rowAt(index) };\n\t}\n\n\tsettleRows(): void {\n\t\tif (this.width === 0) return;\n\t\tfor (const entry of this.laidOut) this.renderEntry(entry, this.width);\n\t}\n\n\tasync renderInSlices(width: number): Promise<string[]> {\n\t\tconst safeWidth = Math.max(1, Math.floor(width));\n\t\tif (safeWidth !== this.width) {\n\t\t\tthis.width = safeWidth;\n\t\t\tfor (const entry of this.laidOut) entry.current = false;\n\t\t}\n\t\tthis.syncEntries();\n\t\tthis.updateOffsets();\n\t\tlet deadline = performance.now() + SLICE_BUDGET_MS;\n\t\tfor (let index = 0; index < this.laidOut.length; index++) {\n\t\t\tif (performance.now() >= deadline) {\n\t\t\t\tawait new Promise<void>((resolve) => setImmediate(resolve));\n\t\t\t\tdeadline = performance.now() + SLICE_BUDGET_MS;\n\t\t\t}\n\t\t\tconst entry = this.laidOut[index];\n\t\t\tif (entry) this.renderEntry(entry, safeWidth);\n\t\t}\n\t\tconst lines: string[] = [];\n\t\tfor (const entry of this.laidOut) for (const line of entry.lines) lines.push(line);\n\t\treturn lines;\n\t}\n\n\t/**\n\t * The child drawn at `row` as the last layout drew it: an entry, or a nested windowed container with the rows its\n\t * children took. A nested container answers from the layout of the container that laid it out, so its own mouse\n\t * handler sees the rows that were painted. Without a layout at `width`, the children are rendered to measure them.\n\t */\n\toverride childAtRow(width: number, row: number): { component: Component; row: number; height: number } | undefined {\n\t\tconst window = this.windowAt(width);\n\t\tif (!window) return super.childAtRow(width, row);\n\t\tconst { host, first, end } = window;\n\t\tconst base = host.offsets[first] ?? 0;\n\t\tconst absolute = base + row;\n\t\tif (row < 0 || absolute >= (host.offsets[end] ?? base)) return undefined;\n\t\tconst index = host.indexAt(absolute);\n\t\tconst entry = host.laidOut[index];\n\t\tif (!entry || index < first || index >= end) return undefined;\n\t\tlet child: Component = entry.component;\n\t\tlet span = { first: index, end: index + 1 };\n\t\tfor (let owner = entry.owner; owner !== this; owner = owner.windowParent) {\n\t\t\tif (!owner) return undefined;\n\t\t\tchild = owner;\n\t\t\tspan = owner.windowSpan;\n\t\t}\n\t\tconst start = host.offsets[span.first] ?? 0;\n\t\tconst stop = host.offsets[span.end] ?? start;\n\t\tif (absolute < start || absolute >= stop) return undefined;\n\t\treturn { component: child, row: absolute - start, height: stop - start };\n\t}\n\n\tprivate windowAt(width: number): { host: WindowedContainer; first: number; end: number } | undefined {\n\t\tif (this.width === width && this.laidOut.length > 0) return { host: this, first: 0, end: this.laidOut.length };\n\t\tconst host = this.windowHost;\n\t\tif (!host || host.width !== width || host.laidOut.length === 0) return undefined;\n\t\tconst { first, end } = this.windowSpan;\n\t\treturn end > first && end <= host.laidOut.length ? { host, first, end } : undefined;\n\t}\n\n\tprivate rowCount(): number {\n\t\treturn this.offsets[this.laidOut.length] ?? 0;\n\t}\n\n\tprivate rowAt(row: number): string | undefined {\n\t\tif (row < 0 || row >= this.rowCount()) return undefined;\n\t\tlet index = this.lastRowIndex;\n\t\tif (!((this.offsets[index] ?? 0) <= row && row < (this.offsets[index + 1] ?? 0))) index = this.indexAt(row);\n\t\tthis.lastRowIndex = index;\n\t\tconst entry = this.laidOut[index];\n\t\tif (!entry?.current) return \"\";\n\t\treturn entry.lines[row - (this.offsets[index] ?? 0)] ?? \"\";\n\t}\n\n\tprivate indexAt(row: number): number {\n\t\tlet low = 0;\n\t\tlet high = this.laidOut.length - 1;\n\t\twhile (low < high) {\n\t\t\tconst middle = (low + high + 1) >> 1;\n\t\t\tif ((this.offsets[middle] ?? 0) <= row) low = middle;\n\t\t\telse high = middle - 1;\n\t\t}\n\t\treturn Math.max(0, low);\n\t}\n\n\tprivate locateAnchor(top: number): { entry: Entry; within: number } | undefined {\n\t\tif (this.laidOut.length === 0) return undefined;\n\t\tconst index = this.indexAt(Math.max(0, top));\n\t\tconst entry = this.laidOut[index];\n\t\treturn entry ? { entry, within: Math.max(0, top - (this.offsets[index] ?? 0)) } : undefined;\n\t}\n\n\tprivate topFor(\n\t\trequest: WindowRequest,\n\t\tanchor: { entry: Entry; within: number } | undefined,\n\t\theight: number,\n\t): number {\n\t\tconst maxTop = Math.max(0, this.rowCount() - height);\n\t\tif (request.followEnd) return maxTop;\n\t\tlet top = Math.floor(request.top);\n\t\tif (anchor && this.laidOut[anchor.entry.index] === anchor.entry) {\n\t\t\ttop = (this.offsets[anchor.entry.index] ?? 0) + Math.min(anchor.within, Math.max(0, anchor.entry.height - 1));\n\t\t}\n\t\treturn Math.max(0, Math.min(maxTop, top));\n\t}\n\n\tprivate syncEntries(): void {\n\t\tconst laidOut = this.laidOut;\n\t\tlet index = 0;\n\t\tlet rebuilt: Entry[] | undefined;\n\t\tconst position = (): number => rebuilt?.length ?? index;\n\t\tconst visit = (container: WindowedContainer): void => {\n\t\t\tfor (const child of container.windowChildren()) {\n\t\t\t\tif (child instanceof WindowedContainer) {\n\t\t\t\t\tchild.windowHost = this;\n\t\t\t\t\tchild.windowParent = container;\n\t\t\t\t\tconst first = position();\n\t\t\t\t\tvisit(child);\n\t\t\t\t\tchild.windowSpan = { first, end: position() };\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (rebuilt === undefined) {\n\t\t\t\t\tconst kept = laidOut[index];\n\t\t\t\t\tif (kept?.component === child) {\n\t\t\t\t\t\tkept.owner = container;\n\t\t\t\t\t\tindex++;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\trebuilt = laidOut.slice(0, index);\n\t\t\t\t}\n\t\t\t\tconst entry = this.entryFor(child);\n\t\t\t\tentry.owner = container;\n\t\t\t\trebuilt.push(entry);\n\t\t\t}\n\t\t};\n\t\tvisit(this);\n\t\tif (rebuilt === undefined) {\n\t\t\tif (index === laidOut.length) return;\n\t\t\trebuilt = laidOut.slice(0, index);\n\t\t}\n\t\tfor (let position = index; position < rebuilt.length; position++) {\n\t\t\tconst entry = rebuilt[position];\n\t\t\tif (entry) entry.index = position;\n\t\t}\n\t\tthis.laidOut = rebuilt;\n\t\tthis.staleOffsetsFrom = Math.min(this.staleOffsetsFrom, index);\n\t\tthis.lastRowIndex = 0;\n\t}\n\n\tprivate entryFor(component: Component): Entry {\n\t\tlet entry = entries.get(component);\n\t\tif (!entry) {\n\t\t\tconst estimate =\n\t\t\t\tthis.measuredChildren > 0 ? Math.max(1, Math.round(this.measuredRows / this.measuredChildren)) : 1;\n\t\t\tentry = {\n\t\t\t\tcomponent,\n\t\t\t\towner: undefined,\n\t\t\t\tlines: [],\n\t\t\t\twidth: 0,\n\t\t\t\tcurrent: false,\n\t\t\t\theight: estimate,\n\t\t\t\tindex: 0,\n\t\t\t\trenderedIn: 0,\n\t\t\t};\n\t\t\tentries.set(component, entry);\n\t\t\tstaleChanges++;\n\t\t} else if (entry.width !== this.width) {\n\t\t\tentry.current = false;\n\t\t}\n\t\treturn entry;\n\t}\n\n\tprivate updateOffsets(): void {\n\t\tconst from = this.staleOffsetsFrom;\n\t\tif (from === Number.POSITIVE_INFINITY) return;\n\t\tconst { laidOut, offsets } = this;\n\t\toffsets.length = laidOut.length + 1;\n\t\tlet row = from === 0 ? 0 : (offsets[from] ?? 0);\n\t\tfor (let index = from; index < laidOut.length; index++) {\n\t\t\toffsets[index] = row;\n\t\t\trow += laidOut[index]?.height ?? 0;\n\t\t}\n\t\toffsets[laidOut.length] = row;\n\t\tthis.staleOffsetsFrom = Number.POSITIVE_INFINITY;\n\t}\n\n\tprivate renderRows(start: number, end: number, width: number, layout: number): boolean {\n\t\tif (this.laidOut.length === 0) return false;\n\t\tlet changed = false;\n\t\tlet first = this.indexAt(Math.max(0, start));\n\t\twhile (first > 0 && this.offsets[first - 1] === this.offsets[first]) first--;\n\t\tlet index = first;\n\t\tfor (; index < this.laidOut.length && (this.offsets[index] ?? 0) < Math.max(end, 1); index++) {\n\t\t\tconst entry = this.laidOut[index];\n\t\t\tif (!entry || entry.renderedIn === layout) continue;\n\t\t\tentry.renderedIn = layout;\n\t\t\tif (this.renderEntry(entry, width)) changed = true;\n\t\t}\n\t\tthis.windowStart = first;\n\t\tthis.windowEnd = index;\n\t\treturn changed;\n\t}\n\n\tprivate renderEntry(entry: Entry, width: number): boolean {\n\t\tconst lines = entry.component.render(width);\n\t\tif (entry.width === 0) {\n\t\t\tthis.measuredRows += lines.length;\n\t\t\tthis.measuredChildren++;\n\t\t}\n\t\tentry.lines = lines;\n\t\tentry.width = width;\n\t\tentry.current = true;\n\t\tif (entry.height === lines.length) return false;\n\t\tentry.height = lines.length;\n\t\tif (this.laidOut[entry.index] === entry) this.staleOffsetsFrom = Math.min(this.staleOffsetsFrom, entry.index);\n\t\treturn true;\n\t}\n\n\tprivate scheduleSweep(): void {\n\t\tif (this.sweepScheduled) return;\n\t\tthis.sweepScheduled = true;\n\t\tconst run = () => this.sweepSlice();\n\t\tif (this.sweptStale !== staleChanges) yieldThen(run);\n\t\telse setTimeout(run, Math.max(0, this.lastFullSweepAt + SWEEP_INTERVAL_MS - performance.now())).unref();\n\t}\n\n\tprivate sweepSlice(): void {\n\t\tif (this.width === 0) {\n\t\t\tthis.sweepScheduled = false;\n\t\t\treturn;\n\t\t}\n\t\tlet sweep = this.sweep;\n\t\tif (!sweep || sweep.stale !== staleChanges) {\n\t\t\tconst full = sweep?.full ?? this.sweptStale === staleChanges;\n\t\t\tsweep = { stale: staleChanges, up: this.windowStart - 1, down: this.windowEnd, full };\n\t\t\tthis.sweep = sweep;\n\t\t}\n\t\tconst deadline = performance.now() + SLICE_BUDGET_MS;\n\t\tlet rendered = 0;\n\t\tlet moved = false;\n\t\twhile (rendered < SLICE_CHILDREN && performance.now() < deadline) {\n\t\t\tlet index: number;\n\t\t\tif (sweep.up >= 0) index = sweep.up--;\n\t\t\telse if (sweep.down < this.laidOut.length) index = sweep.down++;\n\t\t\telse break;\n\t\t\tconst entry = this.laidOut[index];\n\t\t\tif (!entry || (entry.current && !sweep.full)) continue;\n\t\t\trendered++;\n\t\t\tif (this.renderEntry(entry, this.width)) moved = true;\n\t\t}\n\t\tif (moved) this.requestRender?.();\n\t\tif (sweep.up >= 0 || sweep.down < this.laidOut.length) {\n\t\t\tyieldThen(() => this.sweepSlice());\n\t\t\treturn;\n\t\t}\n\t\tthis.sweep = undefined;\n\t\tthis.sweepScheduled = false;\n\t\tthis.sweptStale = sweep.stale;\n\t\tif (sweep.full) this.lastFullSweepAt = performance.now();\n\t}\n}\n"]}
|
|
@@ -20,6 +20,7 @@ export interface EditorComponent extends Component {
|
|
|
20
20
|
onChange?: (text: string) => void;
|
|
21
21
|
/** Add text to history for up/down navigation */
|
|
22
22
|
addToHistory?(text: string): void;
|
|
23
|
+
getHistory?(): readonly string[];
|
|
23
24
|
/** Insert text at current cursor position */
|
|
24
25
|
insertTextAtCursor?(text: string): void;
|
|
25
26
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-component.d.ts","sourceRoot":"","sources":["../src/editor-component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAKjD,mCAAmC;IACnC,OAAO,IAAI,MAAM,CAAC;IAElB,2BAA2B;IAC3B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5B,qEAAqE;IACrE,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAMhC,iDAAiD;IACjD,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAElC,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAMlC,iDAAiD;IACjD,YAAY,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"editor-component.d.ts","sourceRoot":"","sources":["../src/editor-component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAKjD,mCAAmC;IACnC,OAAO,IAAI,MAAM,CAAC;IAElB,2BAA2B;IAC3B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5B,qEAAqE;IACrE,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAMhC,iDAAiD;IACjD,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAElC,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAMlC,iDAAiD;IACjD,YAAY,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAElC,UAAU,CAAC,IAAI,SAAS,MAAM,EAAE,CAAC;IAMjC,6CAA6C;IAC7C,kBAAkB,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAExC;;;OAGG;IACH,eAAe,CAAC,IAAI,MAAM,CAAC;IAM3B,oCAAoC;IACpC,uBAAuB,CAAC,CAAC,QAAQ,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAM/D,4BAA4B;IAC5B,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IAEtC,6BAA6B;IAC7B,WAAW,CAAC,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpC,qDAAqD;IACrD,yBAAyB,CAAC,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CACrD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-component.js","sourceRoot":"","sources":["../src/editor-component.ts"],"names":[],"mappings":"","sourcesContent":["import type { AutocompleteProvider } from \"./autocomplete.ts\";\nimport type { Component } from \"./tui.ts\";\n\n/**\n * Interface for custom editor components.\n *\n * This allows extensions to provide their own editor implementation\n * (e.g., vim mode, emacs mode, custom keybindings) while maintaining\n * compatibility with the core application.\n */\nexport interface EditorComponent extends Component {\n\t// =========================================================================\n\t// Core text access (required)\n\t// =========================================================================\n\n\t/** Get the current text content */\n\tgetText(): string;\n\n\t/** Set the text content */\n\tsetText(text: string): void;\n\n\t/** Handle raw terminal input (key presses, paste sequences, etc.) */\n\thandleInput(data: string): void;\n\n\t// =========================================================================\n\t// Callbacks (required)\n\t// =========================================================================\n\n\t/** Called when user submits (e.g., Enter key) */\n\tonSubmit?: (text: string) => void;\n\n\t/** Called when text changes */\n\tonChange?: (text: string) => void;\n\n\t// =========================================================================\n\t// History support (optional)\n\t// =========================================================================\n\n\t/** Add text to history for up/down navigation */\n\taddToHistory?(text: string): void;\n\n\t// =========================================================================\n\t// Advanced text manipulation (optional)\n\t// =========================================================================\n\n\t/** Insert text at current cursor position */\n\tinsertTextAtCursor?(text: string): void;\n\n\t/**\n\t * Get text with any markers expanded (e.g., paste markers).\n\t * Falls back to getText() if not implemented.\n\t */\n\tgetExpandedText?(): string;\n\n\t// =========================================================================\n\t// Autocomplete support (optional)\n\t// =========================================================================\n\n\t/** Set the autocomplete provider */\n\tsetAutocompleteProvider?(provider: AutocompleteProvider): void;\n\n\t// =========================================================================\n\t// Appearance (optional)\n\t// =========================================================================\n\n\t/** Border color function */\n\tborderColor?: (str: string) => string;\n\n\t/** Set horizontal padding */\n\tsetPaddingX?(padding: number): void;\n\n\t/** Set max visible items in autocomplete dropdown */\n\tsetAutocompleteMaxVisible?(maxVisible: number): void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"editor-component.js","sourceRoot":"","sources":["../src/editor-component.ts"],"names":[],"mappings":"","sourcesContent":["import type { AutocompleteProvider } from \"./autocomplete.ts\";\nimport type { Component } from \"./tui.ts\";\n\n/**\n * Interface for custom editor components.\n *\n * This allows extensions to provide their own editor implementation\n * (e.g., vim mode, emacs mode, custom keybindings) while maintaining\n * compatibility with the core application.\n */\nexport interface EditorComponent extends Component {\n\t// =========================================================================\n\t// Core text access (required)\n\t// =========================================================================\n\n\t/** Get the current text content */\n\tgetText(): string;\n\n\t/** Set the text content */\n\tsetText(text: string): void;\n\n\t/** Handle raw terminal input (key presses, paste sequences, etc.) */\n\thandleInput(data: string): void;\n\n\t// =========================================================================\n\t// Callbacks (required)\n\t// =========================================================================\n\n\t/** Called when user submits (e.g., Enter key) */\n\tonSubmit?: (text: string) => void;\n\n\t/** Called when text changes */\n\tonChange?: (text: string) => void;\n\n\t// =========================================================================\n\t// History support (optional)\n\t// =========================================================================\n\n\t/** Add text to history for up/down navigation */\n\taddToHistory?(text: string): void;\n\n\tgetHistory?(): readonly string[];\n\n\t// =========================================================================\n\t// Advanced text manipulation (optional)\n\t// =========================================================================\n\n\t/** Insert text at current cursor position */\n\tinsertTextAtCursor?(text: string): void;\n\n\t/**\n\t * Get text with any markers expanded (e.g., paste markers).\n\t * Falls back to getText() if not implemented.\n\t */\n\tgetExpandedText?(): string;\n\n\t// =========================================================================\n\t// Autocomplete support (optional)\n\t// =========================================================================\n\n\t/** Set the autocomplete provider */\n\tsetAutocompleteProvider?(provider: AutocompleteProvider): void;\n\n\t// =========================================================================\n\t// Appearance (optional)\n\t// =========================================================================\n\n\t/** Border color function */\n\tborderColor?: (str: string) => string;\n\n\t/** Set horizontal padding */\n\tsetPaddingX?(padding: number): void;\n\n\t/** Set max visible items in autocomplete dropdown */\n\tsetAutocompleteMaxVisible?(maxVisible: number): void;\n}\n"]}
|
package/dist/fuzzy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fuzzy.d.ts","sourceRoot":"","sources":["../src/fuzzy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,UAAU;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACd;
|
|
1
|
+
{"version":3,"file":"fuzzy.d.ts","sourceRoot":"","sources":["../src/fuzzy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,UAAU;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACd;AAkFD,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CA2BlE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,CAAC,EAAE,CAsC3F"}
|
package/dist/fuzzy.js
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
* Matches if all query characters appear in order (not necessarily consecutive).
|
|
4
4
|
* Lower score = better match.
|
|
5
5
|
*/
|
|
6
|
+
const WORD_BOUNDARY_BONUS = 10;
|
|
7
|
+
const POSITION_PENALTY = 0.1;
|
|
8
|
+
const BETTER_OCCURRENCE_SPAN = WORD_BOUNDARY_BONUS / POSITION_PENALTY;
|
|
6
9
|
function scorePositions(textLower, positions) {
|
|
7
10
|
let score = 0;
|
|
8
11
|
let lastMatchIndex = -1;
|
|
@@ -22,10 +25,10 @@ function scorePositions(textLower, positions) {
|
|
|
22
25
|
}
|
|
23
26
|
// Reward word boundary matches
|
|
24
27
|
if (i === 0 || /[\s\-_./:]/.test(textLower[i - 1])) {
|
|
25
|
-
score -=
|
|
28
|
+
score -= WORD_BOUNDARY_BONUS;
|
|
26
29
|
}
|
|
27
30
|
// Slight penalty for later matches
|
|
28
|
-
score += i *
|
|
31
|
+
score += i * POSITION_PENALTY;
|
|
29
32
|
lastMatchIndex = i;
|
|
30
33
|
}
|
|
31
34
|
return score;
|
|
@@ -51,8 +54,8 @@ function matchQuery(normalizedQuery, textLower) {
|
|
|
51
54
|
let score = scorePositions(textLower, positions);
|
|
52
55
|
// The greedy alignment can scatter the query over an earlier, unrelated part of the text,
|
|
53
56
|
// e.g. "opus" in "openrouter openrouter/anthropic/claude-opus" takes o, p, u from "openrouter".
|
|
54
|
-
|
|
55
|
-
for (let start =
|
|
57
|
+
const firstStart = textLower.indexOf(normalizedQuery);
|
|
58
|
+
for (let start = firstStart; start !== -1 && start - firstStart <= BETTER_OCCURRENCE_SPAN; start = textLower.indexOf(normalizedQuery, start + 1)) {
|
|
56
59
|
for (let k = 0; k < positions.length; k++) {
|
|
57
60
|
positions[k] = start + k;
|
|
58
61
|
}
|
package/dist/fuzzy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fuzzy.js","sourceRoot":"","sources":["../src/fuzzy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,SAAS,cAAc,CAAC,SAAiB,EAAE,SAA4B;IACtE,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,cAAc,GAAG,CAAC,CAAC,CAAC;IACxB,IAAI,kBAAkB,GAAG,CAAC,CAAC;IAE3B,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE,CAAC;QAC3B,6BAA6B;QAC7B,IAAI,cAAc,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YAC9B,kBAAkB,EAAE,CAAC;YACrB,KAAK,IAAI,kBAAkB,GAAG,CAAC,CAAC;QACjC,CAAC;aAAM,CAAC;YACP,kBAAkB,GAAG,CAAC,CAAC;YACvB,gBAAgB;YAChB,IAAI,cAAc,IAAI,CAAC,EAAE,CAAC;gBACzB,KAAK,IAAI,CAAC,CAAC,GAAG,cAAc,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;YACvC,CAAC;QACF,CAAC;QAED,+BAA+B;QAC/B,IAAI,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAE,CAAC,EAAE,CAAC;YACrD,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"fuzzy.js","sourceRoot":"","sources":["../src/fuzzy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,MAAM,sBAAsB,GAAG,mBAAmB,GAAG,gBAAgB,CAAC;AAEtE,SAAS,cAAc,CAAC,SAAiB,EAA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n * Matches if all query characters appear in order (not necessarily consecutive).\n * Lower score = better match.\n */\n\nexport interface FuzzyMatch {\n\tmatches: boolean;\n\tscore: number;\n}\n\nconst WORD_BOUNDARY_BONUS = 10;\nconst POSITION_PENALTY = 0.1;\nconst BETTER_OCCURRENCE_SPAN = WORD_BOUNDARY_BONUS / POSITION_PENALTY;\n\nfunction scorePositions(textLower: string, positions: readonly number[]): number {\n\tlet score = 0;\n\tlet lastMatchIndex = -1;\n\tlet consecutiveMatches = 0;\n\n\tfor (const i of positions) {\n\t\t// Reward consecutive matches\n\t\tif (lastMatchIndex === i - 1) {\n\t\t\tconsecutiveMatches++;\n\t\t\tscore -= consecutiveMatches * 5;\n\t\t} else {\n\t\t\tconsecutiveMatches = 0;\n\t\t\t// Penalize gaps\n\t\t\tif (lastMatchIndex >= 0) {\n\t\t\t\tscore += (i - lastMatchIndex - 1) * 2;\n\t\t\t}\n\t\t}\n\n\t\t// Reward word boundary matches\n\t\tif (i === 0 || /[\\s\\-_./:]/.test(textLower[i - 1]!)) {\n\t\t\tscore -= WORD_BOUNDARY_BONUS;\n\t\t}\n\n\t\t// Slight penalty for later matches\n\t\tscore += i * POSITION_PENALTY;\n\n\t\tlastMatchIndex = i;\n\t}\n\n\treturn score;\n}\n\nfunction matchQuery(normalizedQuery: string, textLower: string): FuzzyMatch {\n\tif (normalizedQuery.length === 0) {\n\t\treturn { matches: true, score: 0 };\n\t}\n\n\tif (normalizedQuery.length > textLower.length) {\n\t\treturn { matches: false, score: 0 };\n\t}\n\n\t// Greedy alignment: each query character at its first occurrence after the previous one.\n\tconst positions: number[] = [];\n\tlet lastMatchIndex = -1;\n\tfor (let queryIndex = 0; queryIndex < normalizedQuery.length; queryIndex++) {\n\t\tconst i = textLower.indexOf(normalizedQuery[queryIndex]!, lastMatchIndex + 1);\n\t\tif (i === -1) {\n\t\t\treturn { matches: false, score: 0 };\n\t\t}\n\t\tpositions.push(i);\n\t\tlastMatchIndex = i;\n\t}\n\n\tlet score = scorePositions(textLower, positions);\n\n\t// The greedy alignment can scatter the query over an earlier, unrelated part of the text,\n\t// e.g. \"opus\" in \"openrouter openrouter/anthropic/claude-opus\" takes o, p, u from \"openrouter\".\n\tconst firstStart = textLower.indexOf(normalizedQuery);\n\tfor (\n\t\tlet start = firstStart;\n\t\tstart !== -1 && start - firstStart <= BETTER_OCCURRENCE_SPAN;\n\t\tstart = textLower.indexOf(normalizedQuery, start + 1)\n\t) {\n\t\tfor (let k = 0; k < positions.length; k++) {\n\t\t\tpositions[k] = start + k;\n\t\t}\n\t\tscore = Math.min(score, scorePositions(textLower, positions));\n\t}\n\n\tif (normalizedQuery === textLower) {\n\t\tscore -= 100;\n\t}\n\n\treturn { matches: true, score };\n}\n\nexport function fuzzyMatch(query: string, text: string): FuzzyMatch {\n\tconst queryLower = query.toLowerCase();\n\tconst textLower = text.toLowerCase();\n\n\tconst primaryMatch = matchQuery(queryLower, textLower);\n\tif (primaryMatch.matches) {\n\t\treturn primaryMatch;\n\t}\n\n\tconst alphaNumericMatch = queryLower.match(/^(?<letters>[a-z]+)(?<digits>[0-9]+)$/);\n\tconst numericAlphaMatch = queryLower.match(/^(?<digits>[0-9]+)(?<letters>[a-z]+)$/);\n\tconst swappedQuery = alphaNumericMatch\n\t\t? `${alphaNumericMatch.groups?.digits ?? \"\"}${alphaNumericMatch.groups?.letters ?? \"\"}`\n\t\t: numericAlphaMatch\n\t\t\t? `${numericAlphaMatch.groups?.letters ?? \"\"}${numericAlphaMatch.groups?.digits ?? \"\"}`\n\t\t\t: \"\";\n\n\tif (!swappedQuery) {\n\t\treturn primaryMatch;\n\t}\n\n\tconst swappedMatch = matchQuery(swappedQuery, textLower);\n\tif (!swappedMatch.matches) {\n\t\treturn primaryMatch;\n\t}\n\n\treturn { matches: true, score: swappedMatch.score + 5 };\n}\n\n/**\n * Filter and sort items by fuzzy match quality (best matches first).\n * Supports whitespace- and slash-separated tokens: all tokens must match.\n */\nexport function fuzzyFilter<T>(items: T[], query: string, getText: (item: T) => string): T[] {\n\tif (!query.trim()) {\n\t\treturn items;\n\t}\n\n\tconst tokens = query\n\t\t.trim()\n\t\t.split(/[\\s/]+/)\n\t\t.filter((t) => t.length > 0);\n\n\tif (tokens.length === 0) {\n\t\treturn items;\n\t}\n\n\tconst results: { item: T; totalScore: number }[] = [];\n\n\tfor (const item of items) {\n\t\tconst text = getText(item);\n\t\tlet totalScore = 0;\n\t\tlet allMatch = true;\n\n\t\tfor (const token of tokens) {\n\t\t\tconst match = fuzzyMatch(token, text);\n\t\t\tif (match.matches) {\n\t\t\t\ttotalScore += match.score;\n\t\t\t} else {\n\t\t\t\tallMatch = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (allMatch) {\n\t\t\tresults.push({ item, totalScore });\n\t\t}\n\t}\n\n\tresults.sort((a, b) => a.totalScore - b.totalScore);\n\treturn results.map((r) => r.item);\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { type AutocompleteItem, type AutocompleteProvider, type AutocompleteSugg
|
|
|
3
3
|
export { backgroundAnsi, type Color, type ColorMixSpace, colorToHex, colorToOkhsl, colorToOklch, colorToRgb, foregroundAnsi, type IndexedColor, indexedColor, mixColors, type OkhslChannels, type OklchChannels, type OklchColorValue, okhslColor, oklchColor, parseColor, type RgbColorValue, rgbColor, styleText, styleTextWithAnsi, type TerminalColorMode, type TextAttributes, type TextStyle, } from "./colors.ts";
|
|
4
4
|
export { Box } from "./components/box.ts";
|
|
5
5
|
export { CancellableLoader } from "./components/cancellable-loader.ts";
|
|
6
|
-
export { Editor, type EditorOptions, type EditorTheme } from "./components/editor.ts";
|
|
6
|
+
export { Editor, type EditorAutocompleteHintEntry, type EditorOptions, type EditorTheme, } from "./components/editor.ts";
|
|
7
7
|
export { HStack } from "./components/h-stack.ts";
|
|
8
8
|
export { Image, type ImageOptions, type ImageTheme, type ImageTranscoder, setImageTranscoder, } from "./components/image.ts";
|
|
9
9
|
export { Input } from "./components/input.ts";
|
|
@@ -17,6 +17,7 @@ export { Spacer } from "./components/spacer.ts";
|
|
|
17
17
|
export { Text } from "./components/text.ts";
|
|
18
18
|
export { TruncatedText } from "./components/truncated-text.ts";
|
|
19
19
|
export { type StackChild, type StackEntry, type StackEntryOptions, type StackOptions, VStack, } from "./components/v-stack.ts";
|
|
20
|
+
export { WindowedContainer, type WindowLayout, type WindowRequest, type WindowRows, } from "./components/windowed-container.ts";
|
|
20
21
|
export type { EditorComponent } from "./editor-component.ts";
|
|
21
22
|
export { type FuzzyMatch, fuzzyFilter, fuzzyMatch } from "./fuzzy.ts";
|
|
22
23
|
export { getKeybindings, getSelectPageIndex, type Keybinding, type KeybindingConflict, type KeybindingDefinition, type KeybindingDefinitions, type Keybindings, type KeybindingsConfig, KeybindingsManager, setKeybindings, TUI_KEYBINDINGS, } from "./keybindings.ts";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,KAAK,KAAK,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEzD,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,4BAA4B,EAC5B,KAAK,YAAY,GACjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACN,cAAc,EACd,KAAK,KAAK,EACV,KAAK,aAAa,EAClB,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,cAAc,EACd,KAAK,YAAY,EACjB,YAAY,EACZ,SAAS,EACT,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,UAAU,EACV,UAAU,EACV,UAAU,EACV,KAAK,aAAa,EAClB,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,SAAS,GACd,MAAM,a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B,KAAK,oBAAoB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,KAAK,SAAS,EACd,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,KAAK,SAAS,EACd,WAAW,EACX,aAAa,EACb,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,gBAAgB,EAChB,KAAK,SAAS,EACd,KAAK,GAAG,EACR,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,WAAW,GAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EAAE,aAAa,EAAE,KAAK,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEpF,OAAO,EACN,mBAAmB,EACnB,wBAAwB,EACxB,aAAa,EACb,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,gBAAgB,GAChB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ export { backgroundAnsi, colorToHex, colorToOkhsl, colorToOklch, colorToRgb, for
|
|
|
7
7
|
// Components
|
|
8
8
|
export { Box } from "./components/box.js";
|
|
9
9
|
export { CancellableLoader } from "./components/cancellable-loader.js";
|
|
10
|
-
export { Editor } from "./components/editor.js";
|
|
10
|
+
export { Editor, } from "./components/editor.js";
|
|
11
11
|
export { HStack } from "./components/h-stack.js";
|
|
12
12
|
export { Image, setImageTranscoder, } from "./components/image.js";
|
|
13
13
|
export { Input } from "./components/input.js";
|
|
@@ -21,6 +21,7 @@ export { Spacer } from "./components/spacer.js";
|
|
|
21
21
|
export { Text } from "./components/text.js";
|
|
22
22
|
export { TruncatedText } from "./components/truncated-text.js";
|
|
23
23
|
export { VStack, } from "./components/v-stack.js";
|
|
24
|
+
export { WindowedContainer, } from "./components/windowed-container.js";
|
|
24
25
|
// Fuzzy matching
|
|
25
26
|
export { fuzzyFilter, fuzzyMatch } from "./fuzzy.js";
|
|
26
27
|
// Keybindings
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAElC,OAAO,EAAE,MAAM,EAA2B,MAAM,QAAQ,CAAC;AACzD,uBAAuB;AACvB,OAAO,EAIN,4BAA4B,GAE5B,MAAM,mBAAmB,CAAC;AAC3B,qBAAqB;AACrB,OAAO,EACN,cAAc,EAGd,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,cAAc,EAEd,YAAY,EACZ,SAAS,EAIT,UAAU,EACV,UAAU,EACV,UAAU,EAEV,QAAQ,EACR,SAAS,EACT,iBAAiB,GAIjB,MAAM,aAAa,CAAC;AACrB,aAAa;AACb,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAElC,OAAO,EAAE,MAAM,EAA2B,MAAM,QAAQ,CAAC;AACzD,uBAAuB;AACvB,OAAO,EAIN,4BAA4B,GAE5B,MAAM,mBAAmB,CAAC;AAC3B,qBAAqB;AACrB,OAAO,EACN,cAAc,EAGd,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,cAAc,EAEd,YAAY,EACZ,SAAS,EAIT,UAAU,EACV,UAAU,EACV,UAAU,EAEV,QAAQ,EACR,SAAS,E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tB,eAAe,EACf,YAAY,EACZ,gBAAgB,GAChB,MAAM,YAAY,CAAC","sourcesContent":["// Core TUI interfaces and classes\n\nexport { Marked, type Token, type Tokens } from \"marked\";\n// Autocomplete support\nexport {\n\ttype AutocompleteItem,\n\ttype AutocompleteProvider,\n\ttype AutocompleteSuggestions,\n\tCombinedAutocompleteProvider,\n\ttype SlashCommand,\n} from \"./autocomplete.ts\";\n// Colors and styling\nexport {\n\tbackgroundAnsi,\n\ttype Color,\n\ttype ColorMixSpace,\n\tcolorToHex,\n\tcolorToOkhsl,\n\tcolorToOklch,\n\tcolorToRgb,\n\tforegroundAnsi,\n\ttype IndexedColor,\n\tindexedColor,\n\tmixColors,\n\ttype OkhslChannels,\n\ttype OklchChannels,\n\ttype OklchColorValue,\n\tokhslColor,\n\toklchColor,\n\tparseColor,\n\ttype RgbColorValue,\n\trgbColor,\n\tstyleText,\n\tstyleTextWithAnsi,\n\ttype TerminalColorMode,\n\ttype TextAttributes,\n\ttype TextStyle,\n} from \"./colors.ts\";\n// Components\nexport { Box } from \"./components/box.ts\";\nexport { CancellableLoader } from \"./components/cancellable-loader.ts\";\nexport {\n\tEditor,\n\ttype EditorAutocompleteHintEntry,\n\ttype EditorOptions,\n\ttype EditorTheme,\n} from \"./components/editor.ts\";\nexport { HStack } from \"./components/h-stack.ts\";\nexport {\n\tImage,\n\ttype ImageOptions,\n\ttype ImageTheme,\n\ttype ImageTranscoder,\n\tsetImageTranscoder,\n} from \"./components/image.ts\";\nexport { Input } from \"./components/input.ts\";\nexport { Loader, type LoaderIndicatorOptions } from \"./components/loader.ts\";\nexport { type DefaultTextStyle, Markdown, type MarkdownOptions, type MarkdownTheme } from \"./components/markdown.ts\";\nexport { MouseRegion, type MouseRegionHandler } from \"./components/mouse-region.ts\";\nexport {\n\tScrollView,\n\ttype ScrollViewOptions,\n\ttype ScrollViewScrollbar,\n\ttype ScrollViewScrollToOptions,\n} from \"./components/scroll-view.ts\";\nexport {\n\ttype SelectItem,\n\tSelectList,\n\ttype SelectListLayoutOptions,\n\ttype SelectListTheme,\n\ttype SelectListTruncatePrimaryContext,\n} from \"./components/select-list.ts\";\nexport { type SettingItem, SettingsList, type SettingsListTheme } from \"./components/settings-list.ts\";\nexport { Spacer } from \"./components/spacer.ts\";\nexport { Text } from \"./components/text.ts\";\nexport { TruncatedText } from \"./components/truncated-text.ts\";\nexport {\n\ttype StackChild,\n\ttype StackEntry,\n\ttype StackEntryOptions,\n\ttype StackOptions,\n\tVStack,\n} from \"./components/v-stack.ts\";\nexport {\n\tWindowedContainer,\n\ttype WindowLayout,\n\ttype WindowRequest,\n\ttype WindowRows,\n} from \"./components/windowed-container.ts\";\n// Editor component interface (for custom editors)\nexport type { EditorComponent } from \"./editor-component.ts\";\n// Fuzzy matching\nexport { type FuzzyMatch, fuzzyFilter, fuzzyMatch } from \"./fuzzy.ts\";\n// Keybindings\nexport {\n\tgetKeybindings,\n\tgetSelectPageIndex,\n\ttype Keybinding,\n\ttype KeybindingConflict,\n\ttype KeybindingDefinition,\n\ttype KeybindingDefinitions,\n\ttype Keybindings,\n\ttype KeybindingsConfig,\n\tKeybindingsManager,\n\tsetKeybindings,\n\tTUI_KEYBINDINGS,\n} from \"./keybindings.ts\";\n// Keyboard input handling\nexport {\n\tdecodeKittyPrintable,\n\tdecodePrintableKey,\n\tisKeyRelease,\n\tisKeyRepeat,\n\tisKittyProtocolActive,\n\tKey,\n\ttype KeyEventType,\n\ttype KeyId,\n\tmatchesKey,\n\tparseKey,\n\tsetKittyProtocolActive,\n} from \"./keys.ts\";\n// LaTeX rendering\nexport { type RenderLatexOptions, renderLatex } from \"./latex.ts\";\n// Native platform integration\nexport { getNativeClipboard, type NativeClipboard } from \"./native-platform.ts\";\nexport { oklabToOkhslLightness } from \"./oklab.ts\";\nexport { normalizePastedText } from \"./paste.ts\";\n// Program status reporting (OSC 7501)\nexport { formatProgramStatus, type ProgramStatus } from \"./program-status.ts\";\n// Input buffering for batch splitting\nexport { StdinBuffer, type StdinBufferEventMap, type StdinBufferOptions } from \"./stdin-buffer.ts\";\n// Terminal interface and implementations\nexport { isAppleTerminalSession, ProcessTerminal, type Terminal } from \"./terminal.ts\";\n// Terminal colors\nexport {\n\tparseTerminalColorSchemeReport,\n\ttype RgbColor,\n\ttype TerminalColorScheme,\n\ttype TerminalColors,\n} from \"./terminal-colors.ts\";\n// Terminal image support\nexport {\n\tallocateImageId,\n\ttype CellDimensions,\n\tcalculateImageRows,\n\tdeleteAllKittyImages,\n\tdeleteKittyImage,\n\tdetectCapabilities,\n\tencodeITerm2,\n\tencodeKitty,\n\tgetCapabilities,\n\tgetCellDimensions,\n\tgetGifDimensions,\n\tgetImageDimensions,\n\tgetJpegDimensions,\n\tgetPngDimensions,\n\tgetTerminalColorMode,\n\tgetWebpDimensions,\n\thyperlink,\n\ttype ImageDimensions,\n\ttype ImageProtocol,\n\ttype ImageRenderOptions,\n\timageFallback,\n\trenderImage,\n\tresetCapabilitiesCache,\n\tsetCapabilities,\n\tsetCapabilityOverrides,\n\tsetCellDimensions,\n\ttype TerminalCapabilities,\n} from \"./terminal-image.ts\";\nexport {\n\ttype Component,\n\tContainer,\n\tCURSOR_MARKER,\n\tcompositeTuiLine,\n\ttype Focusable,\n\tisFocusable,\n\tisViewportTUI,\n\ttype OverlayAnchor,\n\ttype OverlayBounds,\n\ttype OverlayHandle,\n\ttype OverlayMargin,\n\ttype OverlayOptions,\n\ttype OverlayUnfocusOptions,\n\trenderFakeCursor,\n\ttype SizeValue,\n\ttype TUI,\n\ttype TuiInputListener,\n\ttype TuiInputListenerResult,\n\ttype TuiMode,\n\ttype TuiMouseButton,\n\ttype TuiMouseEvent,\n\ttype TuiMouseEventResult,\n\ttype TuiMouseEventType,\n\ttype TuiStopOptions,\n\ttype ViewportTUI,\n} from \"./tui.ts\";\nexport { TuiAltScreen, type TuiAltScreenOptions, turnPromptAbove } from \"./tui-alt-screen.ts\";\nexport { TuiMainScreen, type TuiMainScreenRenderState } from \"./tui-main-screen.ts\";\n// Utilities\nexport {\n\tgetOsc8LinkAtColumn,\n\treplaceControlCharacters,\n\tsliceByColumn,\n\tstripTerminalSequences,\n\ttruncateToWidth,\n\tvisibleWidth,\n\twrapTextWithAnsi,\n} from \"./utils.ts\";\nexport type { WheelScrollLines } from \"./wheel-scroll.ts\";\n"]}
|
package/dist/layout-node.d.ts
CHANGED
|
@@ -24,8 +24,9 @@ export interface ScrollLayoutState {
|
|
|
24
24
|
readonly primary: boolean;
|
|
25
25
|
readonly overscroll: "chain" | "contain";
|
|
26
26
|
readonly viewportHeight: number;
|
|
27
|
+
readonly isFollowingEnd: boolean;
|
|
27
28
|
getContentWidth(width: number): number;
|
|
28
|
-
updateLayout(contentHeight: number, viewportHeight: number, requestRender: () => void): void;
|
|
29
|
+
updateLayout(contentHeight: number, viewportHeight: number, requestRender: () => void, anchoredScrollTop?: number): void;
|
|
29
30
|
}
|
|
30
31
|
export interface ScrollLayoutNode {
|
|
31
32
|
type: "scroll";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout-node.d.ts","sourceRoot":"","sources":["../src/layout-node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,eAAO,MAAM,WAAW,eAAgD,CAAC;AAEzE,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAChC,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,OAAO,CAAC;CAChD;AAED,MAAM,WAAW,eAAe;IAC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AO,GAAG,QAAQ,GAAG,KAAK,CAAC;CAC9C;AAED,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,OAAO,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvC,YAAY,CACX,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,IAAI,EACzB,iBAAiB,CAAC,EAAE,MAAM,GACxB,IAAI,CAAC;CACR;AAED,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,EAAE,iBAAiB,CAAC;CACzB;AAED,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG,gBAAgB,CAAC;AAE5D,MAAM,WAAW,eAAgB,SAAQ,SAAS;IACjD,CAAC,WAAW,CAAC,IAAI,UAAU,CAAC;CAC5B;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,CAG1E"}
|
package/dist/layout-node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout-node.js","sourceRoot":"","sources":["../src/layout-node.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"layout-node.js","sourceRoot":"","sources":["../src/layout-node.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;AAmDzE,MAAM,UAAU,aAAa,CAAC,SAAoB;IACjD,MAAM,SAAS,GAAG,SAAqC,CAAC;IACxD,OAAO,OAAO,SAAS,CAAC,WAAW,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5F,CAAC","sourcesContent":["import type { Component } from \"./tui.ts\";\n\nexport const LAYOUT_NODE = Symbol.for(\"@bastani/atomic-tui/layout-node\");\n\nexport interface LayoutViewport {\n\twidth: number;\n\theight: number;\n}\n\nexport interface StackLayoutEntry {\n\tcomponent: Component;\n\tbasis?: number | \"auto\";\n\tgrow?: number;\n\tshrink?: number;\n\tminSize?: number;\n\tmaxSize?: number;\n\tvisible?: (viewport: LayoutViewport) => boolean;\n}\n\nexport interface StackLayoutNode {\n\ttype: \"vstack\" | \"hstack\";\n\tentries: readonly StackLayoutEntry[];\n\tgap: number;\n\talign: \"stretch\" | \"start\" | \"center\" | \"end\";\n}\n\nexport interface ScrollLayoutState {\n\treadonly scrollTop: number;\n\treadonly primary: boolean;\n\treadonly overscroll: \"chain\" | \"contain\";\n\treadonly viewportHeight: number;\n\treadonly isFollowingEnd: boolean;\n\tgetContentWidth(width: number): number;\n\tupdateLayout(\n\t\tcontentHeight: number,\n\t\tviewportHeight: number,\n\t\trequestRender: () => void,\n\t\tanchoredScrollTop?: number,\n\t): void;\n}\n\nexport interface ScrollLayoutNode {\n\ttype: \"scroll\";\n\tcomponent: Component;\n\tstate: ScrollLayoutState;\n}\n\nexport type LayoutNode = StackLayoutNode | ScrollLayoutNode;\n\nexport interface LayoutComponent extends Component {\n\t[LAYOUT_NODE](): LayoutNode;\n}\n\nexport function getLayoutNode(component: Component): LayoutNode | undefined {\n\tconst candidate = component as Partial<LayoutComponent>;\n\treturn typeof candidate[LAYOUT_NODE] === \"function\" ? candidate[LAYOUT_NODE]() : undefined;\n}\n"]}
|
package/dist/layout.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ScrollView } from "./components/scroll-view.ts";
|
|
2
|
+
import { type WindowRows } from "./components/windowed-container.ts";
|
|
2
3
|
import { type Component } from "./tui.ts";
|
|
3
4
|
export interface LayoutRect {
|
|
4
5
|
x: number;
|
|
@@ -13,9 +14,11 @@ export interface LayoutBox {
|
|
|
13
14
|
children: LayoutBox[];
|
|
14
15
|
parent?: LayoutBox;
|
|
15
16
|
lines?: readonly string[];
|
|
17
|
+
rows?: WindowRows;
|
|
16
18
|
lineOffset?: number;
|
|
17
19
|
scrollView?: ScrollView;
|
|
18
20
|
scrollContentLines?: readonly string[];
|
|
21
|
+
scrollContentRows?: WindowRows;
|
|
19
22
|
layer: number;
|
|
20
23
|
}
|
|
21
24
|
export interface LayoutFrame {
|
|
@@ -33,6 +36,7 @@ export interface ScrollbarGeometry {
|
|
|
33
36
|
thumbHeight: number;
|
|
34
37
|
maxScrollTop: number;
|
|
35
38
|
}
|
|
39
|
+
export declare function getScrollContentRows(box: LayoutBox | undefined): WindowRows | undefined;
|
|
36
40
|
export declare function getScrollbarGeometry(box: LayoutBox, includeHiddenAuto?: boolean): ScrollbarGeometry | undefined;
|
|
37
41
|
export declare function renderLayoutFrame(root: Component, width: number, height: number, requestRender: () => void): LayoutFrame;
|
|
38
42
|
/** Return the visual hit path from the deepest component to the layout root. */
|
package/dist/layout.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../src/layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../src/layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAqB,KAAK,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAGxF,OAAO,EAAE,KAAK,SAAS,EAAmC,MAAM,UAAU,CAAC;AA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,iBAAiB,CAChC,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,IAAI,GACvB,WAAW,CAwBb;AAMD,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE,CAUtF;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,GAAG,SAAS,GAAG,SAAS,CAUlG;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU,EAAE,CAUvF"}
|
package/dist/layout.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { allocateStackSizes, visibleStackEntries } from "./components/stack.js";
|
|
2
|
+
import { WindowedContainer } from "./components/windowed-container.js";
|
|
2
3
|
import { getLayoutNode } from "./layout-node.js";
|
|
3
4
|
import { cropKittyImageLine, getKittyImageMetadata, getMaxKittyImageRows, isImageLine } from "./terminal-image.js";
|
|
4
5
|
import { CURSOR_MARKER, compositeTuiLine } from "./tui.js";
|
|
@@ -70,6 +71,16 @@ function layoutComponent(context, component, x, y, width, height, clip) {
|
|
|
70
71
|
if (node.type === "scroll") {
|
|
71
72
|
const previousScrollTop = node.state.scrollTop;
|
|
72
73
|
const contentWidth = node.state.getContentWidth(safeWidth);
|
|
74
|
+
if (node.component instanceof WindowedContainer && height !== undefined) {
|
|
75
|
+
return layoutWindowedScroll(context, component, node.component, node.state, {
|
|
76
|
+
x,
|
|
77
|
+
y,
|
|
78
|
+
width: safeWidth,
|
|
79
|
+
height: Math.max(0, Math.floor(height)),
|
|
80
|
+
contentWidth,
|
|
81
|
+
clip,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
73
84
|
const childBox = layoutComponent(context, node.component, x, y - previousScrollTop, contentWidth, undefined, clip);
|
|
74
85
|
const contentHeight = childBox.rect.height;
|
|
75
86
|
const viewportHeight = height === undefined ? contentHeight : Math.max(0, Math.floor(height));
|
|
@@ -156,6 +167,44 @@ function layoutComponent(context, component, x, y, width, height, clip) {
|
|
|
156
167
|
}
|
|
157
168
|
return box;
|
|
158
169
|
}
|
|
170
|
+
function layoutWindowedScroll(context, component, content, scrollView, area) {
|
|
171
|
+
const rows = content.layoutWindow({
|
|
172
|
+
width: area.contentWidth,
|
|
173
|
+
top: scrollView.scrollTop,
|
|
174
|
+
height: area.height,
|
|
175
|
+
followEnd: scrollView.isFollowingEnd,
|
|
176
|
+
requestRender: context.requestRender,
|
|
177
|
+
});
|
|
178
|
+
scrollView.updateLayout(rows.length, area.height, context.requestRender, rows.top);
|
|
179
|
+
if (scrollView.primary || !context.primaryScrollView)
|
|
180
|
+
context.primaryScrollView = scrollView;
|
|
181
|
+
const rect = { x: area.x, y: area.y, width: area.width, height: area.height };
|
|
182
|
+
const clip = intersect(area.clip, rect);
|
|
183
|
+
const contentRect = { x: area.x, y: area.y - scrollView.scrollTop, width: area.contentWidth, height: rows.length };
|
|
184
|
+
const contentBox = {
|
|
185
|
+
component: content,
|
|
186
|
+
rect: contentRect,
|
|
187
|
+
clip: intersect(clip, contentRect),
|
|
188
|
+
children: [],
|
|
189
|
+
rows,
|
|
190
|
+
lineOffset: 0,
|
|
191
|
+
layer: 0,
|
|
192
|
+
};
|
|
193
|
+
const box = {
|
|
194
|
+
component,
|
|
195
|
+
rect,
|
|
196
|
+
clip,
|
|
197
|
+
children: [contentBox],
|
|
198
|
+
scrollView,
|
|
199
|
+
scrollContentRows: rows,
|
|
200
|
+
layer: 0,
|
|
201
|
+
};
|
|
202
|
+
contentBox.parent = box;
|
|
203
|
+
return box;
|
|
204
|
+
}
|
|
205
|
+
export function getScrollContentRows(box) {
|
|
206
|
+
return box?.scrollContentRows ?? box?.scrollContentLines;
|
|
207
|
+
}
|
|
159
208
|
function replaceScrollbarCell(line, column, totalWidth, replacement, preserveTargetBackground) {
|
|
160
209
|
if (isImageLine(line))
|
|
161
210
|
return line;
|
|
@@ -183,7 +232,7 @@ function replaceScrollbarCell(line, column, totalWidth, replacement, preserveTar
|
|
|
183
232
|
export function getScrollbarGeometry(box, includeHiddenAuto = false) {
|
|
184
233
|
if (!box.scrollView || box.rect.width <= 0 || box.rect.height <= 0)
|
|
185
234
|
return undefined;
|
|
186
|
-
const contentHeight = box.children[0]?.rect.height ?? box
|
|
235
|
+
const contentHeight = box.children[0]?.rect.height ?? getScrollContentRows(box)?.length ?? 0;
|
|
187
236
|
const trackHeight = box.rect.height;
|
|
188
237
|
const canRevealHiddenAuto = includeHiddenAuto && box.scrollView.scrollbar === "auto" && contentHeight > trackHeight;
|
|
189
238
|
if (!box.scrollView.isScrollbarVisible && !canRevealHiddenAuto)
|
|
@@ -221,12 +270,13 @@ function paintScrollbar(box, screen, totalWidth) {
|
|
|
221
270
|
}
|
|
222
271
|
}
|
|
223
272
|
function paintBox(box, screen, totalWidth) {
|
|
224
|
-
|
|
273
|
+
const source = box.lines ?? box.rows;
|
|
274
|
+
if (source) {
|
|
225
275
|
const offset = box.lineOffset ?? 0;
|
|
226
276
|
const firstRow = Math.max(box.rect.y, box.clip.y, 0);
|
|
227
277
|
const lastRow = Math.min(box.rect.y + box.rect.height, box.clip.y + box.clip.height, screen.length);
|
|
228
278
|
for (let row = firstRow; row < lastRow; row++) {
|
|
229
|
-
const sourceLine =
|
|
279
|
+
const sourceLine = source.at(offset + row - box.rect.y);
|
|
230
280
|
if (sourceLine === undefined)
|
|
231
281
|
continue;
|
|
232
282
|
let line = sourceLine.replace(OSC133_ZONE_PREFIX, "");
|
|
@@ -252,14 +302,15 @@ function paintBox(box, screen, totalWidth) {
|
|
|
252
302
|
}
|
|
253
303
|
for (const child of box.children)
|
|
254
304
|
paintBox(child, screen, totalWidth);
|
|
255
|
-
|
|
305
|
+
const scrollContent = getScrollContentRows(box);
|
|
306
|
+
if (box.scrollView && scrollContent && box.scrollView.scrollTop > 0 && box.rect.height > 0) {
|
|
256
307
|
// Find the nearest image line above the viewport. Placeholder rows below an
|
|
257
308
|
// image line may contain padding, borders, or side-by-side text, so the search
|
|
258
309
|
// is bounded by the tallest registered image instead of by row content.
|
|
259
310
|
const scrollTop = box.scrollView.scrollTop;
|
|
260
311
|
const minRow = Math.max(0, scrollTop - getMaxKittyImageRows());
|
|
261
312
|
for (let imageRow = scrollTop - 1; imageRow >= minRow; imageRow--) {
|
|
262
|
-
const imageLine =
|
|
313
|
+
const imageLine = scrollContent.at(imageRow) ?? "";
|
|
263
314
|
if (!isImageLine(imageLine))
|
|
264
315
|
continue;
|
|
265
316
|
const metadata = getKittyImageMetadata(imageLine);
|