@linxiraos/pi-tui 1.4.7 → 1.4.9
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/CHANGELOG.md +28 -109
- package/README.md +7 -1
- package/dist/types/app-keybindings.d.ts +5 -0
- package/dist/types/charts/table-data.d.ts +4 -2
- package/dist/types/chat/bash-execution.d.ts +4 -1
- package/dist/types/chat/eval-execution.d.ts +2 -0
- package/dist/types/chat/execution-shared.d.ts +14 -8
- package/dist/types/chat/figure-markdown.d.ts +2 -0
- package/dist/types/chat/svg-figure.d.ts +5 -0
- package/dist/types/chat/table-chart.d.ts +2 -0
- package/dist/types/chat/transcript-render-helpers.d.ts +11 -3
- package/dist/types/chrome/dynamic-border.d.ts +6 -0
- package/dist/types/chrome/transcript-status.d.ts +2 -2
- package/dist/types/components/editor.d.ts +15 -6
- package/dist/types/components/image.d.ts +6 -0
- package/dist/types/components/loader.d.ts +2 -0
- package/dist/types/keybinding-matchers.d.ts +7 -0
- package/dist/types/native/describe.d.ts +4 -2
- package/dist/types/native/node.d.ts +2 -3
- package/dist/types/native/overlay.d.ts +42 -2
- package/dist/types/native/state.d.ts +4 -0
- package/dist/types/overlays/btw-history-panel.d.ts +15 -0
- package/dist/types/overlays/btw-history.d.ts +24 -0
- package/dist/types/overlays/btw-inject.d.ts +22 -0
- package/dist/types/overlays/btw-panel.d.ts +7 -0
- package/dist/types/overlays/hook-editor.d.ts +2 -0
- package/dist/types/overlays/jobs-panel.d.ts +4 -0
- package/dist/types/overlays/model-browser.d.ts +1 -1
- package/dist/types/overlays/session-selector.d.ts +11 -2
- package/dist/types/prompt/composer.d.ts +13 -5
- package/dist/types/render/render-utils.d.ts +23 -1
- package/dist/types/status-line/startup.d.ts +0 -15
- package/dist/types/terminal-capabilities.d.ts +1 -1
- package/dist/types/theme/symbols.d.ts +3 -1
- package/dist/types/theme/theme-class.d.ts +1 -0
- package/dist/types/theme/theme.d.ts +1 -1
- package/dist/types/theme/tui-adapters.d.ts +2 -0
- package/dist/types/thinking.d.ts +8 -6
- package/dist/types/tools/ast-grep.d.ts +2 -0
- package/dist/types/tools/eval.d.ts +2 -0
- package/dist/types/tools/find.d.ts +1 -1
- package/dist/types/tools/grouped-file-output.d.ts +100 -19
- package/dist/types/tools/hashline-format.d.ts +5 -0
- package/dist/types/tools/native-view.d.ts +2 -0
- package/dist/types/tools/output-meta.d.ts +27 -0
- package/dist/types/tools/read.d.ts +14 -4
- package/dist/types/tools/task.d.ts +4 -3
- package/dist/types/tools/wait.d.ts +2 -0
- package/dist/types/tui.d.ts +12 -0
- package/dist/types/utils.d.ts +4 -0
- package/package.json +9 -9
- package/src/app-keybindings.d.ts +5 -0
- package/src/app-keybindings.ts +5 -0
- package/src/apps/git/git-tui.ts +10 -17
- package/src/apps/git/sidebar.ts +21 -35
- package/src/apps/ps-top.ts +4 -12
- package/src/charts/chart-plan.ts +0 -29
- package/src/charts/table-data.d.ts +4 -2
- package/src/charts/table-data.ts +55 -6
- package/src/chat/bash-execution.d.ts +4 -1
- package/src/chat/bash-execution.ts +20 -9
- package/src/chat/chat-transcript-builder.ts +5 -2
- package/src/chat/eval-execution.d.ts +2 -0
- package/src/chat/eval-execution.ts +14 -7
- package/src/chat/execution-shared.d.ts +14 -8
- package/src/chat/execution-shared.ts +39 -18
- package/src/chat/figure-markdown.d.ts +2 -0
- package/src/chat/figure-markdown.ts +6 -4
- package/src/chat/read-tool-group.ts +56 -36
- package/src/chat/svg-figure.d.ts +5 -0
- package/src/chat/svg-figure.ts +55 -16
- package/src/chat/table-chart.d.ts +2 -0
- package/src/chat/table-chart.ts +19 -2
- package/src/chat/transcript-render-helpers.d.ts +11 -3
- package/src/chat/transcript-render-helpers.ts +70 -22
- package/src/chrome/dynamic-border.d.ts +6 -0
- package/src/chrome/dynamic-border.ts +28 -2
- package/src/chrome/transcript-status.d.ts +2 -2
- package/src/chrome/transcript-status.ts +5 -3
- package/src/components/editor.d.ts +15 -6
- package/src/components/editor.ts +123 -24
- package/src/components/image.d.ts +6 -0
- package/src/components/image.ts +13 -0
- package/src/components/key-value-list.ts +9 -9
- package/src/components/loader.d.ts +2 -0
- package/src/components/loader.ts +7 -0
- package/src/components/section.ts +1 -9
- package/src/components/table.ts +1 -9
- package/src/keybinding-matchers.d.ts +7 -0
- package/src/keybinding-matchers.ts +13 -0
- package/src/native/backend.ts +7 -3
- package/src/native/describe.d.ts +4 -2
- package/src/native/describe.ts +9 -4
- package/src/native/node.d.ts +2 -3
- package/src/native/node.ts +2 -3
- package/src/native/overlay.d.ts +42 -2
- package/src/native/overlay.ts +124 -16
- package/src/native/state.d.ts +4 -0
- package/src/native/state.ts +25 -5
- package/src/overlays/btw-history-panel.ts +106 -14
- package/src/overlays/btw-history.ts +65 -0
- package/src/overlays/btw-inject.ts +91 -0
- package/src/overlays/btw-panel.ts +53 -12
- package/src/overlays/extensions/extension-dashboard.ts +7 -8
- package/src/overlays/hook-editor.ts +6 -0
- package/src/overlays/jobs-panel.ts +82 -22
- package/src/overlays/login-dialog.ts +8 -26
- package/src/overlays/model-browser.ts +69 -10
- package/src/overlays/session-selector.ts +25 -5
- package/src/overlays/settings-defs.ts +2 -2
- package/src/overlays/tree-selector.ts +83 -27
- package/src/overlays/usage-dashboard.ts +4 -6
- package/src/prompt/composer.ts +17 -5
- package/src/render/code-cell.ts +1 -1
- package/src/render/file-list.ts +4 -7
- package/src/render/render-utils.d.ts +23 -1
- package/src/render/render-utils.ts +38 -6
- package/src/setup/scenes/glyph.ts +1 -1
- package/src/status-line/startup.ts +36 -70
- package/src/terminal-capabilities.d.ts +1 -1
- package/src/terminal-capabilities.ts +5 -0
- package/src/theme/symbols.d.ts +3 -1
- package/src/theme/symbols.ts +16 -9
- package/src/theme/theme-class.d.ts +1 -0
- package/src/theme/theme-class.ts +15 -3
- package/src/theme/theme.d.ts +1 -1
- package/src/theme/theme.ts +1 -0
- package/src/theme/tui-adapters.d.ts +2 -0
- package/src/theme/tui-adapters.ts +8 -3
- package/src/thinking.d.ts +8 -6
- package/src/thinking.ts +17 -11
- package/src/tmux.ts +1 -0
- package/src/tools/agent-tree.ts +13 -11
- package/src/tools/ask.ts +24 -37
- package/src/tools/ast-edit.ts +48 -93
- package/src/tools/ast-grep.d.ts +2 -0
- package/src/tools/ast-grep.ts +31 -67
- package/src/tools/bash.ts +7 -0
- package/src/tools/default-renderer.ts +1 -1
- package/src/tools/edit.ts +50 -43
- package/src/tools/eval.d.ts +2 -0
- package/src/tools/eval.ts +2 -0
- package/src/tools/fetch.ts +2 -1
- package/src/tools/find.d.ts +1 -1
- package/src/tools/find.ts +13 -5
- package/src/tools/github.ts +14 -46
- package/src/tools/glob.ts +2 -1
- package/src/tools/grep.ts +47 -277
- package/src/tools/grouped-file-output.d.ts +100 -19
- package/src/tools/grouped-file-output.ts +414 -103
- package/src/tools/hashline-format.d.ts +5 -0
- package/src/tools/hashline-format.ts +5 -0
- package/src/tools/json-tree.ts +1 -5
- package/src/tools/lsp.ts +210 -32
- package/src/tools/native-view.d.ts +2 -0
- package/src/tools/native-view.ts +11 -5
- package/src/tools/output-meta.d.ts +27 -0
- package/src/tools/output-meta.ts +68 -4
- package/src/tools/proc-render.ts +3 -3
- package/src/tools/read.d.ts +14 -4
- package/src/tools/read.ts +20 -5
- package/src/tools/task.d.ts +4 -3
- package/src/tools/task.ts +41 -81
- package/src/tools/vibe.ts +4 -4
- package/src/tools/wait.d.ts +2 -0
- package/src/tools/wait.ts +8 -5
- package/src/tools/write.ts +17 -27
- package/src/tools/yield.ts +1 -1
- package/src/tui.d.ts +12 -0
- package/src/tui.ts +91 -9
- package/src/utils.d.ts +4 -0
- package/src/utils.ts +10 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Component } from "../tui";
|
|
2
|
+
import { truncateToWidth, visibleWidth } from "../utils";
|
|
2
3
|
import { fgOrPlain, theme } from "../theme/index";
|
|
3
4
|
import type { NativeNode } from "../native/node";
|
|
4
5
|
import { EMPTY_NODE } from "../native/describe";
|
|
@@ -13,7 +14,9 @@ import { EMPTY_NODE } from "../native/describe";
|
|
|
13
14
|
*/
|
|
14
15
|
export class DynamicBorder implements Component {
|
|
15
16
|
#color: (str: string) => string;
|
|
17
|
+
#label: string | (() => string) | undefined;
|
|
16
18
|
#cachedWidth = -1;
|
|
19
|
+
#cachedLabel: string | undefined;
|
|
17
20
|
#cachedLines: string[] | undefined;
|
|
18
21
|
|
|
19
22
|
constructor(color: (str: string) => string = str => fgOrPlain("border", str)) {
|
|
@@ -25,19 +28,42 @@ export class DynamicBorder implements Component {
|
|
|
25
28
|
this.#cachedLines = undefined;
|
|
26
29
|
}
|
|
27
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Pre-styled text set into the rule after a short lead (`─── label ────`);
|
|
33
|
+
* undefined draws a plain rule. A function label is re-read every render,
|
|
34
|
+
* for live text such as a spinner.
|
|
35
|
+
*/
|
|
36
|
+
setLabel(label: string | (() => string) | undefined): void {
|
|
37
|
+
if (label === this.#label) return;
|
|
38
|
+
this.#label = label;
|
|
39
|
+
this.invalidate();
|
|
40
|
+
}
|
|
41
|
+
|
|
28
42
|
/** Native terminals draw their own chrome; a border rule describes nothing. */
|
|
29
43
|
describe(): NativeNode {
|
|
30
44
|
return EMPTY_NODE;
|
|
31
45
|
}
|
|
32
46
|
|
|
33
47
|
render(width: number): readonly string[] {
|
|
34
|
-
|
|
48
|
+
const label = typeof this.#label === "function" ? this.#label() : this.#label;
|
|
49
|
+
if (this.#cachedLines && this.#cachedWidth === width && this.#cachedLabel === label) {
|
|
35
50
|
return this.#cachedLines;
|
|
36
51
|
}
|
|
37
52
|
const horizontal = typeof theme === "undefined" ? "─" : theme.boxRound.horizontal;
|
|
38
|
-
const lines = [this.#
|
|
53
|
+
const lines = [this.#rule(horizontal, Math.max(1, width), label)];
|
|
39
54
|
this.#cachedWidth = width;
|
|
55
|
+
this.#cachedLabel = label;
|
|
40
56
|
this.#cachedLines = lines;
|
|
41
57
|
return lines;
|
|
42
58
|
}
|
|
59
|
+
|
|
60
|
+
#rule(horizontal: string, width: number, label: string | undefined): string {
|
|
61
|
+
const lead = horizontal.repeat(3);
|
|
62
|
+
// The label sits between single spaces and leaves at least one rule cell after it.
|
|
63
|
+
const labelRoom = width - visibleWidth(lead) - 3;
|
|
64
|
+
if (!label || labelRoom < 1) return this.#color(horizontal.repeat(width));
|
|
65
|
+
const fitted = ` ${truncateToWidth(label, labelRoom)} `;
|
|
66
|
+
const rest = width - visibleWidth(lead) - visibleWidth(fitted);
|
|
67
|
+
return `${this.#color(lead)}${fitted}${this.#color(horizontal.repeat(rest))}`;
|
|
68
|
+
}
|
|
43
69
|
}
|
|
@@ -3,10 +3,10 @@ import type { NativeNode } from "../native/node";
|
|
|
3
3
|
import { type ThemeColor } from "../theme";
|
|
4
4
|
import { TranscriptBlock } from "./transcript-container";
|
|
5
5
|
import { type NoticeTone } from "./transcript-notice";
|
|
6
|
-
/** One
|
|
6
|
+
/** One run of a status row's terminal line, in `color` unless the text is already styled. */
|
|
7
7
|
export interface TranscriptStatusPart {
|
|
8
8
|
readonly text: string;
|
|
9
|
-
readonly color
|
|
9
|
+
readonly color?: ThemeColor;
|
|
10
10
|
}
|
|
11
11
|
/** A status row in a native terminal: its {@link noticeRow}'s tone, icon and message. */
|
|
12
12
|
export interface TranscriptStatusNative {
|
|
@@ -6,10 +6,10 @@ import { type ThemeColor, theme } from "../theme";
|
|
|
6
6
|
import { TranscriptBlock } from "./transcript-container";
|
|
7
7
|
import { type NoticeTone, noticeRow } from "./transcript-notice";
|
|
8
8
|
|
|
9
|
-
/** One
|
|
9
|
+
/** One run of a status row's terminal line, in `color` unless the text is already styled. */
|
|
10
10
|
export interface TranscriptStatusPart {
|
|
11
11
|
readonly text: string;
|
|
12
|
-
readonly color
|
|
12
|
+
readonly color?: ThemeColor;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/** A status row in a native terminal: its {@link noticeRow}'s tone, icon and message. */
|
|
@@ -41,7 +41,9 @@ export class TranscriptStatusBlock extends TranscriptBlock {
|
|
|
41
41
|
constructor(rows: readonly TranscriptStatusRow[]) {
|
|
42
42
|
super();
|
|
43
43
|
for (const row of rows) {
|
|
44
|
-
const styled = row.parts.flatMap(part =>
|
|
44
|
+
const styled = row.parts.flatMap(part =>
|
|
45
|
+
part ? [part.color ? theme.fg(part.color, part.text) : part.text] : [],
|
|
46
|
+
);
|
|
45
47
|
this.addChild(new Text(styled.join(" "), row.indent ?? 1, 0));
|
|
46
48
|
}
|
|
47
49
|
this.#native = col(
|
|
@@ -157,12 +157,21 @@ export declare class Editor implements Component, Focusable {
|
|
|
157
157
|
* cursor. The host styles it (ANSI allowed). Re-evaluated on every render, so hosts can derive
|
|
158
158
|
* it from live state. */
|
|
159
159
|
placeholder?: () => string | undefined;
|
|
160
|
-
/** Whole-message
|
|
161
|
-
*
|
|
162
|
-
* autocomplete is open. A shown prediction replaces the {@link placeholder}; Tab or
|
|
163
|
-
* the rest without submitting.
|
|
164
|
-
*
|
|
165
|
-
|
|
160
|
+
/** Whole-message predictions for the next prompt, most likely first. The first one the single-line
|
|
161
|
+
* buffer is a strict prefix of is painted as ghost text after the cursor while the cursor sits at
|
|
162
|
+
* its end and no autocomplete is open. A shown prediction replaces the {@link placeholder}; Tab or
|
|
163
|
+
* Right inserts the rest without submitting. A buffer the user typed keeps the ghost even when it
|
|
164
|
+
* equals a shorter prediction; once Tab, Right, or the list has inserted one of two or more
|
|
165
|
+
* predictions, no ghost extends it to a longer one, and Tab instead opens a list of all of them
|
|
166
|
+
* that swaps the whole line, also without submitting. Each must be a single line. Re-evaluated on
|
|
167
|
+
* every render, so hosts can derive them from live state. */
|
|
168
|
+
predictions?: () => readonly string[] | undefined;
|
|
169
|
+
/** Called with the prediction's index in {@link predictions} after Tab or Right inserts the rest of
|
|
170
|
+
* a shown prediction, or the alternatives list swaps a different one into the buffer. */
|
|
171
|
+
onPredictionAccepted?: (index: number) => void;
|
|
172
|
+
/** Called for each frame that paints a prediction as ghost text: a terminal frame that draws at
|
|
173
|
+
* least one cell of it, or a native frame that carries it as the editor's ghost. */
|
|
174
|
+
onPredictionShown?: () => void;
|
|
166
175
|
constructor(theme: EditorTheme);
|
|
167
176
|
/** Return bounded editor content, cursor, and transient child state for debug inspection. */
|
|
168
177
|
debugState(): Record<string, unknown>;
|
package/src/components/editor.ts
CHANGED
|
@@ -71,6 +71,7 @@ import {
|
|
|
71
71
|
export type { EditorBorderStyle, EditorTopBorder };
|
|
72
72
|
|
|
73
73
|
import { type SelectItem, SelectList, type SelectListLayoutOptions, type SelectListTheme } from "./select-list";
|
|
74
|
+
import { editorKey } from "../chrome/keybinding-hints";
|
|
74
75
|
|
|
75
76
|
/** The TSP root an {@link Editor.describeLayout} hook builds around the `editor` node. */
|
|
76
77
|
export interface NativeEditorLayout {
|
|
@@ -866,9 +867,19 @@ export class Editor implements Component, Focusable {
|
|
|
866
867
|
#autocompleteList?: SelectList;
|
|
867
868
|
#autocompleteState: "regular" | "force" | "assist" | null = null;
|
|
868
869
|
#textAssistReplacement:
|
|
869
|
-
| {
|
|
870
|
+
| {
|
|
871
|
+
line: number;
|
|
872
|
+
startCol: number;
|
|
873
|
+
endCol: number;
|
|
874
|
+
original: string;
|
|
875
|
+
cursorOffset: number;
|
|
876
|
+
/** The list offers {@link predictions} for the whole line rather than spelling replacements. */
|
|
877
|
+
prediction?: boolean;
|
|
878
|
+
}
|
|
870
879
|
| undefined;
|
|
871
880
|
#autocompletePrefix: string = "";
|
|
881
|
+
/** The line a prediction insert (Tab, Right, or the alternatives list) left in the buffer; any later edit clears it. */
|
|
882
|
+
#insertedPrediction: string | undefined;
|
|
872
883
|
/** False while the popup's untouched top row is a description-only slash hit ({@link AutocompleteItem.descriptionMatch}): Enter then submits the typed text. */
|
|
873
884
|
#enterAcceptsSelection = true;
|
|
874
885
|
#autocompleteRequestId: number = 0;
|
|
@@ -945,12 +956,21 @@ export class Editor implements Component, Focusable {
|
|
|
945
956
|
* cursor. The host styles it (ANSI allowed). Re-evaluated on every render, so hosts can derive
|
|
946
957
|
* it from live state. */
|
|
947
958
|
placeholder?: () => string | undefined;
|
|
948
|
-
/** Whole-message
|
|
949
|
-
*
|
|
950
|
-
* autocomplete is open. A shown prediction replaces the {@link placeholder}; Tab or
|
|
951
|
-
* the rest without submitting.
|
|
952
|
-
*
|
|
953
|
-
|
|
959
|
+
/** Whole-message predictions for the next prompt, most likely first. The first one the single-line
|
|
960
|
+
* buffer is a strict prefix of is painted as ghost text after the cursor while the cursor sits at
|
|
961
|
+
* its end and no autocomplete is open. A shown prediction replaces the {@link placeholder}; Tab or
|
|
962
|
+
* Right inserts the rest without submitting. A buffer the user typed keeps the ghost even when it
|
|
963
|
+
* equals a shorter prediction; once Tab, Right, or the list has inserted one of two or more
|
|
964
|
+
* predictions, no ghost extends it to a longer one, and Tab instead opens a list of all of them
|
|
965
|
+
* that swaps the whole line, also without submitting. Each must be a single line. Re-evaluated on
|
|
966
|
+
* every render, so hosts can derive them from live state. */
|
|
967
|
+
predictions?: () => readonly string[] | undefined;
|
|
968
|
+
/** Called with the prediction's index in {@link predictions} after Tab or Right inserts the rest of
|
|
969
|
+
* a shown prediction, or the alternatives list swaps a different one into the buffer. */
|
|
970
|
+
onPredictionAccepted?: (index: number) => void;
|
|
971
|
+
/** Called for each frame that paints a prediction as ghost text: a terminal frame that draws at
|
|
972
|
+
* least one cell of it, or a native frame that carries it as the editor's ghost. */
|
|
973
|
+
onPredictionShown?: () => void;
|
|
954
974
|
|
|
955
975
|
// Custom top border (for status line integration). Either an eager `content`
|
|
956
976
|
// (set once, reused every frame) or a `provider` that recomputes lazily just
|
|
@@ -1599,6 +1619,10 @@ export class Editor implements Component, Focusable {
|
|
|
1599
1619
|
// against the cursor, or the placeholder flush right.
|
|
1600
1620
|
const placeholder = this.#getPlaceholder();
|
|
1601
1621
|
const inlineHint = placeholder ? null : this.#getInlineHint();
|
|
1622
|
+
// Whether the hint is the prediction, and how many of its cells this frame draws: a full row,
|
|
1623
|
+
// an unfocused hardware-cursor row, or the IME-safe layout can leave it unpainted.
|
|
1624
|
+
const hintIsPrediction = inlineHint !== null && inlineHint === this.#getPredictionSuffix();
|
|
1625
|
+
let hintCellsPainted = 0;
|
|
1602
1626
|
const hintStyle = this.#theme.hintStyle ?? ((t: string) => `\x1b[2m${t}\x1b[0m`);
|
|
1603
1627
|
const hintTail = (avail: number): { text: string; width: number } | undefined => {
|
|
1604
1628
|
if (placeholder) {
|
|
@@ -1713,6 +1737,7 @@ export class Editor implements Component, Focusable {
|
|
|
1713
1737
|
} else if (tail) {
|
|
1714
1738
|
displayText = before + marker + tail.text;
|
|
1715
1739
|
displayWidth += tail.width;
|
|
1740
|
+
hintCellsPainted += tail.width;
|
|
1716
1741
|
} else if (after.length === 0 && !isSideBordered && displayWidth >= lineContentWidth) {
|
|
1717
1742
|
displayText = this.#renderTerminalCursorMarker(before, marker, lineContentWidth);
|
|
1718
1743
|
} else {
|
|
@@ -1759,6 +1784,7 @@ export class Editor implements Component, Focusable {
|
|
|
1759
1784
|
const tail = hintTail(Math.max(0, lineContentWidth - displayWidth - overrideWidth));
|
|
1760
1785
|
displayText = before + marker + this.cursorOverride + (tail?.text ?? "");
|
|
1761
1786
|
displayWidth += overrideWidth + (tail?.width ?? 0);
|
|
1787
|
+
hintCellsPainted += tail?.width ?? 0;
|
|
1762
1788
|
}
|
|
1763
1789
|
} else {
|
|
1764
1790
|
// Cursor is at the end - add thin cursor glyph
|
|
@@ -1773,6 +1799,7 @@ export class Editor implements Component, Focusable {
|
|
|
1773
1799
|
const tail = hintTail(Math.max(0, lineContentWidth - displayWidth - cursorWidth));
|
|
1774
1800
|
displayText = before + marker + cursor + (tail?.text ?? "");
|
|
1775
1801
|
displayWidth += cursorWidth + (tail?.width ?? 0);
|
|
1802
|
+
hintCellsPainted += tail?.width ?? 0;
|
|
1776
1803
|
}
|
|
1777
1804
|
if (displayWidth > lineContentWidth && paddingX > 0) {
|
|
1778
1805
|
cursorPaddingOverflow = displayWidth - lineContentWidth;
|
|
@@ -1815,6 +1842,7 @@ export class Editor implements Component, Focusable {
|
|
|
1815
1842
|
}),
|
|
1816
1843
|
);
|
|
1817
1844
|
}
|
|
1845
|
+
if (hintIsPrediction && hintCellsPainted > 0) this.onPredictionShown?.();
|
|
1818
1846
|
|
|
1819
1847
|
const bottomRow = style.renderBottom(chromeCtx);
|
|
1820
1848
|
if (bottomRow !== undefined) result.push(bottomRow);
|
|
@@ -1879,6 +1907,7 @@ export class Editor implements Component, Focusable {
|
|
|
1879
1907
|
: placeholder && plainText(placeholder).trim();
|
|
1880
1908
|
const atLineEnd = cursorCol >= (lines[cursorLine]?.length ?? 0);
|
|
1881
1909
|
const ghost = nativePlaceholder || !atLineEnd ? null : this.#getInlineHint();
|
|
1910
|
+
if (ghost && ghost === this.#getPredictionSuffix()) this.onPredictionShown?.();
|
|
1882
1911
|
const vim = this.#vim;
|
|
1883
1912
|
let anchor: number | null = null;
|
|
1884
1913
|
if (vim?.visual && vim.anchor !== null) {
|
|
@@ -2135,7 +2164,7 @@ export class Editor implements Component, Focusable {
|
|
|
2135
2164
|
kb.matchesCanonical(canonical, "tui.input.tab") ||
|
|
2136
2165
|
rightArrowAccepts)
|
|
2137
2166
|
) {
|
|
2138
|
-
this.#
|
|
2167
|
+
this.#applyAssistReplacement();
|
|
2139
2168
|
return;
|
|
2140
2169
|
}
|
|
2141
2170
|
// Let the autocomplete list handle navigation and selection
|
|
@@ -3265,6 +3294,7 @@ export class Editor implements Component, Focusable {
|
|
|
3265
3294
|
|
|
3266
3295
|
#notifyChange(text?: string): void {
|
|
3267
3296
|
this.#textRevision++;
|
|
3297
|
+
this.#insertedPrediction = undefined;
|
|
3268
3298
|
this.onChange?.(text ?? this.getText());
|
|
3269
3299
|
}
|
|
3270
3300
|
|
|
@@ -5082,7 +5112,7 @@ export class Editor implements Component, Focusable {
|
|
|
5082
5112
|
// A pointer pick on the popup (TSP `select`/`activate`) accepts it like Tab.
|
|
5083
5113
|
list.onSelect = item => {
|
|
5084
5114
|
if (this.#autocompleteList !== list) return;
|
|
5085
|
-
if (this.#autocompleteState === "assist") this.#
|
|
5115
|
+
if (this.#autocompleteState === "assist") this.#applyAssistReplacement();
|
|
5086
5116
|
else this.#acceptAutocompleteSelection(item);
|
|
5087
5117
|
};
|
|
5088
5118
|
return list;
|
|
@@ -5090,6 +5120,7 @@ export class Editor implements Component, Focusable {
|
|
|
5090
5120
|
|
|
5091
5121
|
async #handleTabCompletion(): Promise<void> {
|
|
5092
5122
|
if (this.#acceptPrediction()) return;
|
|
5123
|
+
if (this.#showPredictionAlternatives()) return;
|
|
5093
5124
|
if (this.#acceptWordCompletion({ space: true })) return;
|
|
5094
5125
|
if (!this.#autocompleteProvider) return;
|
|
5095
5126
|
|
|
@@ -5127,11 +5158,37 @@ export class Editor implements Component, Focusable {
|
|
|
5127
5158
|
if (space) this.#lastAction = "accept-word";
|
|
5128
5159
|
return true;
|
|
5129
5160
|
}
|
|
5130
|
-
/** Insert the rest of the shown
|
|
5161
|
+
/** Insert the rest of the shown prediction, if any. Never submits. */
|
|
5131
5162
|
#acceptPrediction(): boolean {
|
|
5132
|
-
const
|
|
5133
|
-
if (!
|
|
5134
|
-
this.#insertTextAtCursor(suffix);
|
|
5163
|
+
const shown = this.#getShownPrediction();
|
|
5164
|
+
if (!shown) return false;
|
|
5165
|
+
this.#insertTextAtCursor(shown.suffix);
|
|
5166
|
+
this.#insertedPrediction = this.#state.lines[0];
|
|
5167
|
+
this.onPredictionAccepted?.(shown.index);
|
|
5168
|
+
return true;
|
|
5169
|
+
}
|
|
5170
|
+
|
|
5171
|
+
/** Open the list of every prediction over a buffer that equals one of them, that one selected. */
|
|
5172
|
+
#showPredictionAlternatives(): boolean {
|
|
5173
|
+
const alternatives = this.#getPredictionAlternatives();
|
|
5174
|
+
if (!alternatives) return false;
|
|
5175
|
+
const original = this.#state.lines[0] ?? "";
|
|
5176
|
+
this.#autocompletePrefix = original;
|
|
5177
|
+
this.#autocompleteList = this.#createAutocompleteList(
|
|
5178
|
+
"",
|
|
5179
|
+
alternatives.choices.map(value => ({ value, label: value })),
|
|
5180
|
+
);
|
|
5181
|
+
this.#autocompleteList.setSelectedIndex(alternatives.index);
|
|
5182
|
+
this.#autocompleteState = "assist";
|
|
5183
|
+
this.#textAssistReplacement = {
|
|
5184
|
+
line: 0,
|
|
5185
|
+
startCol: 0,
|
|
5186
|
+
endCol: original.length,
|
|
5187
|
+
original,
|
|
5188
|
+
cursorOffset: 0,
|
|
5189
|
+
prediction: true,
|
|
5190
|
+
};
|
|
5191
|
+
this.onAutocompleteUpdate?.();
|
|
5135
5192
|
return true;
|
|
5136
5193
|
}
|
|
5137
5194
|
|
|
@@ -5174,7 +5231,7 @@ export class Editor implements Component, Focusable {
|
|
|
5174
5231
|
this.onAutocompleteUpdate?.();
|
|
5175
5232
|
}
|
|
5176
5233
|
|
|
5177
|
-
#
|
|
5234
|
+
#applyAssistReplacement(): void {
|
|
5178
5235
|
const replacement = this.#textAssistReplacement;
|
|
5179
5236
|
const selected = this.#autocompleteList?.getSelectedItem();
|
|
5180
5237
|
if (!replacement || !selected) {
|
|
@@ -5182,8 +5239,13 @@ export class Editor implements Component, Focusable {
|
|
|
5182
5239
|
return;
|
|
5183
5240
|
}
|
|
5184
5241
|
const line = this.#state.lines[replacement.line] ?? "";
|
|
5185
|
-
|
|
5242
|
+
// A mismatch means the list went stale; picking the prediction already in the buffer changes nothing.
|
|
5243
|
+
if (
|
|
5244
|
+
line.slice(replacement.startCol, replacement.endCol) !== replacement.original ||
|
|
5245
|
+
(replacement.prediction && selected.value === replacement.original)
|
|
5246
|
+
) {
|
|
5186
5247
|
this.#cancelAutocomplete();
|
|
5248
|
+
this.onAutocompleteUpdate?.();
|
|
5187
5249
|
return;
|
|
5188
5250
|
}
|
|
5189
5251
|
this.#recordUndoState();
|
|
@@ -5195,6 +5257,11 @@ export class Editor implements Component, Focusable {
|
|
|
5195
5257
|
this.#cancelAutocomplete();
|
|
5196
5258
|
this.onAutocompleteUpdate?.();
|
|
5197
5259
|
this.#notifyChange();
|
|
5260
|
+
if (replacement.prediction) {
|
|
5261
|
+
this.#insertedPrediction = selected.value;
|
|
5262
|
+
const index = this.predictions?.()?.indexOf(selected.value) ?? -1;
|
|
5263
|
+
if (index >= 0) this.onPredictionAccepted?.(index);
|
|
5264
|
+
}
|
|
5198
5265
|
}
|
|
5199
5266
|
async #handleSlashCommandCompletion(): Promise<void> {
|
|
5200
5267
|
await this.#tryTriggerAutocomplete();
|
|
@@ -5400,7 +5467,8 @@ export class Editor implements Component, Focusable {
|
|
|
5400
5467
|
|
|
5401
5468
|
/**
|
|
5402
5469
|
* Get inline hint text to show as dim ghost text after the cursor.
|
|
5403
|
-
* Checks the selected autocomplete item's hint first, then the prediction
|
|
5470
|
+
* Checks the selected autocomplete item's hint first, then the prediction and its alternatives,
|
|
5471
|
+
* then the provider.
|
|
5404
5472
|
*/
|
|
5405
5473
|
#getInlineHint(): string | null {
|
|
5406
5474
|
// Check selected autocomplete item for a hint
|
|
@@ -5411,7 +5479,12 @@ export class Editor implements Component, Focusable {
|
|
|
5411
5479
|
|
|
5412
5480
|
const prediction = this.#getPredictionSuffix();
|
|
5413
5481
|
if (prediction) return prediction;
|
|
5414
|
-
|
|
5482
|
+
const alternatives = this.#getPredictionAlternatives();
|
|
5483
|
+
if (alternatives) {
|
|
5484
|
+
// Tab opens the alternatives list from here; without a bound key there is nothing to hint.
|
|
5485
|
+
const tab = editorKey("tui.input.tab");
|
|
5486
|
+
if (tab) return ` ${tab} ${alternatives.choices.length - 1} more`;
|
|
5487
|
+
}
|
|
5415
5488
|
// Fall back to provider's getInlineHint
|
|
5416
5489
|
if (this.#autocompleteProvider?.getInlineHint) {
|
|
5417
5490
|
const hint = this.#autocompleteProvider.getInlineHint(
|
|
@@ -5428,18 +5501,44 @@ export class Editor implements Component, Focusable {
|
|
|
5428
5501
|
if (this.#autocompleteState || !this.#isEditorEmpty() || this.#getPredictionSuffix()) return undefined;
|
|
5429
5502
|
return this.placeholder?.() || undefined;
|
|
5430
5503
|
}
|
|
5431
|
-
/** The part of
|
|
5504
|
+
/** The part of the shown prediction not yet typed, or `null` when no prediction is shown. */
|
|
5432
5505
|
#getPredictionSuffix(): string | null {
|
|
5506
|
+
return this.#getShownPrediction()?.suffix ?? null;
|
|
5507
|
+
}
|
|
5508
|
+
/**
|
|
5509
|
+
* The prediction painted as ghost text: the first one the single-line buffer is a strict prefix of,
|
|
5510
|
+
* with the cursor at its end and no autocomplete open. None while the buffer is a prediction insert
|
|
5511
|
+
* that equals one of two or more predictions, so Tab opens their list rather than extending to a
|
|
5512
|
+
* longer one; a buffer the user typed keeps its ghost.
|
|
5513
|
+
*/
|
|
5514
|
+
#getShownPrediction(): { index: number; suffix: string } | null {
|
|
5433
5515
|
if (this.#autocompleteState) return null;
|
|
5434
|
-
const
|
|
5435
|
-
if (!
|
|
5516
|
+
const predictions = this.predictions?.();
|
|
5517
|
+
if (!predictions?.length) return null;
|
|
5436
5518
|
const { lines, cursorCol } = this.#state;
|
|
5437
5519
|
if (lines.length !== 1) return null;
|
|
5438
5520
|
const typed = lines[0] ?? "";
|
|
5439
|
-
if (cursorCol !== typed.length
|
|
5440
|
-
|
|
5441
|
-
|
|
5442
|
-
|
|
5521
|
+
if (cursorCol !== typed.length) return null;
|
|
5522
|
+
if (predictions.length > 1 && typed === this.#insertedPrediction && predictions.includes(typed)) return null;
|
|
5523
|
+
const index = predictions.findIndex(
|
|
5524
|
+
prediction => typed.length < prediction.length && prediction.startsWith(typed),
|
|
5525
|
+
);
|
|
5526
|
+
return index < 0 ? null : { index, suffix: predictions[index]!.slice(typed.length) };
|
|
5527
|
+
}
|
|
5528
|
+
/**
|
|
5529
|
+
* Two or more predictions, and which one the single-line buffer equals with the cursor at its end:
|
|
5530
|
+
* Tab then opens the list of all of them.
|
|
5531
|
+
*/
|
|
5532
|
+
#getPredictionAlternatives(): { choices: readonly string[]; index: number } | null {
|
|
5533
|
+
if (this.#autocompleteState) return null;
|
|
5534
|
+
const choices = this.predictions?.();
|
|
5535
|
+
if (!choices || choices.length < 2) return null;
|
|
5536
|
+
const { lines, cursorCol } = this.#state;
|
|
5537
|
+
if (lines.length !== 1) return null;
|
|
5538
|
+
const typed = lines[0] ?? "";
|
|
5539
|
+
if (cursorCol !== typed.length) return null;
|
|
5540
|
+
const index = choices.indexOf(typed);
|
|
5541
|
+
return index < 0 ? null : { choices, index };
|
|
5443
5542
|
}
|
|
5444
5543
|
/** Typing `typed` where it diverges from the shown ghost completion rejects that ghost. */
|
|
5445
5544
|
#reportTypedPastWordCompletion(typed: string): void {
|
|
@@ -207,6 +207,12 @@ export declare class Image implements Component {
|
|
|
207
207
|
/** Return source metadata without exposing the encoded image buffer. */
|
|
208
208
|
debugState(): Record<string, unknown>;
|
|
209
209
|
invalidate(): void;
|
|
210
|
+
/**
|
|
211
|
+
* Refit to a new row ceiling; a SIXEL reserves its rows until the off-thread
|
|
212
|
+
* encode lands. A demoted fallback keeps the height already drawn only
|
|
213
|
+
* within the new ceiling: the owner chose to shrink the block.
|
|
214
|
+
*/
|
|
215
|
+
setMaxHeightCells(maxHeightCells: number): void;
|
|
210
216
|
releaseRenderCaches(): void;
|
|
211
217
|
/**
|
|
212
218
|
* A native `image` backed by a content-addressed blob; the terminal fits
|
package/src/components/image.ts
CHANGED
|
@@ -773,6 +773,19 @@ export class Image implements Component {
|
|
|
773
773
|
this.#cachedWidth = undefined;
|
|
774
774
|
}
|
|
775
775
|
|
|
776
|
+
/**
|
|
777
|
+
* Refit to a new row ceiling; a SIXEL reserves its rows until the off-thread
|
|
778
|
+
* encode lands. A demoted fallback keeps the height already drawn only
|
|
779
|
+
* within the new ceiling: the owner chose to shrink the block.
|
|
780
|
+
*/
|
|
781
|
+
setMaxHeightCells(maxHeightCells: number): void {
|
|
782
|
+
if (this.#options.maxHeightCells === maxHeightCells) return;
|
|
783
|
+
this.#options.maxHeightCells = maxHeightCells;
|
|
784
|
+
this.#renderedGraphicRows = Math.min(this.#renderedGraphicRows, maxHeightCells);
|
|
785
|
+
this.#native = undefined;
|
|
786
|
+
this.invalidate();
|
|
787
|
+
}
|
|
788
|
+
|
|
776
789
|
releaseRenderCaches(): void {
|
|
777
790
|
this.#cachedLines = undefined;
|
|
778
791
|
this.#cachedWidth = undefined;
|
|
@@ -2,7 +2,15 @@ import { compactText, styleSpans } from "../native/spans";
|
|
|
2
2
|
import { node } from "../native/describe";
|
|
3
3
|
import type { DescribeContext, NativeNode } from "../native/node";
|
|
4
4
|
import type { Component } from "../tui";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
Ellipsis,
|
|
7
|
+
finiteWidth,
|
|
8
|
+
getWidthConfigEpoch,
|
|
9
|
+
singleLine,
|
|
10
|
+
truncateToWidth,
|
|
11
|
+
visibleWidth,
|
|
12
|
+
wrapTextWithAnsi,
|
|
13
|
+
} from "../utils";
|
|
6
14
|
|
|
7
15
|
/** One label/value entry in a {@link KeyValueList}. */
|
|
8
16
|
export interface KeyValueRow {
|
|
@@ -21,14 +29,6 @@ export interface KeyValueListOptions {
|
|
|
21
29
|
readonly labelOverflow?: "allow" | "truncate";
|
|
22
30
|
}
|
|
23
31
|
|
|
24
|
-
function finiteWidth(width: number): number {
|
|
25
|
-
return Number.isFinite(width) ? Math.max(0, Math.trunc(width)) : 0;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function singleLine(text: string): string {
|
|
29
|
-
return replaceTabs(text).replace(/[\r\n]+/g, " ");
|
|
30
|
-
}
|
|
31
|
-
|
|
32
32
|
/** A bounded ANSI-aware label/value list with replaceable rows and aligned wrapped continuations. */
|
|
33
33
|
export class KeyValueList implements Component {
|
|
34
34
|
#rows: readonly KeyValueRow[];
|
|
@@ -71,6 +71,8 @@ export declare class Loader extends Text {
|
|
|
71
71
|
stop(): void;
|
|
72
72
|
/** Lifecycle teardown: stop the animation timer. Idempotent. */
|
|
73
73
|
dispose(): void;
|
|
74
|
+
/** The current spinner frame and message as one styled line, for hosts that set it into their own chrome. */
|
|
75
|
+
inlineText(): string;
|
|
74
76
|
/** Install a lazy right-docked suffix for the spinner row (e.g. a styled
|
|
75
77
|
* session title). Re-evaluated every paint; dropped when the row leaves
|
|
76
78
|
* less than a two-cell gap. */
|
package/src/components/loader.ts
CHANGED
|
@@ -325,6 +325,13 @@ export class Loader extends Text {
|
|
|
325
325
|
dispose() {
|
|
326
326
|
this.stop();
|
|
327
327
|
}
|
|
328
|
+
|
|
329
|
+
/** The current spinner frame and message as one styled line, for hosts that set it into their own chrome. */
|
|
330
|
+
inlineText(): string {
|
|
331
|
+
const spinner = this.spinnerColorFn(this.#frames[this.#currentFrame]);
|
|
332
|
+
return `${spinner} ${this.messageColorFn(this.#resolveMessage())}`;
|
|
333
|
+
}
|
|
334
|
+
|
|
328
335
|
/** Install a lazy right-docked suffix for the spinner row (e.g. a styled
|
|
329
336
|
* session title). Re-evaluated every paint; dropped when the row leaves
|
|
330
337
|
* less than a two-cell gap. */
|
|
@@ -2,20 +2,12 @@ import { compactText, rowsText, styledSpans } from "../native/spans";
|
|
|
2
2
|
import { node } from "../native/describe";
|
|
3
3
|
import type { DescribeContext, NativeNode } from "../native/node";
|
|
4
4
|
import type { Component } from "../tui";
|
|
5
|
-
import { Ellipsis, getWidthConfigEpoch,
|
|
5
|
+
import { Ellipsis, finiteWidth, getWidthConfigEpoch, singleLine, truncateToWidth, visibleWidth } from "../utils";
|
|
6
6
|
|
|
7
7
|
function isComponent(body: Component | readonly string[]): body is Component {
|
|
8
8
|
return !Array.isArray(body);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
function finiteWidth(width: number): number {
|
|
12
|
-
return Number.isFinite(width) ? Math.max(0, Math.trunc(width)) : 0;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function singleLine(text: string): string {
|
|
16
|
-
return replaceTabs(text).replace(/[\r\n]+/g, " ");
|
|
17
|
-
}
|
|
18
|
-
|
|
19
11
|
function fillCells(glyph: string, width: number): string {
|
|
20
12
|
const cleanGlyph = singleLine(glyph);
|
|
21
13
|
const glyphWidth = visibleWidth(cleanGlyph);
|
package/src/components/table.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { compactText, styleSpans } from "../native/spans";
|
|
|
3
3
|
import { node } from "../native/describe";
|
|
4
4
|
import type { DescribeContext, NativeNode } from "../native/node";
|
|
5
5
|
import type { Component } from "../tui";
|
|
6
|
-
import { Ellipsis, getWidthConfigEpoch,
|
|
6
|
+
import { Ellipsis, finiteWidth, getWidthConfigEpoch, singleLine, truncateToWidth, visibleWidth } from "../utils";
|
|
7
7
|
|
|
8
8
|
/** One table cell. Styling is applied after alignment so padding shares the cell style. */
|
|
9
9
|
export interface TableCell {
|
|
@@ -29,14 +29,6 @@ export interface TableOptions {
|
|
|
29
29
|
readonly fit?: boolean;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
function finiteWidth(width: number, fallback = 0): number {
|
|
33
|
-
return Number.isFinite(width) ? Math.max(0, Math.trunc(width)) : fallback;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function singleLine(text: string): string {
|
|
37
|
-
return replaceTabs(text).replace(/[\r\n]+/g, " ");
|
|
38
|
-
}
|
|
39
|
-
|
|
40
32
|
function fitWidths(columns: readonly TableColumn[], maxWidth: number, gapWidth: number): number[] {
|
|
41
33
|
const widths = columns.map(column => finiteWidth(column.width));
|
|
42
34
|
let overflow = widths.reduce((sum, width) => sum + width, 0) + Math.max(0, columns.length - 1) * gapWidth - maxWidth;
|
|
@@ -42,3 +42,10 @@ export declare function matchesAppFollowUp(data: string): boolean;
|
|
|
42
42
|
export declare function appApproveKeys(): readonly KeyId[];
|
|
43
43
|
/** Match the tool-approval key, recognizing modifier-tagged LF as Ctrl+Enter like {@link matchesAppFollowUp}. */
|
|
44
44
|
export declare function matchesAppApprove(data: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Effective /btw inject key (Alt+I by default). No fallback: it sends text into the main
|
|
47
|
+
* session, so a user who unbinds it gets no key at all.
|
|
48
|
+
*/
|
|
49
|
+
export declare function appBtwInjectKey(): KeyId | undefined;
|
|
50
|
+
/** Match the key that sends a /btw answer's steering prompt to the main session. */
|
|
51
|
+
export declare function matchesAppBtwInject(data: string): boolean;
|
|
@@ -120,3 +120,16 @@ export function appApproveKeys(): readonly KeyId[] {
|
|
|
120
120
|
export function matchesAppApprove(data: string): boolean {
|
|
121
121
|
return matchesEffectiveKeys(data, appApproveKeys());
|
|
122
122
|
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Effective /btw inject key (Alt+I by default). No fallback: it sends text into the main
|
|
126
|
+
* session, so a user who unbinds it gets no key at all.
|
|
127
|
+
*/
|
|
128
|
+
export function appBtwInjectKey(): KeyId | undefined {
|
|
129
|
+
return getKeybindings().getKeys("app.btw.inject")[0];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Match the key that sends a /btw answer's steering prompt to the main session. */
|
|
133
|
+
export function matchesAppBtwInject(data: string): boolean {
|
|
134
|
+
return getKeybindings().matches(data, "app.btw.inject");
|
|
135
|
+
}
|
package/src/native/backend.ts
CHANGED
|
@@ -48,7 +48,7 @@ import { encodeTspJson, encodeTspMessage, type TspHello, TspReader, splitTspMess
|
|
|
48
48
|
import type { DescribeContext, NativeChild, NativeNode, NativeSurface, NativeUiEvent } from "./node";
|
|
49
49
|
import { NARROW_SHEET_COLS } from "./overlay";
|
|
50
50
|
import { nativeComponentId, Reconciler } from "./reconcile";
|
|
51
|
-
import { setNativeRendering } from "./state";
|
|
51
|
+
import { setNativeButtons, setNativeRendering } from "./state";
|
|
52
52
|
|
|
53
53
|
/** A visible TUI overlay, bottom to top. */
|
|
54
54
|
export interface NativeOverlay {
|
|
@@ -199,9 +199,10 @@ function sameSet(a: ReadonlySet<string>, b: ReadonlySet<string>): boolean {
|
|
|
199
199
|
* Kinds newer than some Tern builds that answer `TERM_PROGRAM=tern`: used only
|
|
200
200
|
* once the real `hello` lists them, so the optimistic start never emits a node
|
|
201
201
|
* an older terminal cannot draw (`media`: files Tern loads by path; `json`:
|
|
202
|
-
* raw JSON values Tern draws as its own tree
|
|
202
|
+
* raw JSON values Tern draws as its own tree; `button`: omp's buttons, which
|
|
203
|
+
* older builds get as role-styled rows).
|
|
203
204
|
*/
|
|
204
|
-
const UNASSUMED_KINDS: Partial<Record<TspKind, true>> = { media: true, json: true };
|
|
205
|
+
const UNASSUMED_KINDS: Partial<Record<TspKind, true>> = { media: true, json: true, button: true };
|
|
205
206
|
|
|
206
207
|
/**
|
|
207
208
|
* The reply a v1 terminal is assumed to give before its real `hello` arrives
|
|
@@ -380,6 +381,7 @@ export class NativeBackend {
|
|
|
380
381
|
this.#close(this.#inline, keep);
|
|
381
382
|
this.#inline.doc?.close();
|
|
382
383
|
setNativeRendering(false);
|
|
384
|
+
setNativeButtons(false);
|
|
383
385
|
this.#useNerdSymbols(false);
|
|
384
386
|
this.#clearStallTimer();
|
|
385
387
|
// Replies no longer reach the backend: forget the queries outright.
|
|
@@ -539,6 +541,8 @@ export class NativeBackend {
|
|
|
539
541
|
this.#limit = hello.apc !== undefined && hello.apc > 0 ? hello.apc : TSP_DEFAULT_APC_LIMIT;
|
|
540
542
|
this.#credits = hello.credits !== undefined && hello.credits > 0 ? hello.credits : TSP_DEFAULT_CREDITS;
|
|
541
543
|
this.#cx = new NativeContext(hello, hello.cols ?? this.#cx.cols);
|
|
544
|
+
// A changed vocabulary re-describes every component (`confirm`).
|
|
545
|
+
setNativeButtons(this.#cx.supports("button"));
|
|
542
546
|
this.#sawResize = false;
|
|
543
547
|
}
|
|
544
548
|
|
package/src/native/describe.d.ts
CHANGED
|
@@ -56,7 +56,9 @@ export declare function list(items: readonly NativeChild[], p?: TspProps<"list">
|
|
|
56
56
|
/** Terminal-clocked elapsed counter: `age` ms already elapsed; `stopped` freezes it there. */
|
|
57
57
|
export declare function elapsed(age: number, stopped?: boolean): NativeNode;
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
59
|
+
* The key names of one key id (`"ctrl+o"` → `["ctrl", "o"]`), as `kbd` and
|
|
60
|
+
* `button` `keys` take them. A literal `+` key survives (`"+"`, `"ctrl++"`).
|
|
61
61
|
*/
|
|
62
|
+
export declare function keyNames(key: string): string[];
|
|
63
|
+
/** Keycap for one key id ({@link keyNames}); the terminal draws platform glyphs. */
|
|
62
64
|
export declare function kbd(key: string, nodeKey?: string): NativeNode;
|