@bastani/atomic-tui 0.9.89-alpha.2 → 0.9.90-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/builtin-command-names.d.ts +4 -0
- package/dist/builtin-command-names.d.ts.map +1 -0
- package/dist/builtin-command-names.js +42 -0
- package/dist/builtin-command-names.js.map +1 -0
- package/dist/clickable-hints.d.ts +84 -0
- package/dist/clickable-hints.d.ts.map +1 -0
- package/dist/clickable-hints.js +267 -0
- package/dist/clickable-hints.js.map +1 -0
- package/dist/components/editor.d.ts +7 -1
- package/dist/components/editor.d.ts.map +1 -1
- package/dist/components/editor.js +63 -25
- package/dist/components/editor.js.map +1 -1
- package/dist/components/settings-list.d.ts.map +1 -1
- package/dist/components/settings-list.js +3 -2
- package/dist/components/settings-list.js.map +1 -1
- package/dist/components/windowed-container.d.ts +2 -0
- package/dist/components/windowed-container.d.ts.map +1 -1
- package/dist/components/windowed-container.js +4 -0
- package/dist/components/windowed-container.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/keys.d.ts +5 -0
- package/dist/keys.d.ts.map +1 -1
- package/dist/keys.js +115 -0
- package/dist/keys.js.map +1 -1
- package/dist/terminal.d.ts +3 -0
- package/dist/terminal.d.ts.map +1 -1
- package/dist/terminal.js +16 -0
- package/dist/terminal.js.map +1 -1
- package/dist/tui-alt-screen.d.ts +24 -3
- package/dist/tui-alt-screen.d.ts.map +1 -1
- package/dist/tui-alt-screen.js +205 -58
- package/dist/tui-alt-screen.js.map +1 -1
- package/dist/tui.d.ts +23 -0
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +48 -5
- package/dist/tui.js.map +1 -1
- package/dist/utils.d.ts +4 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +79 -11
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Ordered command IDs shared by the application command registry and the terminal hint grammar. */
|
|
2
|
+
export declare const CORE_COMMAND_NAMES: readonly ["settings", "model", "tree", "thinking", "scoped-models", "export", "import", "share", "copy", "name", "session", "tools", "tasks", "changelog", "hotkeys", "fork", "clone", "trust", "login", "logout", "new", "compact", "resume", "reload", "exit", "quit"];
|
|
3
|
+
export declare const BUNDLED_COMMAND_NAMES: readonly ["agents", "workflows", "workflow-authoring", "mcp", "mcp-auth", "curator", "google-account", "search", "websearch", "intercom"];
|
|
4
|
+
//# sourceMappingURL=builtin-command-names.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtin-command-names.d.ts","sourceRoot":"","sources":["../src/builtin-command-names.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,eAAO,MAAM,kBAAkB,YAC9B,UAAU,EACV,OAAO,EACP,MAAM,EACN,UAAU,EACV,eAAe,EACf,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,MAAM,EACN,MAAM,EACN,SAAS,EACT,OAAO,EACP,OAAO,EACP,WAAW,EACX,SAAS,EACT,MAAM,EACN,OAAO,EACP,OAAO,EACP,OAAO,EACP,QAAQ,EACR,KAAK,EACL,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,MAAM,CACG,CAAC;AAEX,eAAO,MAAM,qBAAqB,YACjC,QAAQ,EACR,WAAW,EACX,oBAAoB,EACpB,KAAK,EACL,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,UAAU,CACD,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** Ordered command IDs shared by the application command registry and the terminal hint grammar. */
|
|
2
|
+
export const CORE_COMMAND_NAMES = [
|
|
3
|
+
"settings",
|
|
4
|
+
"model",
|
|
5
|
+
"tree",
|
|
6
|
+
"thinking",
|
|
7
|
+
"scoped-models",
|
|
8
|
+
"export",
|
|
9
|
+
"import",
|
|
10
|
+
"share",
|
|
11
|
+
"copy",
|
|
12
|
+
"name",
|
|
13
|
+
"session",
|
|
14
|
+
"tools",
|
|
15
|
+
"tasks",
|
|
16
|
+
"changelog",
|
|
17
|
+
"hotkeys",
|
|
18
|
+
"fork",
|
|
19
|
+
"clone",
|
|
20
|
+
"trust",
|
|
21
|
+
"login",
|
|
22
|
+
"logout",
|
|
23
|
+
"new",
|
|
24
|
+
"compact",
|
|
25
|
+
"resume",
|
|
26
|
+
"reload",
|
|
27
|
+
"exit",
|
|
28
|
+
"quit",
|
|
29
|
+
];
|
|
30
|
+
export const BUNDLED_COMMAND_NAMES = [
|
|
31
|
+
"agents",
|
|
32
|
+
"workflows",
|
|
33
|
+
"workflow-authoring",
|
|
34
|
+
"mcp",
|
|
35
|
+
"mcp-auth",
|
|
36
|
+
"curator",
|
|
37
|
+
"google-account",
|
|
38
|
+
"search",
|
|
39
|
+
"websearch",
|
|
40
|
+
"intercom",
|
|
41
|
+
];
|
|
42
|
+
//# sourceMappingURL=builtin-command-names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtin-command-names.js","sourceRoot":"","sources":["../src/builtin-command-names.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,MAAM,CAAC,MAAM,kBAAkB,GAAG;IACjC,UAAU;IACV,OAAO;IACP,MAAM;IACN,UAAU;IACV,eAAe;IACf,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,MAAM;IACN,MAAM;IACN,SAAS;IACT,OAAO;IACP,OAAO;IACP,WAAW;IACX,SAAS;IACT,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,QAAQ;IACR,KAAK;IACL,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,MAAM;CACG,CAAC;AAEX,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACpC,QAAQ;IACR,WAAW;IACX,oBAAoB;IACpB,KAAK;IACL,UAAU;IACV,SAAS;IACT,gBAAgB;IAChB,QAAQ;IACR,WAAW;IACX,UAAU;CACD,CAAC","sourcesContent":["/** Ordered command IDs shared by the application command registry and the terminal hint grammar. */\nexport const CORE_COMMAND_NAMES = [\n\t\"settings\",\n\t\"model\",\n\t\"tree\",\n\t\"thinking\",\n\t\"scoped-models\",\n\t\"export\",\n\t\"import\",\n\t\"share\",\n\t\"copy\",\n\t\"name\",\n\t\"session\",\n\t\"tools\",\n\t\"tasks\",\n\t\"changelog\",\n\t\"hotkeys\",\n\t\"fork\",\n\t\"clone\",\n\t\"trust\",\n\t\"login\",\n\t\"logout\",\n\t\"new\",\n\t\"compact\",\n\t\"resume\",\n\t\"reload\",\n\t\"exit\",\n\t\"quit\",\n] as const;\n\nexport const BUNDLED_COMMAND_NAMES = [\n\t\"agents\",\n\t\"workflows\",\n\t\"workflow-authoring\",\n\t\"mcp\",\n\t\"mcp-auth\",\n\t\"curator\",\n\t\"google-account\",\n\t\"search\",\n\t\"websearch\",\n\t\"intercom\",\n] as const;\n"]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clickable key hints. A hint such as `esc cancel` is drawn with zero-width markers around it that name what a click on
|
|
3
|
+
* it runs: a key, which the renderer feeds to the input path as if it were pressed, or a slash command. The fullscreen
|
|
4
|
+
* renderer strips the markers before writing a frame and remembers where each hint was painted.
|
|
5
|
+
*/
|
|
6
|
+
import { type KeybindingsManager } from "./keybindings.ts";
|
|
7
|
+
import { type KeyId } from "./keys.ts";
|
|
8
|
+
/** What a click on a hint runs: a key, exactly as if it were pressed, or a slash command such as `/tasks`. */
|
|
9
|
+
export type HintAction = {
|
|
10
|
+
readonly kind: "key";
|
|
11
|
+
readonly key: KeyId;
|
|
12
|
+
} | {
|
|
13
|
+
readonly kind: "command";
|
|
14
|
+
readonly command: string;
|
|
15
|
+
};
|
|
16
|
+
/** Where a hint was painted on a row, in columns `[start, end)`, and what a click on it runs. */
|
|
17
|
+
export interface HintSpan {
|
|
18
|
+
readonly start: number;
|
|
19
|
+
readonly end: number;
|
|
20
|
+
readonly action: HintAction;
|
|
21
|
+
}
|
|
22
|
+
/** One key a hint names, and the text that names it, such as `pgup/` for the first key of `pgup/pgdn`. */
|
|
23
|
+
export interface HintKeyPart {
|
|
24
|
+
readonly text: string;
|
|
25
|
+
readonly key?: KeyId;
|
|
26
|
+
}
|
|
27
|
+
export declare function keyHintAction(key: KeyId): HintAction;
|
|
28
|
+
export declare function commandHintAction(command: string): HintAction;
|
|
29
|
+
/**
|
|
30
|
+
* `text` marked as a hint that a click runs `action`. The markers take no columns, so widths, truncation and wrapping
|
|
31
|
+
* are unchanged; text with no action is returned as it is.
|
|
32
|
+
*/
|
|
33
|
+
export declare function clickableHint(text: string, action: HintAction | undefined): string;
|
|
34
|
+
/**
|
|
35
|
+
* A hint naming one or more keys, such as `pgup/pgdn scroll`: the text of each key runs that key, and `label` runs the
|
|
36
|
+
* last one, so a hint that names two keys acts by the half clicked. A part with no key is drawn without an action.
|
|
37
|
+
*/
|
|
38
|
+
export declare function clickableKeysHint(parts: readonly HintKeyPart[], label?: string): string;
|
|
39
|
+
/** Resolve bundled command hints against the live registrations of the session that owns these bindings. */
|
|
40
|
+
export declare function bindBundledHintCommands(bindings: KeybindingsManager, isRegistered: (name: string) => boolean): void;
|
|
41
|
+
/** The key id a hint's name for a key stands for, such as `pageUp` for `pgup`; undefined when no key is named. */
|
|
42
|
+
export declare function hintKeyId(name: string): KeyId | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* A hint's key text, such as `pgup/pgdn`, `↑↓` or `esc/←`, split by key: each part keeps its text and the separator
|
|
45
|
+
* after it, so the parts read as the text did, and names the key a click on it presses.
|
|
46
|
+
*/
|
|
47
|
+
export declare function hintKeyParts(text: string): HintKeyPart[];
|
|
48
|
+
/** A hint for `keyText`, such as `pgup/pgdn`, and `label`, each key running when its text is clicked. */
|
|
49
|
+
export declare function clickableKeyTextHint(keyText: string, label: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* A hint line written as text, such as `↑↓ select · ↵ open · esc close`: each ` · `-separated segment that starts with
|
|
52
|
+
* a complete named key (or a modified key) runs it. Bare letters, digits and punctuation must be listed in `bindings`,
|
|
53
|
+
* except a literal slash following a recognized key. Every member of a compact shortcut must be recognized. Numeric
|
|
54
|
+
* ratios stay plain even with digit bindings. Use {@link clickableKeyTextHint} when the key text is known separately.
|
|
55
|
+
* Built-in slash commands such as `/tasks to manage` run the command. Use {@link slashCommandHint} for custom commands.
|
|
56
|
+
*/
|
|
57
|
+
export declare function clickableHintText(text: string): string;
|
|
58
|
+
export declare function clickableHintText(text: string, bindings: readonly KeyId[]): string;
|
|
59
|
+
/** A hint naming a slash command, such as `/tasks to manage`, that runs the command when clicked. */
|
|
60
|
+
export declare function slashCommandHint(text: string): string;
|
|
61
|
+
/** Whether `line` has hint markers. */
|
|
62
|
+
export declare function hasHintMarkers(line: string): boolean;
|
|
63
|
+
/** `line` without its hint markers. */
|
|
64
|
+
export declare function stripHintMarkers(line: string): string;
|
|
65
|
+
/**
|
|
66
|
+
* `line` without its hint markers, and the columns each marked hint covers. A hint whose closing marker was cut off,
|
|
67
|
+
* by truncation for example, ends at the end of the line; a closing marker whose opening one was cut off is dropped.
|
|
68
|
+
*/
|
|
69
|
+
export declare function readHintSpans(line: string): {
|
|
70
|
+
readonly line: string;
|
|
71
|
+
readonly spans: readonly HintSpan[];
|
|
72
|
+
};
|
|
73
|
+
/** The action of the hint painted at `column`, among a row's `spans`. */
|
|
74
|
+
export declare function hintActionAt(spans: readonly HintSpan[] | undefined, column: number): HintAction | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Whether the input being handled was sent by a click on a key hint. A key that acts only on an empty prompt, such as
|
|
77
|
+
* `?` for the keys of a screen, acts for a click whatever the prompt holds: a click cannot be typing.
|
|
78
|
+
*/
|
|
79
|
+
export declare function isHintActivation(): boolean;
|
|
80
|
+
/** Run `handle` as the input of a click on a key hint; see {@link isHintActivation}. */
|
|
81
|
+
export declare function runAsHintActivation<T>(handle: () => T): T;
|
|
82
|
+
/** The terminal input a click on a key hint sends for `action`, or undefined for a command or an unknown key. */
|
|
83
|
+
export declare function hintKeyInput(action: HintAction): string | undefined;
|
|
84
|
+
//# sourceMappingURL=clickable-hints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clickable-hints.d.ts","sourceRoot":"","sources":["../src/clickable-hints.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAkB,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,KAAK,KAAK,EAAgB,MAAM,WAAW,CAAC;AAGrD,8GAA8G;AAC9G,MAAM,MAAM,UAAU,GACnB;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAA;CAAE,GAC7C;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1D,iGAAiG;AACjG,MAAM,WAAW,QAAQ;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;CAC5B;AAED,0GAA0G;AAC1G,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC;CACrB;AAID,wBAAgB,aAAa,CAAC,GAAG,EAAE,KAAK,GAAG,UAAU,CAEpD;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,CAE7D;AAeD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,MAAM,CAGlF;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,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;GAGG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AAED,wFAAwF;AACxF,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAOzD;AAED,iHAAiH;AACjH,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAEnE"}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clickable key hints. A hint such as `esc cancel` is drawn with zero-width markers around it that name what a click on
|
|
3
|
+
* it runs: a key, which the renderer feeds to the input path as if it were pressed, or a slash command. The fullscreen
|
|
4
|
+
* renderer strips the markers before writing a frame and remembers where each hint was painted.
|
|
5
|
+
*/
|
|
6
|
+
import { CORE_COMMAND_NAMES } from "./builtin-command-names.js";
|
|
7
|
+
import { getKeybindings } from "./keybindings.js";
|
|
8
|
+
import { keyInputData } from "./keys.js";
|
|
9
|
+
import { extractAnsiCode, HINT_CLOSE, HINT_OPEN, visibleWidth } from "./utils.js";
|
|
10
|
+
const CONTROL_CHARACTERS = /[\u0000-\u001f\u007f-\u009f]/g;
|
|
11
|
+
export function keyHintAction(key) {
|
|
12
|
+
return { kind: "key", key };
|
|
13
|
+
}
|
|
14
|
+
export function commandHintAction(command) {
|
|
15
|
+
return { kind: "command", command };
|
|
16
|
+
}
|
|
17
|
+
function encodeAction(action) {
|
|
18
|
+
const payload = action.kind === "key" ? `k:${action.key}` : `c:${action.command}`;
|
|
19
|
+
return payload.replace(CONTROL_CHARACTERS, "");
|
|
20
|
+
}
|
|
21
|
+
function decodeAction(payload) {
|
|
22
|
+
const value = payload.slice(2);
|
|
23
|
+
if (value === "")
|
|
24
|
+
return undefined;
|
|
25
|
+
if (payload.startsWith("k:"))
|
|
26
|
+
return { kind: "key", key: value };
|
|
27
|
+
if (payload.startsWith("c:"))
|
|
28
|
+
return { kind: "command", command: value };
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* `text` marked as a hint that a click runs `action`. The markers take no columns, so widths, truncation and wrapping
|
|
33
|
+
* are unchanged; text with no action is returned as it is.
|
|
34
|
+
*/
|
|
35
|
+
export function clickableHint(text, action) {
|
|
36
|
+
if (action === undefined || text === "")
|
|
37
|
+
return text;
|
|
38
|
+
return `${HINT_OPEN}${encodeAction(action)}\x07${text}${HINT_CLOSE}`;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A hint naming one or more keys, such as `pgup/pgdn scroll`: the text of each key runs that key, and `label` runs the
|
|
42
|
+
* last one, so a hint that names two keys acts by the half clicked. A part with no key is drawn without an action.
|
|
43
|
+
*/
|
|
44
|
+
export function clickableKeysHint(parts, label = "") {
|
|
45
|
+
if (parts.length === 0)
|
|
46
|
+
return label;
|
|
47
|
+
return parts
|
|
48
|
+
.map((part, index) => clickableHint(index === parts.length - 1 ? part.text + label : part.text, part.key === undefined ? undefined : keyHintAction(part.key)))
|
|
49
|
+
.join("");
|
|
50
|
+
}
|
|
51
|
+
const ARROW_GLYPHS = new Set(["↑", "↓", "←", "→"]);
|
|
52
|
+
const CORE_COMMANDS = new Set(CORE_COMMAND_NAMES);
|
|
53
|
+
const bundledCommandLookups = new WeakMap();
|
|
54
|
+
/** Resolve bundled command hints against the live registrations of the session that owns these bindings. */
|
|
55
|
+
export function bindBundledHintCommands(bindings, isRegistered) {
|
|
56
|
+
bundledCommandLookups.set(bindings, isRegistered);
|
|
57
|
+
}
|
|
58
|
+
/** Key names a hint shows, by the key id they stand for. */
|
|
59
|
+
const HINT_KEY_IDS = {
|
|
60
|
+
"↑": "up",
|
|
61
|
+
"↓": "down",
|
|
62
|
+
"←": "left",
|
|
63
|
+
"→": "right",
|
|
64
|
+
esc: "escape",
|
|
65
|
+
"↵": "enter",
|
|
66
|
+
return: "enter",
|
|
67
|
+
pgup: "pageUp",
|
|
68
|
+
pgdn: "pageDown",
|
|
69
|
+
pageup: "pageUp",
|
|
70
|
+
pagedown: "pageDown",
|
|
71
|
+
del: "delete",
|
|
72
|
+
control: "ctrl",
|
|
73
|
+
option: "alt",
|
|
74
|
+
};
|
|
75
|
+
/** The key id a hint's name for a key stands for, such as `pageUp` for `pgup`; undefined when no key is named. */
|
|
76
|
+
export function hintKeyId(name) {
|
|
77
|
+
const id = name
|
|
78
|
+
.split("+")
|
|
79
|
+
.map((part) => HINT_KEY_IDS[part.toLowerCase()] ?? (part.length === 1 ? part : part.toLowerCase()))
|
|
80
|
+
.join("+");
|
|
81
|
+
return keyInputData(id) === undefined ? undefined : id;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* A hint's key text, such as `pgup/pgdn`, `↑↓` or `esc/←`, split by key: each part keeps its text and the separator
|
|
85
|
+
* after it, so the parts read as the text did, and names the key a click on it presses.
|
|
86
|
+
*/
|
|
87
|
+
export function hintKeyParts(text) {
|
|
88
|
+
return parseHintKeys(text).parts;
|
|
89
|
+
}
|
|
90
|
+
function hintTokenAt(text, start) {
|
|
91
|
+
if (ARROW_GLYPHS.has(text[start]))
|
|
92
|
+
return text[start];
|
|
93
|
+
let token = "";
|
|
94
|
+
for (let index = start; index < text.length; index++) {
|
|
95
|
+
const char = text[index];
|
|
96
|
+
const expectsKey = token.length > 1 && token.endsWith("+") && !token.endsWith("++");
|
|
97
|
+
if (char === " " || (ARROW_GLYPHS.has(char) && !expectsKey))
|
|
98
|
+
break;
|
|
99
|
+
if (char === "/" && token !== "" && !expectsKey)
|
|
100
|
+
break;
|
|
101
|
+
token += char;
|
|
102
|
+
}
|
|
103
|
+
return token;
|
|
104
|
+
}
|
|
105
|
+
const DIGIT_RANGE = /^[1-9]-[1-9]$/;
|
|
106
|
+
function parseHintKeys(text, bindings) {
|
|
107
|
+
const parts = [];
|
|
108
|
+
// Whole-line parsing is speculative: an invalid member invalidates its entire compact shortcut, not just its tail.
|
|
109
|
+
let groupStart = 0;
|
|
110
|
+
let groupPart = 0;
|
|
111
|
+
let afterSlash = false;
|
|
112
|
+
let index = 0;
|
|
113
|
+
while (index < text.length) {
|
|
114
|
+
const start = index;
|
|
115
|
+
if (!afterSlash && text[start - 1] === " ") {
|
|
116
|
+
groupStart = start;
|
|
117
|
+
groupPart = parts.length;
|
|
118
|
+
}
|
|
119
|
+
let token = hintTokenAt(text, index);
|
|
120
|
+
index += token.length;
|
|
121
|
+
const end = index;
|
|
122
|
+
while (text[index] === " ")
|
|
123
|
+
index++;
|
|
124
|
+
if (token !== "" && text[index] === "/") {
|
|
125
|
+
let next = index + 1;
|
|
126
|
+
while (text[next] === " ")
|
|
127
|
+
next++;
|
|
128
|
+
// In `esc / enter` this slash separates keys; in `esc /` the final slash is a key itself.
|
|
129
|
+
const following = index === end ? undefined : hintTokenAt(text, next);
|
|
130
|
+
if (following === undefined || DIGIT_RANGE.test(following) || hintKeyId(following) !== undefined)
|
|
131
|
+
index = next;
|
|
132
|
+
}
|
|
133
|
+
const separator = text.slice(end, index);
|
|
134
|
+
if (token === "") {
|
|
135
|
+
if (parts.length > 0) {
|
|
136
|
+
const last = parts[parts.length - 1];
|
|
137
|
+
parts[parts.length - 1] = { ...last, text: last.text + separator };
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
parts.push({ text: separator });
|
|
141
|
+
}
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
// In a numbered picker, `1-4` shows two keys: the dash belongs to the first, the label to the last.
|
|
145
|
+
if (DIGIT_RANGE.test(token) && (!bindings || bindings.includes(token[0]))) {
|
|
146
|
+
parts.push({ text: token.slice(0, 2), key: token[0] });
|
|
147
|
+
token = token[2];
|
|
148
|
+
}
|
|
149
|
+
const key = hintKeyId(token);
|
|
150
|
+
if (bindings && !(key && (key.length > 1 || bindings.includes(key) || (key === "/" && parts.length > 0)))) {
|
|
151
|
+
return { parts: parts.slice(0, groupPart), label: text.slice(groupStart) };
|
|
152
|
+
}
|
|
153
|
+
afterSlash = separator.includes("/");
|
|
154
|
+
parts.push(key === undefined ? { text: token + separator } : { text: token + separator, key });
|
|
155
|
+
}
|
|
156
|
+
return bindings && afterSlash
|
|
157
|
+
? { parts: parts.slice(0, groupPart), label: text.slice(groupStart) }
|
|
158
|
+
: { parts, label: "" };
|
|
159
|
+
}
|
|
160
|
+
/** A hint for `keyText`, such as `pgup/pgdn`, and `label`, each key running when its text is clicked. */
|
|
161
|
+
export function clickableKeyTextHint(keyText, label) {
|
|
162
|
+
return clickableKeysHint(hintKeyParts(keyText), label);
|
|
163
|
+
}
|
|
164
|
+
export function clickableHintText(text, bindings) {
|
|
165
|
+
// Passing the one-argument builder to Array.map supplies a numeric index, not a binding list.
|
|
166
|
+
const configured = Array.isArray(bindings) ? bindings : [];
|
|
167
|
+
return text
|
|
168
|
+
.split(" · ")
|
|
169
|
+
.map((segment) => {
|
|
170
|
+
const lead = /^\s*/.exec(segment)?.[0] ?? "";
|
|
171
|
+
const body = segment.slice(lead.length);
|
|
172
|
+
const command = /^\/([\w:-]+)(?:\s|$)/.exec(body)?.[1];
|
|
173
|
+
if (command && (CORE_COMMANDS.has(command) || bundledCommandLookups.get(getKeybindings())?.(command))) {
|
|
174
|
+
return lead + slashCommandHint(body);
|
|
175
|
+
}
|
|
176
|
+
if (/^\d+(?:\s*\/\s*\d+)+(?:\s|$)/.test(body))
|
|
177
|
+
return segment;
|
|
178
|
+
const { parts, label } = parseHintKeys(body, configured);
|
|
179
|
+
return lead + clickableKeysHint(parts, label);
|
|
180
|
+
})
|
|
181
|
+
.join(" · ");
|
|
182
|
+
}
|
|
183
|
+
/** A hint naming a slash command, such as `/tasks to manage`, that runs the command when clicked. */
|
|
184
|
+
export function slashCommandHint(text) {
|
|
185
|
+
const command = /^\/[\w:-]+/.exec(text)?.[0];
|
|
186
|
+
return command === undefined ? text : clickableHint(text, commandHintAction(command));
|
|
187
|
+
}
|
|
188
|
+
/** Whether `line` has hint markers. */
|
|
189
|
+
export function hasHintMarkers(line) {
|
|
190
|
+
return line.includes(HINT_OPEN) || line.includes(HINT_CLOSE);
|
|
191
|
+
}
|
|
192
|
+
/** `line` without its hint markers. */
|
|
193
|
+
export function stripHintMarkers(line) {
|
|
194
|
+
return hasHintMarkers(line) ? readHintSpans(line).line : line;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* `line` without its hint markers, and the columns each marked hint covers. A hint whose closing marker was cut off,
|
|
198
|
+
* by truncation for example, ends at the end of the line; a closing marker whose opening one was cut off is dropped.
|
|
199
|
+
*/
|
|
200
|
+
export function readHintSpans(line) {
|
|
201
|
+
if (!hasHintMarkers(line))
|
|
202
|
+
return { line, spans: [] };
|
|
203
|
+
const spans = [];
|
|
204
|
+
let text = "";
|
|
205
|
+
let column = 0;
|
|
206
|
+
let open;
|
|
207
|
+
const close = () => {
|
|
208
|
+
if (open?.action !== undefined && column > open.start)
|
|
209
|
+
spans.push({ start: open.start, end: column, action: open.action });
|
|
210
|
+
open = undefined;
|
|
211
|
+
};
|
|
212
|
+
let index = 0;
|
|
213
|
+
while (index < line.length) {
|
|
214
|
+
const ansi = line.charCodeAt(index) === 0x1b ? extractAnsiCode(line, index) : null;
|
|
215
|
+
if (ansi) {
|
|
216
|
+
index += ansi.length;
|
|
217
|
+
if (ansi.code.startsWith(HINT_OPEN)) {
|
|
218
|
+
close();
|
|
219
|
+
const payload = ansi.code.slice(HINT_OPEN.length).replace(/(?:\x07|\x1b\\)$/, "");
|
|
220
|
+
open = { start: column, action: decodeAction(payload) };
|
|
221
|
+
}
|
|
222
|
+
else if (ansi.code === HINT_CLOSE) {
|
|
223
|
+
close();
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
text += ansi.code;
|
|
227
|
+
}
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
let next = line.indexOf("\x1b", index + 1);
|
|
231
|
+
if (next === -1)
|
|
232
|
+
next = line.length;
|
|
233
|
+
const chunk = line.slice(index, next);
|
|
234
|
+
text += chunk;
|
|
235
|
+
column += visibleWidth(chunk);
|
|
236
|
+
index = next;
|
|
237
|
+
}
|
|
238
|
+
close();
|
|
239
|
+
return { line: text, spans };
|
|
240
|
+
}
|
|
241
|
+
/** The action of the hint painted at `column`, among a row's `spans`. */
|
|
242
|
+
export function hintActionAt(spans, column) {
|
|
243
|
+
return spans?.find((span) => column >= span.start && column < span.end)?.action;
|
|
244
|
+
}
|
|
245
|
+
let hintActivationDepth = 0;
|
|
246
|
+
/**
|
|
247
|
+
* Whether the input being handled was sent by a click on a key hint. A key that acts only on an empty prompt, such as
|
|
248
|
+
* `?` for the keys of a screen, acts for a click whatever the prompt holds: a click cannot be typing.
|
|
249
|
+
*/
|
|
250
|
+
export function isHintActivation() {
|
|
251
|
+
return hintActivationDepth > 0;
|
|
252
|
+
}
|
|
253
|
+
/** Run `handle` as the input of a click on a key hint; see {@link isHintActivation}. */
|
|
254
|
+
export function runAsHintActivation(handle) {
|
|
255
|
+
hintActivationDepth++;
|
|
256
|
+
try {
|
|
257
|
+
return handle();
|
|
258
|
+
}
|
|
259
|
+
finally {
|
|
260
|
+
hintActivationDepth--;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
/** The terminal input a click on a key hint sends for `action`, or undefined for a command or an unknown key. */
|
|
264
|
+
export function hintKeyInput(action) {
|
|
265
|
+
return action.kind === "key" ? keyInputData(action.key) : undefined;
|
|
266
|
+
}
|
|
267
|
+
//# sourceMappingURL=clickable-hints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clickable-hints.js","sourceRoot":"","sources":["../src/clickable-hints.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,cAAc,EAA2B,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAc,YAAY,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAoBlF,MAAM,kBAAkB,GAA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AU,mBAAmB,CAAI,MAAe;IACrD,mBAAmB,EAAE,CAAC;IACtB,IAAI,CAAC;QACJ,OAAO,MAAM,EAAE,CAAC;IACjB,CAAC;YAAS,CAAC;QACV,mBAAmB,EAAE,CAAC;IACvB,CAAC;AACF,CAAC;AAED,iHAAiH;AACjH,MAAM,UAAU,YAAY,CAAC,MAAkB;IAC9C,OAAO,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACrE,CAAC","sourcesContent":["/**\n * Clickable key hints. A hint such as `esc cancel` is drawn with zero-width markers around it that name what a click on\n * it runs: a key, which the renderer feeds to the input path as if it were pressed, or a slash command. The fullscreen\n * renderer strips the markers before writing a frame and remembers where each hint was painted.\n */\n\nimport { CORE_COMMAND_NAMES } from \"./builtin-command-names.ts\";\nimport { getKeybindings, type KeybindingsManager } from \"./keybindings.ts\";\nimport { type KeyId, keyInputData } from \"./keys.ts\";\nimport { extractAnsiCode, HINT_CLOSE, HINT_OPEN, visibleWidth } from \"./utils.ts\";\n\n/** What a click on a hint runs: a key, exactly as if it were pressed, or a slash command such as `/tasks`. */\nexport type HintAction =\n\t| { readonly kind: \"key\"; readonly key: KeyId }\n\t| { readonly kind: \"command\"; readonly command: string };\n\n/** Where a hint was painted on a row, in columns `[start, end)`, and what a click on it runs. */\nexport interface HintSpan {\n\treadonly start: number;\n\treadonly end: number;\n\treadonly action: HintAction;\n}\n\n/** One key a hint names, and the text that names it, such as `pgup/` for the first key of `pgup/pgdn`. */\nexport interface HintKeyPart {\n\treadonly text: string;\n\treadonly key?: KeyId;\n}\n\nconst CONTROL_CHARACTERS = /[\\u0000-\\u001f\\u007f-\\u009f]/g;\n\nexport function keyHintAction(key: KeyId): HintAction {\n\treturn { kind: \"key\", key };\n}\n\nexport function commandHintAction(command: string): HintAction {\n\treturn { kind: \"command\", command };\n}\n\nfunction encodeAction(action: HintAction): string {\n\tconst payload = action.kind === \"key\" ? `k:${action.key}` : `c:${action.command}`;\n\treturn payload.replace(CONTROL_CHARACTERS, \"\");\n}\n\nfunction decodeAction(payload: string): HintAction | undefined {\n\tconst value = payload.slice(2);\n\tif (value === \"\") return undefined;\n\tif (payload.startsWith(\"k:\")) return { kind: \"key\", key: value as KeyId };\n\tif (payload.startsWith(\"c:\")) return { kind: \"command\", command: value };\n\treturn undefined;\n}\n\n/**\n * `text` marked as a hint that a click runs `action`. The markers take no columns, so widths, truncation and wrapping\n * are unchanged; text with no action is returned as it is.\n */\nexport function clickableHint(text: string, action: HintAction | undefined): string {\n\tif (action === undefined || text === \"\") return text;\n\treturn `${HINT_OPEN}${encodeAction(action)}\\x07${text}${HINT_CLOSE}`;\n}\n\n/**\n * A hint naming one or more keys, such as `pgup/pgdn scroll`: the text of each key runs that key, and `label` runs the\n * last one, so a hint that names two keys acts by the half clicked. A part with no key is drawn without an action.\n */\nexport function clickableKeysHint(parts: readonly HintKeyPart[], label = \"\"): string {\n\tif (parts.length === 0) return label;\n\treturn parts\n\t\t.map((part, index) =>\n\t\t\tclickableHint(\n\t\t\t\tindex === parts.length - 1 ? part.text + label : part.text,\n\t\t\t\tpart.key === undefined ? undefined : keyHintAction(part.key),\n\t\t\t),\n\t\t)\n\t\t.join(\"\");\n}\n\nconst ARROW_GLYPHS = new Set([\"↑\", \"↓\", \"←\", \"→\"]);\nconst CORE_COMMANDS = new Set<string>(CORE_COMMAND_NAMES);\nconst bundledCommandLookups = new WeakMap<KeybindingsManager, (name: string) => boolean>();\n\n/** Resolve bundled command hints against the live registrations of the session that owns these bindings. */\nexport function bindBundledHintCommands(bindings: KeybindingsManager, isRegistered: (name: string) => boolean): void {\n\tbundledCommandLookups.set(bindings, isRegistered);\n}\n\n/** Key names a hint shows, by the key id they stand for. */\nconst HINT_KEY_IDS: Record<string, string> = {\n\t\"↑\": \"up\",\n\t\"↓\": \"down\",\n\t\"←\": \"left\",\n\t\"→\": \"right\",\n\tesc: \"escape\",\n\t\"↵\": \"enter\",\n\treturn: \"enter\",\n\tpgup: \"pageUp\",\n\tpgdn: \"pageDown\",\n\tpageup: \"pageUp\",\n\tpagedown: \"pageDown\",\n\tdel: \"delete\",\n\tcontrol: \"ctrl\",\n\toption: \"alt\",\n};\n\n/** The key id a hint's name for a key stands for, such as `pageUp` for `pgup`; undefined when no key is named. */\nexport function hintKeyId(name: string): KeyId | undefined {\n\tconst id = name\n\t\t.split(\"+\")\n\t\t.map((part) => HINT_KEY_IDS[part.toLowerCase()] ?? (part.length === 1 ? part : part.toLowerCase()))\n\t\t.join(\"+\");\n\treturn keyInputData(id as KeyId) === undefined ? undefined : (id as KeyId);\n}\n\n/**\n * A hint's key text, such as `pgup/pgdn`, `↑↓` or `esc/←`, split by key: each part keeps its text and the separator\n * after it, so the parts read as the text did, and names the key a click on it presses.\n */\nexport function hintKeyParts(text: string): HintKeyPart[] {\n\treturn parseHintKeys(text).parts;\n}\n\nfunction hintTokenAt(text: string, start: number): string {\n\tif (ARROW_GLYPHS.has(text[start]!)) return text[start]!;\n\tlet token = \"\";\n\tfor (let index = start; index < text.length; index++) {\n\t\tconst char = text[index]!;\n\t\tconst expectsKey = token.length > 1 && token.endsWith(\"+\") && !token.endsWith(\"++\");\n\t\tif (char === \" \" || (ARROW_GLYPHS.has(char) && !expectsKey)) break;\n\t\tif (char === \"/\" && token !== \"\" && !expectsKey) break;\n\t\ttoken += char;\n\t}\n\treturn token;\n}\n\nconst DIGIT_RANGE = /^[1-9]-[1-9]$/;\n\nfunction parseHintKeys(text: string, bindings?: readonly KeyId[]): { parts: HintKeyPart[]; label: string } {\n\tconst parts: HintKeyPart[] = [];\n\t// Whole-line parsing is speculative: an invalid member invalidates its entire compact shortcut, not just its tail.\n\tlet groupStart = 0;\n\tlet groupPart = 0;\n\tlet afterSlash = false;\n\tlet index = 0;\n\twhile (index < text.length) {\n\t\tconst start = index;\n\t\tif (!afterSlash && text[start - 1] === \" \") {\n\t\t\tgroupStart = start;\n\t\t\tgroupPart = parts.length;\n\t\t}\n\t\tlet token = hintTokenAt(text, index);\n\t\tindex += token.length;\n\t\tconst end = index;\n\t\twhile (text[index] === \" \") index++;\n\t\tif (token !== \"\" && text[index] === \"/\") {\n\t\t\tlet next = index + 1;\n\t\t\twhile (text[next] === \" \") next++;\n\t\t\t// In `esc / enter` this slash separates keys; in `esc /` the final slash is a key itself.\n\t\t\tconst following = index === end ? undefined : hintTokenAt(text, next);\n\t\t\tif (following === undefined || DIGIT_RANGE.test(following) || hintKeyId(following) !== undefined) index = next;\n\t\t}\n\t\tconst separator = text.slice(end, index);\n\t\tif (token === \"\") {\n\t\t\tif (parts.length > 0) {\n\t\t\t\tconst last = parts[parts.length - 1]!;\n\t\t\t\tparts[parts.length - 1] = { ...last, text: last.text + separator };\n\t\t\t} else {\n\t\t\t\tparts.push({ text: separator });\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\t// In a numbered picker, `1-4` shows two keys: the dash belongs to the first, the label to the last.\n\t\tif (DIGIT_RANGE.test(token) && (!bindings || bindings.includes(token[0] as KeyId))) {\n\t\t\tparts.push({ text: token.slice(0, 2), key: token[0] as KeyId });\n\t\t\ttoken = token[2]!;\n\t\t}\n\t\tconst key = hintKeyId(token);\n\t\tif (bindings && !(key && (key.length > 1 || bindings.includes(key) || (key === \"/\" && parts.length > 0)))) {\n\t\t\treturn { parts: parts.slice(0, groupPart), label: text.slice(groupStart) };\n\t\t}\n\t\tafterSlash = separator.includes(\"/\");\n\t\tparts.push(key === undefined ? { text: token + separator } : { text: token + separator, key });\n\t}\n\treturn bindings && afterSlash\n\t\t? { parts: parts.slice(0, groupPart), label: text.slice(groupStart) }\n\t\t: { parts, label: \"\" };\n}\n\n/** A hint for `keyText`, such as `pgup/pgdn`, and `label`, each key running when its text is clicked. */\nexport function clickableKeyTextHint(keyText: string, label: string): string {\n\treturn clickableKeysHint(hintKeyParts(keyText), label);\n}\n\n/**\n * A hint line written as text, such as `↑↓ select · ↵ open · esc close`: each ` · `-separated segment that starts with\n * a complete named key (or a modified key) runs it. Bare letters, digits and punctuation must be listed in `bindings`,\n * except a literal slash following a recognized key. Every member of a compact shortcut must be recognized. Numeric\n * ratios stay plain even with digit bindings. Use {@link clickableKeyTextHint} when the key text is known separately.\n * Built-in slash commands such as `/tasks to manage` run the command. Use {@link slashCommandHint} for custom commands.\n */\nexport function clickableHintText(text: string): string;\nexport function clickableHintText(text: string, bindings: readonly KeyId[]): string;\nexport function clickableHintText(text: string, bindings?: readonly KeyId[]): string {\n\t// Passing the one-argument builder to Array.map supplies a numeric index, not a binding list.\n\tconst configured = Array.isArray(bindings) ? bindings : [];\n\treturn text\n\t\t.split(\" · \")\n\t\t.map((segment) => {\n\t\t\tconst lead = /^\\s*/.exec(segment)?.[0] ?? \"\";\n\t\t\tconst body = segment.slice(lead.length);\n\t\t\tconst command = /^\\/([\\w:-]+)(?:\\s|$)/.exec(body)?.[1];\n\t\t\tif (command && (CORE_COMMANDS.has(command) || bundledCommandLookups.get(getKeybindings())?.(command))) {\n\t\t\t\treturn lead + slashCommandHint(body);\n\t\t\t}\n\t\t\tif (/^\\d+(?:\\s*\\/\\s*\\d+)+(?:\\s|$)/.test(body)) return segment;\n\t\t\tconst { parts, label } = parseHintKeys(body, configured);\n\t\t\treturn lead + clickableKeysHint(parts, label);\n\t\t})\n\t\t.join(\" · \");\n}\n\n/** A hint naming a slash command, such as `/tasks to manage`, that runs the command when clicked. */\nexport function slashCommandHint(text: string): string {\n\tconst command = /^\\/[\\w:-]+/.exec(text)?.[0];\n\treturn command === undefined ? text : clickableHint(text, commandHintAction(command));\n}\n\n/** Whether `line` has hint markers. */\nexport function hasHintMarkers(line: string): boolean {\n\treturn line.includes(HINT_OPEN) || line.includes(HINT_CLOSE);\n}\n\n/** `line` without its hint markers. */\nexport function stripHintMarkers(line: string): string {\n\treturn hasHintMarkers(line) ? readHintSpans(line).line : line;\n}\n\n/**\n * `line` without its hint markers, and the columns each marked hint covers. A hint whose closing marker was cut off,\n * by truncation for example, ends at the end of the line; a closing marker whose opening one was cut off is dropped.\n */\nexport function readHintSpans(line: string): { readonly line: string; readonly spans: readonly HintSpan[] } {\n\tif (!hasHintMarkers(line)) return { line, spans: [] };\n\tconst spans: HintSpan[] = [];\n\tlet text = \"\";\n\tlet column = 0;\n\tlet open: { start: number; action: HintAction | undefined } | undefined;\n\tconst close = () => {\n\t\tif (open?.action !== undefined && column > open.start)\n\t\t\tspans.push({ start: open.start, end: column, action: open.action });\n\t\topen = undefined;\n\t};\n\tlet index = 0;\n\twhile (index < line.length) {\n\t\tconst ansi = line.charCodeAt(index) === 0x1b ? extractAnsiCode(line, index) : null;\n\t\tif (ansi) {\n\t\t\tindex += ansi.length;\n\t\t\tif (ansi.code.startsWith(HINT_OPEN)) {\n\t\t\t\tclose();\n\t\t\t\tconst payload = ansi.code.slice(HINT_OPEN.length).replace(/(?:\\x07|\\x1b\\\\)$/, \"\");\n\t\t\t\topen = { start: column, action: decodeAction(payload) };\n\t\t\t} else if (ansi.code === HINT_CLOSE) {\n\t\t\t\tclose();\n\t\t\t} else {\n\t\t\t\ttext += ansi.code;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tlet next = line.indexOf(\"\\x1b\", index + 1);\n\t\tif (next === -1) next = line.length;\n\t\tconst chunk = line.slice(index, next);\n\t\ttext += chunk;\n\t\tcolumn += visibleWidth(chunk);\n\t\tindex = next;\n\t}\n\tclose();\n\treturn { line: text, spans };\n}\n\n/** The action of the hint painted at `column`, among a row's `spans`. */\nexport function hintActionAt(spans: readonly HintSpan[] | undefined, column: number): HintAction | undefined {\n\treturn spans?.find((span) => column >= span.start && column < span.end)?.action;\n}\n\nlet hintActivationDepth = 0;\n\n/**\n * Whether the input being handled was sent by a click on a key hint. A key that acts only on an empty prompt, such as\n * `?` for the keys of a screen, acts for a click whatever the prompt holds: a click cannot be typing.\n */\nexport function isHintActivation(): boolean {\n\treturn hintActivationDepth > 0;\n}\n\n/** Run `handle` as the input of a click on a key hint; see {@link isHintActivation}. */\nexport function runAsHintActivation<T>(handle: () => T): T {\n\thintActivationDepth++;\n\ttry {\n\t\treturn handle();\n\t} finally {\n\t\thintActivationDepth--;\n\t}\n}\n\n/** The terminal input a click on a key hint sends for `action`, or undefined for a command or an unknown key. */\nexport function hintKeyInput(action: HintAction): string | undefined {\n\treturn action.kind === \"key\" ? keyInputData(action.key) : undefined;\n}\n"]}
|
|
@@ -71,10 +71,13 @@ export declare class Editor implements Component, Focusable {
|
|
|
71
71
|
private autocompletePrefix;
|
|
72
72
|
private autocompleteCompleteOnConfirm;
|
|
73
73
|
private autocompleteSelectionMoved;
|
|
74
|
+
private menuProvider?;
|
|
74
75
|
private autocompleteMaxVisible;
|
|
75
76
|
private autocompleteAbort?;
|
|
76
77
|
private autocompleteDebounceTimer?;
|
|
77
78
|
private autocompleteRequestTask;
|
|
79
|
+
private pendingAutocomplete?;
|
|
80
|
+
private emptyAutocomplete?;
|
|
78
81
|
private autocompleteStartToken;
|
|
79
82
|
private autocompleteRequestId;
|
|
80
83
|
private pastes;
|
|
@@ -102,7 +105,9 @@ export declare class Editor implements Component, Focusable {
|
|
|
102
105
|
setPaddingX(padding: number): void;
|
|
103
106
|
getAutocompleteMaxVisible(): number;
|
|
104
107
|
setAutocompleteMaxVisible(maxVisible: number): void;
|
|
105
|
-
setAutocompleteProvider(provider: AutocompleteProvider
|
|
108
|
+
setAutocompleteProvider(provider: AutocompleteProvider, options?: {
|
|
109
|
+
preserveSelection?: boolean;
|
|
110
|
+
}): void;
|
|
106
111
|
private renderAutocompleteHint;
|
|
107
112
|
/** Past prompts for up/down and history search, newest first. */
|
|
108
113
|
getHistory(): readonly string[];
|
|
@@ -281,6 +286,7 @@ export declare class Editor implements Component, Focusable {
|
|
|
281
286
|
private runAutocompleteRequest;
|
|
282
287
|
private isAutocompleteRequestCurrent;
|
|
283
288
|
private applyAutocompleteSuggestions;
|
|
289
|
+
protected dismissEmptyAutocomplete(): void;
|
|
284
290
|
private cancelAutocompleteRequest;
|
|
285
291
|
private clearAutocompleteUi;
|
|
286
292
|
private cancelAutocomplete;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../src/components/editor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAA2B,MAAM,oBAAoB,CAAC;AACxF,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAIpE,OAAO,EACN,KAAK,SAAS,EAEd,KAAK,SAAS,EAEd,KAAK,GAAG,EACR,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,MAAM,WAAW,CAAC;AAcnB,OAAO,EAA4C,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAoFlG;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,GAAG,SAAS,EAAE,CA4G3G;
|
|
1
|
+
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../src/components/editor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAA2B,MAAM,oBAAoB,CAAC;AACxF,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAIpE,OAAO,EACN,KAAK,SAAS,EAEd,KAAK,SAAS,EAEd,KAAK,GAAG,EACR,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,MAAM,WAAW,CAAC;AAcnB,OAAO,EAA4C,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAoFlG;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAC;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