@fleetagent/pi-tui 0.1.9 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -7
- package/dist/autocomplete.d.ts +17 -23
- package/dist/autocomplete.d.ts.map +1 -1
- package/dist/autocomplete.js +129 -195
- package/dist/autocomplete.js.map +1 -1
- package/dist/components/alt-screen-flash.d.ts +13 -0
- package/dist/components/alt-screen-flash.d.ts.map +1 -0
- package/dist/components/alt-screen-flash.js +37 -0
- package/dist/components/alt-screen-flash.js.map +1 -0
- package/dist/components/editor.d.ts +47 -4
- package/dist/components/editor.d.ts.map +1 -1
- package/dist/components/editor.js +615 -585
- package/dist/components/editor.js.map +1 -1
- package/dist/components/h-stack.d.ts +7 -0
- package/dist/components/h-stack.d.ts.map +1 -0
- package/dist/components/h-stack.js +43 -0
- package/dist/components/h-stack.js.map +1 -0
- package/dist/components/image.d.ts +4 -0
- package/dist/components/image.d.ts.map +1 -1
- package/dist/components/image.js +38 -51
- package/dist/components/image.js.map +1 -1
- package/dist/components/input.d.ts +9 -0
- package/dist/components/input.d.ts.map +1 -1
- package/dist/components/input.js +121 -147
- package/dist/components/input.js.map +1 -1
- package/dist/components/markdown.d.ts +34 -0
- package/dist/components/markdown.d.ts.map +1 -1
- package/dist/components/markdown.js +491 -429
- package/dist/components/markdown.js.map +1 -1
- package/dist/components/scroll-view.d.ts +53 -0
- package/dist/components/scroll-view.d.ts.map +1 -0
- package/dist/components/scroll-view.js +173 -0
- package/dist/components/scroll-view.js.map +1 -0
- package/dist/components/select-list.d.ts.map +1 -1
- package/dist/components/select-list.js.map +1 -1
- package/dist/components/settings-list.d.ts +2 -0
- package/dist/components/settings-list.d.ts.map +1 -1
- package/dist/components/settings-list.js +31 -29
- package/dist/components/settings-list.js.map +1 -1
- package/dist/components/stack.d.ts +32 -0
- package/dist/components/stack.d.ts.map +1 -0
- package/dist/components/stack.js +122 -0
- package/dist/components/stack.js.map +1 -0
- package/dist/components/v-stack.d.ts +8 -0
- package/dist/components/v-stack.d.ts.map +1 -0
- package/dist/components/v-stack.js +27 -0
- package/dist/components/v-stack.js.map +1 -0
- package/dist/fuzzy.d.ts.map +1 -1
- package/dist/fuzzy.js +37 -46
- package/dist/fuzzy.js.map +1 -1
- package/dist/index.d.ts +10 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/keybindings.d.ts +54 -4
- package/dist/keybindings.d.ts.map +1 -1
- package/dist/keybindings.js +39 -4
- package/dist/keybindings.js.map +1 -1
- package/dist/keys.d.ts.map +1 -1
- package/dist/keys.js +359 -479
- package/dist/keys.js.map +1 -1
- package/dist/kill-ring.d.ts +6 -4
- package/dist/kill-ring.d.ts.map +1 -1
- package/dist/kill-ring.js +0 -7
- package/dist/kill-ring.js.map +1 -1
- package/dist/latex.d.ts +10 -0
- package/dist/latex.d.ts.map +1 -0
- package/dist/latex.js +1406 -0
- package/dist/latex.js.map +1 -0
- package/dist/layout-node.d.ts +43 -0
- package/dist/layout-node.d.ts.map +1 -0
- package/dist/layout-node.js +6 -0
- package/dist/layout-node.js.map +1 -0
- package/dist/layout.d.ts +40 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +386 -0
- package/dist/layout.js.map +1 -0
- package/dist/stdin-buffer.d.ts +8 -0
- package/dist/stdin-buffer.d.ts.map +1 -1
- package/dist/stdin-buffer.js +116 -159
- package/dist/stdin-buffer.js.map +1 -1
- package/dist/terminal-image.d.ts +41 -19
- package/dist/terminal-image.d.ts.map +1 -1
- package/dist/terminal-image.js +171 -32
- package/dist/terminal-image.js.map +1 -1
- package/dist/terminal.d.ts +3 -0
- package/dist/terminal.d.ts.map +1 -1
- package/dist/terminal.js +27 -23
- package/dist/terminal.js.map +1 -1
- package/dist/tui-alt-screen.d.ts +114 -0
- package/dist/tui-alt-screen.d.ts.map +1 -0
- package/dist/tui-alt-screen.js +950 -0
- package/dist/tui-alt-screen.js.map +1 -0
- package/dist/tui-main-screen.d.ts +52 -0
- package/dist/tui-main-screen.d.ts.map +1 -0
- package/dist/tui-main-screen.js +511 -0
- package/dist/tui-main-screen.js.map +1 -0
- package/dist/tui.d.ts +112 -44
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +489 -699
- package/dist/tui.js.map +1 -1
- package/dist/utils.d.ts +29 -17
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +605 -528
- package/dist/utils.js.map +1 -1
- package/dist/word-navigation.d.ts.map +1 -1
- package/dist/word-navigation.js +37 -39
- package/dist/word-navigation.js.map +1 -1
- package/package.json +1 -1
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;AAqCD,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CA2BlE;AAED;;;GAGG;AAEH,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","sourcesContent":["/**\n * Fuzzy matching utilities.\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\ninterface FuzzyMatchState {\n\tqueryIndex: number;\n\tscore: number;\n\tlastMatchIndex: number;\n\tconsecutiveMatches: number;\n}\n\nfunction scoreFuzzyCharacterMatch(state: FuzzyMatchState, text: string, index: number): void {\n\tconst isWordBoundary = index === 0 || /[\\s\\-_./:]/.test(text[index - 1]!);\n\tif (state.lastMatchIndex === index - 1) {\n\t\tstate.consecutiveMatches++;\n\t\tstate.score -= state.consecutiveMatches * 5;\n\t} else {\n\t\tstate.consecutiveMatches = 0;\n\t\tif (state.lastMatchIndex >= 0) state.score += (index - state.lastMatchIndex - 1) * 2;\n\t}\n\tif (isWordBoundary) state.score -= 10;\n\tstate.score += index * 0.1;\n\tstate.lastMatchIndex = index;\n\tstate.queryIndex++;\n}\n\nfunction matchNormalizedQuery(normalizedQuery: string, text: string): FuzzyMatch {\n\tif (normalizedQuery.length === 0) return { matches: true, score: 0 };\n\tif (normalizedQuery.length > text.length) return { matches: false, score: 0 };\n\tconst state: FuzzyMatchState = { queryIndex: 0, score: 0, lastMatchIndex: -1, consecutiveMatches: 0 };\n\tfor (let index = 0; index < text.length && state.queryIndex < normalizedQuery.length; index++) {\n\t\tif (text[index] !== normalizedQuery[state.queryIndex]) continue;\n\t\tscoreFuzzyCharacterMatch(state, text, index);\n\t}\n\tif (state.queryIndex < normalizedQuery.length) return { matches: false, score: 0 };\n\tif (normalizedQuery === text) state.score -= 100;\n\treturn { matches: true, score: state.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 = matchNormalizedQuery(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 = matchNormalizedQuery(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 space-separated tokens: all tokens must match.\n */\n// pi-ignore noExcessiveCollectionIterations: Multi-token filtering must independently score every query token against each candidate item, with short-circuiting on the first failed token.\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/fuzzy.js
CHANGED
|
@@ -3,54 +3,44 @@
|
|
|
3
3
|
* Matches if all query characters appear in order (not necessarily consecutive).
|
|
4
4
|
* Lower score = better match.
|
|
5
5
|
*/
|
|
6
|
+
function scoreFuzzyCharacterMatch(state, text, index) {
|
|
7
|
+
const isWordBoundary = index === 0 || /[\s\-_./:]/.test(text[index - 1]);
|
|
8
|
+
if (state.lastMatchIndex === index - 1) {
|
|
9
|
+
state.consecutiveMatches++;
|
|
10
|
+
state.score -= state.consecutiveMatches * 5;
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
state.consecutiveMatches = 0;
|
|
14
|
+
if (state.lastMatchIndex >= 0)
|
|
15
|
+
state.score += (index - state.lastMatchIndex - 1) * 2;
|
|
16
|
+
}
|
|
17
|
+
if (isWordBoundary)
|
|
18
|
+
state.score -= 10;
|
|
19
|
+
state.score += index * 0.1;
|
|
20
|
+
state.lastMatchIndex = index;
|
|
21
|
+
state.queryIndex++;
|
|
22
|
+
}
|
|
23
|
+
function matchNormalizedQuery(normalizedQuery, text) {
|
|
24
|
+
if (normalizedQuery.length === 0)
|
|
25
|
+
return { matches: true, score: 0 };
|
|
26
|
+
if (normalizedQuery.length > text.length)
|
|
27
|
+
return { matches: false, score: 0 };
|
|
28
|
+
const state = { queryIndex: 0, score: 0, lastMatchIndex: -1, consecutiveMatches: 0 };
|
|
29
|
+
for (let index = 0; index < text.length && state.queryIndex < normalizedQuery.length; index++) {
|
|
30
|
+
if (text[index] !== normalizedQuery[state.queryIndex])
|
|
31
|
+
continue;
|
|
32
|
+
scoreFuzzyCharacterMatch(state, text, index);
|
|
33
|
+
}
|
|
34
|
+
if (state.queryIndex < normalizedQuery.length)
|
|
35
|
+
return { matches: false, score: 0 };
|
|
36
|
+
if (normalizedQuery === text)
|
|
37
|
+
state.score -= 100;
|
|
38
|
+
return { matches: true, score: state.score };
|
|
39
|
+
}
|
|
6
40
|
export function fuzzyMatch(query, text) {
|
|
7
41
|
const queryLower = query.toLowerCase();
|
|
8
42
|
const textLower = text.toLowerCase();
|
|
9
|
-
const
|
|
10
|
-
if (normalizedQuery.length === 0) {
|
|
11
|
-
return { matches: true, score: 0 };
|
|
12
|
-
}
|
|
13
|
-
if (normalizedQuery.length > textLower.length) {
|
|
14
|
-
return { matches: false, score: 0 };
|
|
15
|
-
}
|
|
16
|
-
let queryIndex = 0;
|
|
17
|
-
let score = 0;
|
|
18
|
-
let lastMatchIndex = -1;
|
|
19
|
-
let consecutiveMatches = 0;
|
|
20
|
-
for (let i = 0; i < textLower.length && queryIndex < normalizedQuery.length; i++) {
|
|
21
|
-
if (textLower[i] === normalizedQuery[queryIndex]) {
|
|
22
|
-
const isWordBoundary = i === 0 || /[\s\-_./:]/.test(textLower[i - 1]);
|
|
23
|
-
// Reward consecutive matches
|
|
24
|
-
if (lastMatchIndex === i - 1) {
|
|
25
|
-
consecutiveMatches++;
|
|
26
|
-
score -= consecutiveMatches * 5;
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
consecutiveMatches = 0;
|
|
30
|
-
// Penalize gaps
|
|
31
|
-
if (lastMatchIndex >= 0) {
|
|
32
|
-
score += (i - lastMatchIndex - 1) * 2;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
// Reward word boundary matches
|
|
36
|
-
if (isWordBoundary) {
|
|
37
|
-
score -= 10;
|
|
38
|
-
}
|
|
39
|
-
// Slight penalty for later matches
|
|
40
|
-
score += i * 0.1;
|
|
41
|
-
lastMatchIndex = i;
|
|
42
|
-
queryIndex++;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (queryIndex < normalizedQuery.length) {
|
|
46
|
-
return { matches: false, score: 0 };
|
|
47
|
-
}
|
|
48
|
-
if (normalizedQuery === textLower) {
|
|
49
|
-
score -= 100;
|
|
50
|
-
}
|
|
51
|
-
return { matches: true, score };
|
|
52
|
-
};
|
|
53
|
-
const primaryMatch = matchQuery(queryLower);
|
|
43
|
+
const primaryMatch = matchNormalizedQuery(queryLower, textLower);
|
|
54
44
|
if (primaryMatch.matches) {
|
|
55
45
|
return primaryMatch;
|
|
56
46
|
}
|
|
@@ -64,7 +54,7 @@ export function fuzzyMatch(query, text) {
|
|
|
64
54
|
if (!swappedQuery) {
|
|
65
55
|
return primaryMatch;
|
|
66
56
|
}
|
|
67
|
-
const swappedMatch =
|
|
57
|
+
const swappedMatch = matchNormalizedQuery(swappedQuery, textLower);
|
|
68
58
|
if (!swappedMatch.matches) {
|
|
69
59
|
return primaryMatch;
|
|
70
60
|
}
|
|
@@ -74,6 +64,7 @@ export function fuzzyMatch(query, text) {
|
|
|
74
64
|
* Filter and sort items by fuzzy match quality (best matches first).
|
|
75
65
|
* Supports space-separated tokens: all tokens must match.
|
|
76
66
|
*/
|
|
67
|
+
// pi-ignore noExcessiveCollectionIterations: Multi-token filtering must independently score every query token against each candidate item, with short-circuiting on the first failed token.
|
|
77
68
|
export function fuzzyFilter(items, query, getText) {
|
|
78
69
|
if (!query.trim()) {
|
|
79
70
|
return items;
|
package/dist/fuzzy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fuzzy.js","sourceRoot":"","sources":["../src/fuzzy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"fuzzy.js","sourceRoot":"","sources":["../src/fuzzy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH,SAAS,wBAAwB,CAAC,KAAsB,EAAE,IAAY,EAAE,KAAa,EAAQ;IAC5F,MAAM,cAAc,GAAG,KAAK,KAAK,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAE,CAAC,CAAC;IAC1E,IAAI,KAAK,CAAC,cAAc,KAAK,KAAK,GAAG,CAAC,EAAE,CAAC;QACxC,KAAK,CAAC,kBAAkB,EAAE,CAAC;QAC3B,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,kBAAkB,GAAG,CAAC,CAAC;IAC7C,CAAC;SAAM,CAAC;QACP,KAAK,CAAC,kBAAkB,GAAG,CAAC,CAAC;QAC7B,IAAI,KAAK,CAAC,cAAc,IAAI,CAAC;YAAE,KAAK,CAAC,KAAK,IAAI,CAAC,KAAK,GAAG,KAAK,CA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C,CAAC,CAAC,IAAI,CAAC,CAAC;AAAA,CAClC","sourcesContent":["/**\n * Fuzzy matching utilities.\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\ninterface FuzzyMatchState {\n\tqueryIndex: number;\n\tscore: number;\n\tlastMatchIndex: number;\n\tconsecutiveMatches: number;\n}\n\nfunction scoreFuzzyCharacterMatch(state: FuzzyMatchState, text: string, index: number): void {\n\tconst isWordBoundary = index === 0 || /[\\s\\-_./:]/.test(text[index - 1]!);\n\tif (state.lastMatchIndex === index - 1) {\n\t\tstate.consecutiveMatches++;\n\t\tstate.score -= state.consecutiveMatches * 5;\n\t} else {\n\t\tstate.consecutiveMatches = 0;\n\t\tif (state.lastMatchIndex >= 0) state.score += (index - state.lastMatchIndex - 1) * 2;\n\t}\n\tif (isWordBoundary) state.score -= 10;\n\tstate.score += index * 0.1;\n\tstate.lastMatchIndex = index;\n\tstate.queryIndex++;\n}\n\nfunction matchNormalizedQuery(normalizedQuery: string, text: string): FuzzyMatch {\n\tif (normalizedQuery.length === 0) return { matches: true, score: 0 };\n\tif (normalizedQuery.length > text.length) return { matches: false, score: 0 };\n\tconst state: FuzzyMatchState = { queryIndex: 0, score: 0, lastMatchIndex: -1, consecutiveMatches: 0 };\n\tfor (let index = 0; index < text.length && state.queryIndex < normalizedQuery.length; index++) {\n\t\tif (text[index] !== normalizedQuery[state.queryIndex]) continue;\n\t\tscoreFuzzyCharacterMatch(state, text, index);\n\t}\n\tif (state.queryIndex < normalizedQuery.length) return { matches: false, score: 0 };\n\tif (normalizedQuery === text) state.score -= 100;\n\treturn { matches: true, score: state.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 = matchNormalizedQuery(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 = matchNormalizedQuery(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 space-separated tokens: all tokens must match.\n */\n// pi-ignore noExcessiveCollectionIterations: Multi-token filtering must independently score every query token against each candidate item, with short-circuiting on the first failed token.\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
|
@@ -1,23 +1,30 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Marked, type Token, type Tokens } from "marked";
|
|
2
|
+
export { type AutocompleteCompletion, type AutocompleteItem, type AutocompleteProvider, type AutocompleteSuggestionRequest, type AutocompleteSuggestions, CombinedAutocompleteProvider, type SlashCommand, } from "./autocomplete.ts";
|
|
2
3
|
export { Box } from "./components/box.ts";
|
|
3
4
|
export { CancellableLoader } from "./components/cancellable-loader.ts";
|
|
4
5
|
export { Editor, type EditorOptions, type EditorTheme } from "./components/editor.ts";
|
|
6
|
+
export { HStack } from "./components/h-stack.ts";
|
|
5
7
|
export { Image, type ImageOptions, type ImageTheme } from "./components/image.ts";
|
|
6
8
|
export { Input } from "./components/input.ts";
|
|
7
9
|
export { Loader, type LoaderIndicatorOptions } from "./components/loader.ts";
|
|
8
10
|
export { type DefaultTextStyle, Markdown, type MarkdownOptions, type MarkdownTheme } from "./components/markdown.ts";
|
|
11
|
+
export { ScrollView, type ScrollViewOptions, type ScrollViewScrollbar } from "./components/scroll-view.ts";
|
|
9
12
|
export { type SelectItem, SelectList, type SelectListLayoutOptions, type SelectListTheme, type SelectListTruncatePrimaryContext, } from "./components/select-list.ts";
|
|
10
13
|
export { type SettingItem, SettingsList, type SettingsListTheme } from "./components/settings-list.ts";
|
|
11
14
|
export { Spacer } from "./components/spacer.ts";
|
|
12
15
|
export { Text } from "./components/text.ts";
|
|
13
16
|
export { TruncatedText } from "./components/truncated-text.ts";
|
|
17
|
+
export { type StackChild, type StackEntry, type StackEntryOptions, type StackOptions, VStack, } from "./components/v-stack.ts";
|
|
14
18
|
export type { EditorComponent } from "./editor-component.ts";
|
|
15
19
|
export { type FuzzyMatch, fuzzyFilter, fuzzyMatch } from "./fuzzy.ts";
|
|
16
20
|
export { getKeybindings, type Keybinding, type KeybindingConflict, type KeybindingDefinition, type KeybindingDefinitions, type Keybindings, type KeybindingsConfig, KeybindingsManager, setKeybindings, TUI_KEYBINDINGS, } from "./keybindings.ts";
|
|
17
21
|
export { decodeKittyPrintable, isKeyRelease, isKeyRepeat, isKittyProtocolActive, Key, type KeyEventType, type KeyId, matchesKey, parseKey, setKittyProtocolActive, } from "./keys.ts";
|
|
22
|
+
export { type RenderLatexOptions, renderLatex } from "./latex.ts";
|
|
18
23
|
export { StdinBuffer, type StdinBufferEventMap, type StdinBufferOptions } from "./stdin-buffer.ts";
|
|
19
24
|
export { ProcessTerminal, type Terminal } from "./terminal.ts";
|
|
20
25
|
export { allocateImageId, type CellDimensions, calculateImageRows, deleteAllKittyImages, deleteKittyImage, detectCapabilities, encodeITerm2, encodeKitty, getCapabilities, getCellDimensions, getGifDimensions, getImageDimensions, getJpegDimensions, getPngDimensions, getWebpDimensions, hyperlink, type ImageDimensions, type ImageProtocol, type ImageRenderOptions, imageFallback, renderImage, resetCapabilitiesCache, setCapabilities, setCellDimensions, type TerminalCapabilities, } from "./terminal-image.ts";
|
|
21
|
-
export { type Component, Container, CURSOR_MARKER, type Focusable, isFocusable, type OverlayAnchor, type OverlayHandle, type OverlayMargin, type OverlayOptions, type SizeValue, TUI, } from "./tui.ts";
|
|
22
|
-
export {
|
|
26
|
+
export { type Component, Container, CURSOR_MARKER, compositeTuiLine, type Focusable, isFocusable, isViewportTUI, type OverlayAnchor, type OverlayHandle, type OverlayMargin, type OverlayOptions, type OverlayUnfocusOptions, type SizeValue, type TUI, type TuiInputListener, type TuiInputListenerResult, type TuiMode, type TuiStopOptions, type ViewportTUI, } from "./tui.ts";
|
|
27
|
+
export { TuiAltScreen, type TuiAltScreenOptions } from "./tui-alt-screen.ts";
|
|
28
|
+
export { TuiMainScreen, type TuiMainScreenRenderState } from "./tui-main-screen.ts";
|
|
29
|
+
export { getOsc8LinkAtColumn, sliceByColumn, stripTerminalSequences, truncateToWidth, visibleWidth, wrapTextWithAnsi, } from "./utils.ts";
|
|
23
30
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,4BAA4B,EAC5B,KAAK,YAAY,GACjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,KAAK,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,KAAK,gBAAgB,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACrH,OAAO,EACN,KAAK,UAAU,EACf,UAAU,EACV,KAAK,uBAAuB,EAC5B,KAAK,eAAe,EACpB,KAAK,gCAAgC,GACrC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,KAAK,WAAW,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvG,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,KAAK,KAAK,EAAE,KAAK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AM,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,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,KAAK,GAAG,EACR,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,WAAW,GAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,KAAK,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEpF,OAAO,EACN,mBAAmB,EACnB,aAAa,EACb,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,gBAAgB,GAChB,MAAM,YAAY,CAAC","sourcesContent":["// Core TUI interfaces and classes\n\n// Markdown parser API\nexport { Marked, type Token, type Tokens } from \"marked\";\n// Autocomplete support\nexport {\n\ttype AutocompleteCompletion,\n\ttype AutocompleteItem,\n\ttype AutocompleteProvider,\n\ttype AutocompleteSuggestionRequest,\n\ttype AutocompleteSuggestions,\n\tCombinedAutocompleteProvider,\n\ttype SlashCommand,\n} from \"./autocomplete.ts\";\n// Components\nexport { Box } from \"./components/box.ts\";\nexport { CancellableLoader } from \"./components/cancellable-loader.ts\";\nexport { Editor, type EditorOptions, type EditorTheme } from \"./components/editor.ts\";\nexport { HStack } from \"./components/h-stack.ts\";\nexport { Image, type ImageOptions, type ImageTheme } 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 { ScrollView, type ScrollViewOptions, type ScrollViewScrollbar } 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\";\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\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\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// Input buffering for batch splitting\nexport { StdinBuffer, type StdinBufferEventMap, type StdinBufferOptions } from \"./stdin-buffer.ts\";\n// Terminal interface and implementations\nexport { ProcessTerminal, type Terminal } from \"./terminal.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\tgetWebpDimensions,\n\thyperlink,\n\ttype ImageDimensions,\n\ttype ImageProtocol,\n\ttype ImageRenderOptions,\n\timageFallback,\n\trenderImage,\n\tresetCapabilitiesCache,\n\tsetCapabilities,\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 OverlayHandle,\n\ttype OverlayMargin,\n\ttype OverlayOptions,\n\ttype OverlayUnfocusOptions,\n\ttype SizeValue,\n\ttype TUI,\n\ttype TuiInputListener,\n\ttype TuiInputListenerResult,\n\ttype TuiMode,\n\ttype TuiStopOptions,\n\ttype ViewportTUI,\n} from \"./tui.ts\";\nexport { TuiAltScreen, type TuiAltScreenOptions } from \"./tui-alt-screen.ts\";\nexport { TuiMainScreen, type TuiMainScreenRenderState } from \"./tui-main-screen.ts\";\n// Utilities\nexport {\n\tgetOsc8LinkAtColumn,\n\tsliceByColumn,\n\tstripTerminalSequences,\n\ttruncateToWidth,\n\tvisibleWidth,\n\twrapTextWithAnsi,\n} from \"./utils.ts\";\n"]}
|
package/dist/index.js
CHANGED
|
@@ -1,32 +1,41 @@
|
|
|
1
1
|
// Core TUI interfaces and classes
|
|
2
|
+
// Markdown parser API
|
|
3
|
+
export { Marked } from "marked";
|
|
2
4
|
// Autocomplete support
|
|
3
5
|
export { CombinedAutocompleteProvider, } from "./autocomplete.js";
|
|
4
6
|
// Components
|
|
5
7
|
export { Box } from "./components/box.js";
|
|
6
8
|
export { CancellableLoader } from "./components/cancellable-loader.js";
|
|
7
9
|
export { Editor } from "./components/editor.js";
|
|
10
|
+
export { HStack } from "./components/h-stack.js";
|
|
8
11
|
export { Image } from "./components/image.js";
|
|
9
12
|
export { Input } from "./components/input.js";
|
|
10
13
|
export { Loader } from "./components/loader.js";
|
|
11
14
|
export { Markdown } from "./components/markdown.js";
|
|
15
|
+
export { ScrollView } from "./components/scroll-view.js";
|
|
12
16
|
export { SelectList, } from "./components/select-list.js";
|
|
13
17
|
export { SettingsList } from "./components/settings-list.js";
|
|
14
18
|
export { Spacer } from "./components/spacer.js";
|
|
15
19
|
export { Text } from "./components/text.js";
|
|
16
20
|
export { TruncatedText } from "./components/truncated-text.js";
|
|
21
|
+
export { VStack, } from "./components/v-stack.js";
|
|
17
22
|
// Fuzzy matching
|
|
18
23
|
export { fuzzyFilter, fuzzyMatch } from "./fuzzy.js";
|
|
19
24
|
// Keybindings
|
|
20
25
|
export { getKeybindings, KeybindingsManager, setKeybindings, TUI_KEYBINDINGS, } from "./keybindings.js";
|
|
21
26
|
// Keyboard input handling
|
|
22
27
|
export { decodeKittyPrintable, isKeyRelease, isKeyRepeat, isKittyProtocolActive, Key, matchesKey, parseKey, setKittyProtocolActive, } from "./keys.js";
|
|
28
|
+
// LaTeX rendering
|
|
29
|
+
export { renderLatex } from "./latex.js";
|
|
23
30
|
// Input buffering for batch splitting
|
|
24
31
|
export { StdinBuffer } from "./stdin-buffer.js";
|
|
25
32
|
// Terminal interface and implementations
|
|
26
33
|
export { ProcessTerminal } from "./terminal.js";
|
|
27
34
|
// Terminal image support
|
|
28
35
|
export { allocateImageId, calculateImageRows, deleteAllKittyImages, deleteKittyImage, detectCapabilities, encodeITerm2, encodeKitty, getCapabilities, getCellDimensions, getGifDimensions, getImageDimensions, getJpegDimensions, getPngDimensions, getWebpDimensions, hyperlink, imageFallback, renderImage, resetCapabilitiesCache, setCapabilities, setCellDimensions, } from "./terminal-image.js";
|
|
29
|
-
export { Container, CURSOR_MARKER, isFocusable,
|
|
36
|
+
export { Container, CURSOR_MARKER, compositeTuiLine, isFocusable, isViewportTUI, } from "./tui.js";
|
|
37
|
+
export { TuiAltScreen } from "./tui-alt-screen.js";
|
|
38
|
+
export { TuiMainScreen } from "./tui-main-screen.js";
|
|
30
39
|
// Utilities
|
|
31
|
-
export { truncateToWidth, visibleWidth, wrapTextWithAnsi } from "./utils.js";
|
|
40
|
+
export { getOsc8LinkAtColumn, sliceByColumn, stripTerminalSequences, truncateToWidth, visibleWidth, wrapTextWithAnsi, } from "./utils.js";
|
|
32
41
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAElC,uBAAuB;AACvB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAElC,sBAAsB;AACtB,OAAO,EAAE,MAAM,EAA2B,MAAM,QAAQ,CAAC;AACzD,uBAAuB;AACvB,OAAO,EAMN,4BAA4B,GAE5B,MAAM,mBAAmB,CAAC;AAC3B,aAAa;AACb,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,MAAM,EAAwC,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAsC,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAA+B,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAyB,QAAQ,EAA4C,MAAM,0BAA0B,CAAC;AACrH,OAAO,EAAE,UAAU,EAAoD,MAAM,6BAA6B,CAAC;AAC3G,OAAO,EAEN,UAAU,GAIV,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAoB,YAAY,EAA0B,MAAM,+BAA+B,CAAC;AACvG,OAAO,EAAE,MAAM,EAAE,MAAM,wBAA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AAmB,EACnB,aAAa,EACb,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,gBAAgB,GAChB,MAAM,YAAY,CAAC","sourcesContent":["// Core TUI interfaces and classes\n\n// Markdown parser API\nexport { Marked, type Token, type Tokens } from \"marked\";\n// Autocomplete support\nexport {\n\ttype AutocompleteCompletion,\n\ttype AutocompleteItem,\n\ttype AutocompleteProvider,\n\ttype AutocompleteSuggestionRequest,\n\ttype AutocompleteSuggestions,\n\tCombinedAutocompleteProvider,\n\ttype SlashCommand,\n} from \"./autocomplete.ts\";\n// Components\nexport { Box } from \"./components/box.ts\";\nexport { CancellableLoader } from \"./components/cancellable-loader.ts\";\nexport { Editor, type EditorOptions, type EditorTheme } from \"./components/editor.ts\";\nexport { HStack } from \"./components/h-stack.ts\";\nexport { Image, type ImageOptions, type ImageTheme } 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 { ScrollView, type ScrollViewOptions, type ScrollViewScrollbar } 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\";\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\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\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// Input buffering for batch splitting\nexport { StdinBuffer, type StdinBufferEventMap, type StdinBufferOptions } from \"./stdin-buffer.ts\";\n// Terminal interface and implementations\nexport { ProcessTerminal, type Terminal } from \"./terminal.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\tgetWebpDimensions,\n\thyperlink,\n\ttype ImageDimensions,\n\ttype ImageProtocol,\n\ttype ImageRenderOptions,\n\timageFallback,\n\trenderImage,\n\tresetCapabilitiesCache,\n\tsetCapabilities,\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 OverlayHandle,\n\ttype OverlayMargin,\n\ttype OverlayOptions,\n\ttype OverlayUnfocusOptions,\n\ttype SizeValue,\n\ttype TUI,\n\ttype TuiInputListener,\n\ttype TuiInputListenerResult,\n\ttype TuiMode,\n\ttype TuiStopOptions,\n\ttype ViewportTUI,\n} from \"./tui.ts\";\nexport { TuiAltScreen, type TuiAltScreenOptions } from \"./tui-alt-screen.ts\";\nexport { TuiMainScreen, type TuiMainScreenRenderState } from \"./tui-main-screen.ts\";\n// Utilities\nexport {\n\tgetOsc8LinkAtColumn,\n\tsliceByColumn,\n\tstripTerminalSequences,\n\ttruncateToWidth,\n\tvisibleWidth,\n\twrapTextWithAnsi,\n} from \"./utils.ts\";\n"]}
|
package/dist/keybindings.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ import { type KeyId } from "./keys.ts";
|
|
|
6
6
|
export interface Keybindings {
|
|
7
7
|
"tui.editor.cursorUp": true;
|
|
8
8
|
"tui.editor.cursorDown": true;
|
|
9
|
+
"tui.editor.historyPrevious": true;
|
|
10
|
+
"tui.editor.historyNext": true;
|
|
9
11
|
"tui.editor.cursorLeft": true;
|
|
10
12
|
"tui.editor.cursorRight": true;
|
|
11
13
|
"tui.editor.cursorWordLeft": true;
|
|
@@ -35,6 +37,14 @@ export interface Keybindings {
|
|
|
35
37
|
"tui.select.pageDown": true;
|
|
36
38
|
"tui.select.confirm": true;
|
|
37
39
|
"tui.select.cancel": true;
|
|
40
|
+
"tui.altScreen.pageUp": true;
|
|
41
|
+
"tui.altScreen.pageDown": true;
|
|
42
|
+
"tui.altScreen.halfPageUp": true;
|
|
43
|
+
"tui.altScreen.halfPageDown": true;
|
|
44
|
+
"tui.altScreen.previousPrompt": true;
|
|
45
|
+
"tui.altScreen.nextPrompt": true;
|
|
46
|
+
"tui.altScreen.top": true;
|
|
47
|
+
"tui.altScreen.bottom": true;
|
|
38
48
|
}
|
|
39
49
|
export type Keybinding = keyof Keybindings;
|
|
40
50
|
export interface KeybindingDefinition {
|
|
@@ -52,6 +62,14 @@ export declare const TUI_KEYBINDINGS: {
|
|
|
52
62
|
readonly defaultKeys: "down";
|
|
53
63
|
readonly description: "Move cursor down";
|
|
54
64
|
};
|
|
65
|
+
readonly "tui.editor.historyPrevious": {
|
|
66
|
+
readonly defaultKeys: [];
|
|
67
|
+
readonly description: "Select previous prompt history entry";
|
|
68
|
+
};
|
|
69
|
+
readonly "tui.editor.historyNext": {
|
|
70
|
+
readonly defaultKeys: [];
|
|
71
|
+
readonly description: "Select next prompt history entry";
|
|
72
|
+
};
|
|
55
73
|
readonly "tui.editor.cursorLeft": {
|
|
56
74
|
readonly defaultKeys: ["left", "ctrl+b"];
|
|
57
75
|
readonly description: "Move cursor left";
|
|
@@ -69,11 +87,11 @@ export declare const TUI_KEYBINDINGS: {
|
|
|
69
87
|
readonly description: "Move cursor word right";
|
|
70
88
|
};
|
|
71
89
|
readonly "tui.editor.cursorLineStart": {
|
|
72
|
-
readonly defaultKeys: ["home", "ctrl+a"];
|
|
90
|
+
readonly defaultKeys: ["home", "ctrl+home", "ctrl+a"];
|
|
73
91
|
readonly description: "Move to line start";
|
|
74
92
|
};
|
|
75
93
|
readonly "tui.editor.cursorLineEnd": {
|
|
76
|
-
readonly defaultKeys: ["end", "ctrl+e"];
|
|
94
|
+
readonly defaultKeys: ["end", "ctrl+end", "ctrl+e"];
|
|
77
95
|
readonly description: "Move to line end";
|
|
78
96
|
};
|
|
79
97
|
readonly "tui.editor.jumpForward": {
|
|
@@ -85,11 +103,11 @@ export declare const TUI_KEYBINDINGS: {
|
|
|
85
103
|
readonly description: "Jump backward to character";
|
|
86
104
|
};
|
|
87
105
|
readonly "tui.editor.pageUp": {
|
|
88
|
-
readonly defaultKeys: "pageUp";
|
|
106
|
+
readonly defaultKeys: ["pageUp", "ctrl+pageUp"];
|
|
89
107
|
readonly description: "Page up";
|
|
90
108
|
};
|
|
91
109
|
readonly "tui.editor.pageDown": {
|
|
92
|
-
readonly defaultKeys: "pageDown";
|
|
110
|
+
readonly defaultKeys: ["pageDown", "ctrl+pageDown"];
|
|
93
111
|
readonly description: "Page down";
|
|
94
112
|
};
|
|
95
113
|
readonly "tui.editor.deleteCharBackward": {
|
|
@@ -168,6 +186,38 @@ export declare const TUI_KEYBINDINGS: {
|
|
|
168
186
|
readonly defaultKeys: ["escape", "ctrl+c"];
|
|
169
187
|
readonly description: "Cancel selection";
|
|
170
188
|
};
|
|
189
|
+
readonly "tui.altScreen.pageUp": {
|
|
190
|
+
readonly defaultKeys: "pageUp";
|
|
191
|
+
readonly description: "Scroll viewport up one page";
|
|
192
|
+
};
|
|
193
|
+
readonly "tui.altScreen.pageDown": {
|
|
194
|
+
readonly defaultKeys: "pageDown";
|
|
195
|
+
readonly description: "Scroll viewport down one page";
|
|
196
|
+
};
|
|
197
|
+
readonly "tui.altScreen.halfPageUp": {
|
|
198
|
+
readonly defaultKeys: [];
|
|
199
|
+
readonly description: "Scroll viewport up half a page";
|
|
200
|
+
};
|
|
201
|
+
readonly "tui.altScreen.halfPageDown": {
|
|
202
|
+
readonly defaultKeys: [];
|
|
203
|
+
readonly description: "Scroll viewport down half a page";
|
|
204
|
+
};
|
|
205
|
+
readonly "tui.altScreen.previousPrompt": {
|
|
206
|
+
readonly defaultKeys: "ctrl+shift+up";
|
|
207
|
+
readonly description: "Jump to previous semantic prompt";
|
|
208
|
+
};
|
|
209
|
+
readonly "tui.altScreen.nextPrompt": {
|
|
210
|
+
readonly defaultKeys: "ctrl+shift+down";
|
|
211
|
+
readonly description: "Jump to next semantic prompt";
|
|
212
|
+
};
|
|
213
|
+
readonly "tui.altScreen.top": {
|
|
214
|
+
readonly defaultKeys: "home";
|
|
215
|
+
readonly description: "Scroll viewport to top";
|
|
216
|
+
};
|
|
217
|
+
readonly "tui.altScreen.bottom": {
|
|
218
|
+
readonly defaultKeys: "end";
|
|
219
|
+
readonly description: "Scroll viewport to bottom";
|
|
220
|
+
};
|
|
171
221
|
};
|
|
172
222
|
export interface KeybindingConflict {
|
|
173
223
|
key: KeyId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keybindings.d.ts","sourceRoot":"","sources":["../src/keybindings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAA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esKey } from \"./keys.ts\";\n\n/**\n * Global keybinding registry.\n * Downstream packages can add keybindings via declaration merging.\n */\nexport interface Keybindings {\n\t// Editor navigation and editing\n\t\"tui.editor.cursorUp\": true;\n\t\"tui.editor.cursorDown\": true;\n\t\"tui.editor.cursorLeft\": true;\n\t\"tui.editor.cursorRight\": true;\n\t\"tui.editor.cursorWordLeft\": true;\n\t\"tui.editor.cursorWordRight\": true;\n\t\"tui.editor.cursorLineStart\": true;\n\t\"tui.editor.cursorLineEnd\": true;\n\t\"tui.editor.jumpForward\": true;\n\t\"tui.editor.jumpBackward\": true;\n\t\"tui.editor.pageUp\": true;\n\t\"tui.editor.pageDown\": true;\n\t\"tui.editor.deleteCharBackward\": true;\n\t\"tui.editor.deleteCharForward\": true;\n\t\"tui.editor.deleteWordBackward\": true;\n\t\"tui.editor.deleteWordForward\": true;\n\t\"tui.editor.deleteToLineStart\": true;\n\t\"tui.editor.deleteToLineEnd\": true;\n\t\"tui.editor.yank\": true;\n\t\"tui.editor.yankPop\": true;\n\t\"tui.editor.undo\": true;\n\t// Generic input actions\n\t\"tui.input.newLine\": true;\n\t\"tui.input.submit\": true;\n\t\"tui.input.tab\": true;\n\t\"tui.input.copy\": true;\n\t// Generic selection actions\n\t\"tui.select.up\": true;\n\t\"tui.select.down\": true;\n\t\"tui.select.pageUp\": true;\n\t\"tui.select.pageDown\": true;\n\t\"tui.select.confirm\": true;\n\t\"tui.select.cancel\": true;\n}\n\nexport type Keybinding = keyof Keybindings;\n\nexport interface KeybindingDefinition {\n\tdefaultKeys: KeyId | KeyId[];\n\tdescription?: string;\n}\n\nexport type KeybindingDefinitions = Record<string, KeybindingDefinition>;\nexport type KeybindingsConfig = Record<string, KeyId | KeyId[] | undefined>;\n\nexport const TUI_KEYBINDINGS = {\n\t\"tui.editor.cursorUp\": { defaultKeys: \"up\", description: \"Move cursor up\" },\n\t\"tui.editor.cursorDown\": { defaultKeys: \"down\", description: \"Move cursor down\" },\n\t\"tui.editor.cursorLeft\": {\n\t\tdefaultKeys: [\"left\", \"ctrl+b\"],\n\t\tdescription: \"Move cursor left\",\n\t},\n\t\"tui.editor.cursorRight\": {\n\t\tdefaultKeys: [\"right\", \"ctrl+f\"],\n\t\tdescription: \"Move cursor right\",\n\t},\n\t\"tui.editor.cursorWordLeft\": {\n\t\tdefaultKeys: [\"alt+left\", \"ctrl+left\", \"alt+b\"],\n\t\tdescription: \"Move cursor word left\",\n\t},\n\t\"tui.editor.cursorWordRight\": {\n\t\tdefaultKeys: [\"alt+right\", \"ctrl+right\", \"alt+f\"],\n\t\tdescription: \"Move cursor word right\",\n\t},\n\t\"tui.editor.cursorLineStart\": {\n\t\tdefaultKeys: [\"home\", \"ctrl+a\"],\n\t\tdescription: \"Move to line start\",\n\t},\n\t\"tui.editor.cursorLineEnd\": {\n\t\tdefaultKeys: [\"end\", \"ctrl+e\"],\n\t\tdescription: \"Move to line end\",\n\t},\n\t\"tui.editor.jumpForward\": {\n\t\tdefaultKeys: \"ctrl+]\",\n\t\tdescription: \"Jump forward to character\",\n\t},\n\t\"tui.editor.jumpBackward\": {\n\t\tdefaultKeys: \"ctrl+alt+]\",\n\t\tdescription: \"Jump backward to character\",\n\t},\n\t\"tui.editor.pageUp\": { defaultKeys: \"pageUp\", description: \"Page up\" },\n\t\"tui.editor.pageDown\": { defaultKeys: \"pageDown\", description: \"Page down\" },\n\t\"tui.editor.deleteCharBackward\": {\n\t\tdefaultKeys: \"backspace\",\n\t\tdescription: \"Delete character backward\",\n\t},\n\t\"tui.editor.deleteCharForward\": {\n\t\tdefaultKeys: [\"delete\", \"ctrl+d\"],\n\t\tdescription: \"Delete character forward\",\n\t},\n\t\"tui.editor.deleteWordBackward\": {\n\t\tdefaultKeys: [\"ctrl+w\", \"alt+backspace\"],\n\t\tdescription: \"Delete word backward\",\n\t},\n\t\"tui.editor.deleteWordForward\": {\n\t\tdefaultKeys: [\"alt+d\", \"alt+delete\"],\n\t\tdescription: \"Delete word forward\",\n\t},\n\t\"tui.editor.deleteToLineStart\": {\n\t\tdefaultKeys: \"ctrl+u\",\n\t\tdescription: \"Delete to line start\",\n\t},\n\t\"tui.editor.deleteToLineEnd\": {\n\t\tdefaultKeys: \"ctrl+k\",\n\t\tdescription: \"Delete to line end\",\n\t},\n\t\"tui.editor.yank\": { defaultKeys: \"ctrl+y\", description: \"Yank\" },\n\t\"tui.editor.yankPop\": { defaultKeys: \"alt+y\", description: \"Yank pop\" },\n\t\"tui.editor.undo\": { defaultKeys: \"ctrl+-\", description: \"Undo\" },\n\t\"tui.input.newLine\": { defaultKeys: \"shift+enter\", description: \"Insert newline\" },\n\t\"tui.input.submit\": { defaultKeys: \"enter\", description: \"Submit input\" },\n\t\"tui.input.tab\": { defaultKeys: \"tab\", description: \"Tab / autocomplete\" },\n\t\"tui.input.copy\": { defaultKeys: \"ctrl+c\", description: \"Copy selection\" },\n\t\"tui.select.up\": { defaultKeys: \"up\", description: \"Move selection up\" },\n\t\"tui.select.down\": { defaultKeys: \"down\", description: \"Move selection down\" },\n\t\"tui.select.pageUp\": { defaultKeys: \"pageUp\", description: \"Selection page up\" },\n\t\"tui.select.pageDown\": {\n\t\tdefaultKeys: \"pageDown\",\n\t\tdescription: \"Selection page down\",\n\t},\n\t\"tui.select.confirm\": { defaultKeys: \"enter\", description: \"Confirm selection\" },\n\t\"tui.select.cancel\": {\n\t\tdefaultKeys: [\"escape\", \"ctrl+c\"],\n\t\tdescription: \"Cancel selection\",\n\t},\n} as const satisfies KeybindingDefinitions;\n\nexport interface KeybindingConflict {\n\tkey: KeyId;\n\tkeybindings: string[];\n}\n\nfunction normalizeKeys(keys: KeyId | KeyId[] | undefined): KeyId[] {\n\tif (keys === undefined) return [];\n\tconst keyList = Array.isArray(keys) ? keys : [keys];\n\tconst seen = new Set<KeyId>();\n\tconst result: KeyId[] = [];\n\tfor (const key of keyList) {\n\t\tif (!seen.has(key)) {\n\t\t\tseen.add(key);\n\t\t\tresult.push(key);\n\t\t}\n\t}\n\treturn result;\n}\n\nexport class KeybindingsManager {\n\tprivate definitions: KeybindingDefinitions;\n\tprivate userBindings: KeybindingsConfig;\n\tprivate keysById = new Map<Keybinding, KeyId[]>();\n\tprivate conflicts: KeybindingConflict[] = [];\n\n\tconstructor(definitions: KeybindingDefinitions, userBindings: KeybindingsConfig = {}) {\n\t\tthis.definitions = definitions;\n\t\tthis.userBindings = userBindings;\n\t\tthis.rebuild();\n\t}\n\n\tprivate rebuild(): void {\n\t\tthis.keysById.clear();\n\t\tthis.conflicts = [];\n\n\t\tconst userClaims = new Map<KeyId, Set<Keybinding>>();\n\t\tfor (const [keybinding, keys] of Object.entries(this.userBindings)) {\n\t\t\tif (!(keybinding in this.definitions)) continue;\n\t\t\tfor (const key of normalizeKeys(keys)) {\n\t\t\t\tconst claimants = userClaims.get(key) ?? new Set<Keybinding>();\n\t\t\t\tclaimants.add(keybinding as Keybinding);\n\t\t\t\tuserClaims.set(key, claimants);\n\t\t\t}\n\t\t}\n\n\t\tfor (const [key, keybindings] of userClaims) {\n\t\t\tif (keybindings.size > 1) {\n\t\t\t\tthis.conflicts.push({ key, keybindings: [...keybindings] });\n\t\t\t}\n\t\t}\n\n\t\tfor (const [id, definition] of Object.entries(this.definitions)) {\n\t\t\tconst userKeys = this.userBindings[id];\n\t\t\tconst keys = userKeys === undefined ? normalizeKeys(definition.defaultKeys) : normalizeKeys(userKeys);\n\t\t\tthis.keysById.set(id as Keybinding, keys);\n\t\t}\n\t}\n\n\tmatches(data: string, keybinding: Keybinding): boolean {\n\t\tconst keys = this.keysById.get(keybinding) ?? [];\n\t\tfor (const key of keys) {\n\t\t\tif (matchesKey(data, key)) return true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tgetKeys(keybinding: Keybinding): KeyId[] {\n\t\treturn [...(this.keysById.get(keybinding) ?? [])];\n\t}\n\n\tgetDefinition(keybinding: Keybinding): KeybindingDefinition {\n\t\treturn this.definitions[keybinding];\n\t}\n\n\tgetConflicts(): KeybindingConflict[] {\n\t\treturn this.conflicts.map((conflict) => ({ ...conflict, keybindings: [...conflict.keybindings] }));\n\t}\n\n\tsetUserBindings(userBindings: KeybindingsConfig): void {\n\t\tthis.userBindings = userBindings;\n\t\tthis.rebuild();\n\t}\n\n\tgetUserBindings(): KeybindingsConfig {\n\t\treturn { ...this.userBindings };\n\t}\n\n\tgetResolvedBindings(): KeybindingsConfig {\n\t\tconst resolved: KeybindingsConfig = {};\n\t\tfor (const id of Object.keys(this.definitions)) {\n\t\t\tconst keys = this.keysById.get(id as Keybinding) ?? [];\n\t\t\tresolved[id] = keys.length === 1 ? keys[0]! : [...keys];\n\t\t}\n\t\treturn resolved;\n\t}\n}\n\nlet globalKeybindings: KeybindingsManager | null = null;\n\nexport function setKeybindings(keybindings: KeybindingsManager): void {\n\tglobalKeybindings = keybindings;\n}\n\nexport function getKeybindings(): KeybindingsManager {\n\tif (!globalKeybindings) {\n\t\tglobalKeybindings = new KeybindingsManager(TUI_KEYBINDINGS);\n\t}\n\treturn globalKeybindings;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"keybindings.d.ts","sourceRoot":"","sources":["../src/keybindings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAc,MAAM,WAAW,CAAC;AAEnD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAE3B,qBAAqB,EAAE,IAAI,CAAC;IAC5B,uBAAuB,EAAE,IAAI,CAAC;IAC9B,4BAA4B,EAAE,IAAI,CAAC;IACnC,wBAAwB,EAAE,IAAI,CAAC;IAC/B,uBAAuB,EAAE,IAAI,CAAC;IAC9B,wBAAwB,EAAE,IAAI,CAAC;IAC/B,2BAA2B,EAAE,IAAI,CAAC;IAClC,4BAA4B,EAAE,IAAI,CAAC;IACnC,4BAA4B,EAAE,IAAI,CAAC;IACnC,0BAA0B,EAAE,IAAI,CAAC;IACjC,wBAAwB,EAAE,IAAI,CAAC;IAC/B,yBAAyB,EAAE,IAAI,CAAC;IAChC,mBAAmB,EAAE,IAAI,CAAC;IAC1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KAAK,EAAE,GAAG,SAAS,CAAC,CAAC;AAE5E,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmHc,CAAC;AAE3C,MAAM,WAAW,kBAAkB;IAClC,GAAG,EAAE,KAAK,CAAC;IACX,WAAW,EAAE,MAAM,EAAE,CAAC;CACtB;AAgBD,qBAAa,kBAAkB;IAC9B,OAAO,CAAC,WAAW,CAAwB;IAC3C,OAAO,CAAC,YAAY,CAAoB;IACxC,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,SAAS,CAA4B;IAE7C,YAAY,WAAW,EAAE,qBAAqB,EAAE,YAAY,GAAE,iBAAsB,EAInF;IAED,OAAO,CAAC,OAAO;IA2Bf,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAMrD;IAED,OAAO,CAAC,UAAU,EAAE,UAAU,GAAG,KAAK,EAAE,CAEvC;IAED,aAAa,CAAC,UAAU,EAAE,UAAU,GAAG,oBAAoB,CAE1D;IAED,YAAY,IAAI,kBAAkB,EAAE,CAEnC;IAED,eAAe,CAAC,YAAY,EAAE,iBAAiB,GAAG,IAAI,CAGrD;IAED,eAAe,IAAI,iBAAiB,CAEnC;IAED,mBAAmB,IAAI,iBAAiB,CAOvC;CACD;AAID,wBAAgB,cAAc,CAAC,WAAW,EAAE,kBAAkB,GAAG,IAAI,CAEpE;AAED,wBAAgB,cAAc,IAAI,kBAAkB,CAKnD","sourcesContent":["import { type KeyId, matchesKey } from \"./keys.ts\";\n\n/**\n * Global keybinding registry.\n * Downstream packages can add keybindings via declaration merging.\n */\nexport interface Keybindings {\n\t// Editor navigation and editing\n\t\"tui.editor.cursorUp\": true;\n\t\"tui.editor.cursorDown\": true;\n\t\"tui.editor.historyPrevious\": true;\n\t\"tui.editor.historyNext\": true;\n\t\"tui.editor.cursorLeft\": true;\n\t\"tui.editor.cursorRight\": true;\n\t\"tui.editor.cursorWordLeft\": true;\n\t\"tui.editor.cursorWordRight\": true;\n\t\"tui.editor.cursorLineStart\": true;\n\t\"tui.editor.cursorLineEnd\": true;\n\t\"tui.editor.jumpForward\": true;\n\t\"tui.editor.jumpBackward\": true;\n\t\"tui.editor.pageUp\": true;\n\t\"tui.editor.pageDown\": true;\n\t\"tui.editor.deleteCharBackward\": true;\n\t\"tui.editor.deleteCharForward\": true;\n\t\"tui.editor.deleteWordBackward\": true;\n\t\"tui.editor.deleteWordForward\": true;\n\t\"tui.editor.deleteToLineStart\": true;\n\t\"tui.editor.deleteToLineEnd\": true;\n\t\"tui.editor.yank\": true;\n\t\"tui.editor.yankPop\": true;\n\t\"tui.editor.undo\": true;\n\t// Generic input actions\n\t\"tui.input.newLine\": true;\n\t\"tui.input.submit\": true;\n\t\"tui.input.tab\": true;\n\t\"tui.input.copy\": true;\n\t// Generic selection actions\n\t\"tui.select.up\": true;\n\t\"tui.select.down\": true;\n\t\"tui.select.pageUp\": true;\n\t\"tui.select.pageDown\": true;\n\t\"tui.select.confirm\": true;\n\t\"tui.select.cancel\": true;\n\t// Alternate-screen viewport navigation\n\t\"tui.altScreen.pageUp\": true;\n\t\"tui.altScreen.pageDown\": true;\n\t\"tui.altScreen.halfPageUp\": true;\n\t\"tui.altScreen.halfPageDown\": true;\n\t\"tui.altScreen.previousPrompt\": true;\n\t\"tui.altScreen.nextPrompt\": true;\n\t\"tui.altScreen.top\": true;\n\t\"tui.altScreen.bottom\": true;\n}\n\nexport type Keybinding = keyof Keybindings;\n\nexport interface KeybindingDefinition {\n\tdefaultKeys: KeyId | KeyId[];\n\tdescription?: string;\n}\n\nexport type KeybindingDefinitions = Record<string, KeybindingDefinition>;\nexport type KeybindingsConfig = Record<string, KeyId | KeyId[] | undefined>;\n\nexport const TUI_KEYBINDINGS = {\n\t\"tui.editor.cursorUp\": { defaultKeys: \"up\", description: \"Move cursor up\" },\n\t\"tui.editor.cursorDown\": { defaultKeys: \"down\", description: \"Move cursor down\" },\n\t\"tui.editor.historyPrevious\": {\n\t\tdefaultKeys: [],\n\t\tdescription: \"Select previous prompt history entry\",\n\t},\n\t\"tui.editor.historyNext\": {\n\t\tdefaultKeys: [],\n\t\tdescription: \"Select next prompt history entry\",\n\t},\n\t\"tui.editor.cursorLeft\": {\n\t\tdefaultKeys: [\"left\", \"ctrl+b\"],\n\t\tdescription: \"Move cursor left\",\n\t},\n\t\"tui.editor.cursorRight\": {\n\t\tdefaultKeys: [\"right\", \"ctrl+f\"],\n\t\tdescription: \"Move cursor right\",\n\t},\n\t\"tui.editor.cursorWordLeft\": {\n\t\tdefaultKeys: [\"alt+left\", \"ctrl+left\", \"alt+b\"],\n\t\tdescription: \"Move cursor word left\",\n\t},\n\t\"tui.editor.cursorWordRight\": {\n\t\tdefaultKeys: [\"alt+right\", \"ctrl+right\", \"alt+f\"],\n\t\tdescription: \"Move cursor word right\",\n\t},\n\t\"tui.editor.cursorLineStart\": {\n\t\tdefaultKeys: [\"home\", \"ctrl+home\", \"ctrl+a\"],\n\t\tdescription: \"Move to line start\",\n\t},\n\t\"tui.editor.cursorLineEnd\": {\n\t\tdefaultKeys: [\"end\", \"ctrl+end\", \"ctrl+e\"],\n\t\tdescription: \"Move to line end\",\n\t},\n\t\"tui.editor.jumpForward\": {\n\t\tdefaultKeys: \"ctrl+]\",\n\t\tdescription: \"Jump forward to character\",\n\t},\n\t\"tui.editor.jumpBackward\": {\n\t\tdefaultKeys: \"ctrl+alt+]\",\n\t\tdescription: \"Jump backward to character\",\n\t},\n\t\"tui.editor.pageUp\": { defaultKeys: [\"pageUp\", \"ctrl+pageUp\"], description: \"Page up\" },\n\t\"tui.editor.pageDown\": { defaultKeys: [\"pageDown\", \"ctrl+pageDown\"], description: \"Page down\" },\n\t\"tui.editor.deleteCharBackward\": {\n\t\tdefaultKeys: \"backspace\",\n\t\tdescription: \"Delete character backward\",\n\t},\n\t\"tui.editor.deleteCharForward\": {\n\t\tdefaultKeys: [\"delete\", \"ctrl+d\"],\n\t\tdescription: \"Delete character forward\",\n\t},\n\t\"tui.editor.deleteWordBackward\": {\n\t\tdefaultKeys: [\"ctrl+w\", \"alt+backspace\"],\n\t\tdescription: \"Delete word backward\",\n\t},\n\t\"tui.editor.deleteWordForward\": {\n\t\tdefaultKeys: [\"alt+d\", \"alt+delete\"],\n\t\tdescription: \"Delete word forward\",\n\t},\n\t\"tui.editor.deleteToLineStart\": {\n\t\tdefaultKeys: \"ctrl+u\",\n\t\tdescription: \"Delete to line start\",\n\t},\n\t\"tui.editor.deleteToLineEnd\": {\n\t\tdefaultKeys: \"ctrl+k\",\n\t\tdescription: \"Delete to line end\",\n\t},\n\t\"tui.editor.yank\": { defaultKeys: \"ctrl+y\", description: \"Yank\" },\n\t\"tui.editor.yankPop\": { defaultKeys: \"alt+y\", description: \"Yank pop\" },\n\t\"tui.editor.undo\": { defaultKeys: \"ctrl+-\", description: \"Undo\" },\n\t\"tui.input.newLine\": { defaultKeys: \"shift+enter\", description: \"Insert newline\" },\n\t\"tui.input.submit\": { defaultKeys: \"enter\", description: \"Submit input\" },\n\t\"tui.input.tab\": { defaultKeys: \"tab\", description: \"Tab / autocomplete\" },\n\t\"tui.input.copy\": { defaultKeys: \"ctrl+c\", description: \"Copy selection\" },\n\t\"tui.select.up\": { defaultKeys: \"up\", description: \"Move selection up\" },\n\t\"tui.select.down\": { defaultKeys: \"down\", description: \"Move selection down\" },\n\t\"tui.select.pageUp\": { defaultKeys: \"pageUp\", description: \"Selection page up\" },\n\t\"tui.select.pageDown\": {\n\t\tdefaultKeys: \"pageDown\",\n\t\tdescription: \"Selection page down\",\n\t},\n\t\"tui.select.confirm\": { defaultKeys: \"enter\", description: \"Confirm selection\" },\n\t\"tui.select.cancel\": {\n\t\tdefaultKeys: [\"escape\", \"ctrl+c\"],\n\t\tdescription: \"Cancel selection\",\n\t},\n\t// These intentionally shadow the unmodified editor bindings in fullscreen mode.\n\t\"tui.altScreen.pageUp\": {\n\t\tdefaultKeys: \"pageUp\",\n\t\tdescription: \"Scroll viewport up one page\",\n\t},\n\t\"tui.altScreen.pageDown\": {\n\t\tdefaultKeys: \"pageDown\",\n\t\tdescription: \"Scroll viewport down one page\",\n\t},\n\t\"tui.altScreen.halfPageUp\": {\n\t\tdefaultKeys: [],\n\t\tdescription: \"Scroll viewport up half a page\",\n\t},\n\t\"tui.altScreen.halfPageDown\": {\n\t\tdefaultKeys: [],\n\t\tdescription: \"Scroll viewport down half a page\",\n\t},\n\t\"tui.altScreen.previousPrompt\": {\n\t\tdefaultKeys: \"ctrl+shift+up\",\n\t\tdescription: \"Jump to previous semantic prompt\",\n\t},\n\t\"tui.altScreen.nextPrompt\": {\n\t\tdefaultKeys: \"ctrl+shift+down\",\n\t\tdescription: \"Jump to next semantic prompt\",\n\t},\n\t\"tui.altScreen.top\": { defaultKeys: \"home\", description: \"Scroll viewport to top\" },\n\t\"tui.altScreen.bottom\": { defaultKeys: \"end\", description: \"Scroll viewport to bottom\" },\n} as const satisfies KeybindingDefinitions;\n\nexport interface KeybindingConflict {\n\tkey: KeyId;\n\tkeybindings: string[];\n}\n\nfunction normalizeKeys(keys: KeyId | KeyId[] | undefined): KeyId[] {\n\tif (keys === undefined) return [];\n\tconst keyList = Array.isArray(keys) ? keys : [keys];\n\tconst seen = new Set<KeyId>();\n\tconst result: KeyId[] = [];\n\tfor (const key of keyList) {\n\t\tif (!seen.has(key)) {\n\t\t\tseen.add(key);\n\t\t\tresult.push(key);\n\t\t}\n\t}\n\treturn result;\n}\n\nexport class KeybindingsManager {\n\tprivate definitions: KeybindingDefinitions;\n\tprivate userBindings: KeybindingsConfig;\n\tprivate keysById = new Map<Keybinding, KeyId[]>();\n\tprivate conflicts: KeybindingConflict[] = [];\n\n\tconstructor(definitions: KeybindingDefinitions, userBindings: KeybindingsConfig = {}) {\n\t\tthis.definitions = definitions;\n\t\tthis.userBindings = userBindings;\n\t\tthis.rebuild();\n\t}\n\n\tprivate rebuild(): void {\n\t\tthis.keysById.clear();\n\t\tthis.conflicts = [];\n\n\t\tconst userClaims = new Map<KeyId, Set<Keybinding>>();\n\t\tfor (const [keybinding, keys] of Object.entries(this.userBindings)) {\n\t\t\tif (!(keybinding in this.definitions)) continue;\n\t\t\tfor (const key of normalizeKeys(keys)) {\n\t\t\t\tconst claimants = userClaims.get(key) ?? new Set<Keybinding>();\n\t\t\t\tclaimants.add(keybinding as Keybinding);\n\t\t\t\tuserClaims.set(key, claimants);\n\t\t\t}\n\t\t}\n\n\t\tfor (const [key, keybindings] of userClaims) {\n\t\t\tif (keybindings.size > 1) {\n\t\t\t\tthis.conflicts.push({ key, keybindings: [...keybindings] });\n\t\t\t}\n\t\t}\n\n\t\tfor (const [id, definition] of Object.entries(this.definitions)) {\n\t\t\tconst userKeys = this.userBindings[id];\n\t\t\tconst keys = userKeys === undefined ? normalizeKeys(definition.defaultKeys) : normalizeKeys(userKeys);\n\t\t\tthis.keysById.set(id as Keybinding, keys);\n\t\t}\n\t}\n\n\tmatches(data: string, keybinding: Keybinding): boolean {\n\t\tconst keys = this.keysById.get(keybinding) ?? [];\n\t\tfor (const key of keys) {\n\t\t\tif (matchesKey(data, key)) return true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tgetKeys(keybinding: Keybinding): KeyId[] {\n\t\treturn [...(this.keysById.get(keybinding) ?? [])];\n\t}\n\n\tgetDefinition(keybinding: Keybinding): KeybindingDefinition {\n\t\treturn this.definitions[keybinding];\n\t}\n\n\tgetConflicts(): KeybindingConflict[] {\n\t\treturn this.conflicts.map((conflict) => ({ ...conflict, keybindings: [...conflict.keybindings] }));\n\t}\n\n\tsetUserBindings(userBindings: KeybindingsConfig): void {\n\t\tthis.userBindings = userBindings;\n\t\tthis.rebuild();\n\t}\n\n\tgetUserBindings(): KeybindingsConfig {\n\t\treturn { ...this.userBindings };\n\t}\n\n\tgetResolvedBindings(): KeybindingsConfig {\n\t\tconst resolved: KeybindingsConfig = {};\n\t\tfor (const id of Object.keys(this.definitions)) {\n\t\t\tconst keys = this.keysById.get(id as Keybinding) ?? [];\n\t\t\tresolved[id] = keys.length === 1 ? keys[0]! : [...keys];\n\t\t}\n\t\treturn resolved;\n\t}\n}\n\nlet globalKeybindings: KeybindingsManager | null = null;\n\nexport function setKeybindings(keybindings: KeybindingsManager): void {\n\tglobalKeybindings = keybindings;\n}\n\nexport function getKeybindings(): KeybindingsManager {\n\tif (!globalKeybindings) {\n\t\tglobalKeybindings = new KeybindingsManager(TUI_KEYBINDINGS);\n\t}\n\treturn globalKeybindings;\n}\n"]}
|
package/dist/keybindings.js
CHANGED
|
@@ -2,6 +2,14 @@ import { matchesKey } from "./keys.js";
|
|
|
2
2
|
export const TUI_KEYBINDINGS = {
|
|
3
3
|
"tui.editor.cursorUp": { defaultKeys: "up", description: "Move cursor up" },
|
|
4
4
|
"tui.editor.cursorDown": { defaultKeys: "down", description: "Move cursor down" },
|
|
5
|
+
"tui.editor.historyPrevious": {
|
|
6
|
+
defaultKeys: [],
|
|
7
|
+
description: "Select previous prompt history entry",
|
|
8
|
+
},
|
|
9
|
+
"tui.editor.historyNext": {
|
|
10
|
+
defaultKeys: [],
|
|
11
|
+
description: "Select next prompt history entry",
|
|
12
|
+
},
|
|
5
13
|
"tui.editor.cursorLeft": {
|
|
6
14
|
defaultKeys: ["left", "ctrl+b"],
|
|
7
15
|
description: "Move cursor left",
|
|
@@ -19,11 +27,11 @@ export const TUI_KEYBINDINGS = {
|
|
|
19
27
|
description: "Move cursor word right",
|
|
20
28
|
},
|
|
21
29
|
"tui.editor.cursorLineStart": {
|
|
22
|
-
defaultKeys: ["home", "ctrl+a"],
|
|
30
|
+
defaultKeys: ["home", "ctrl+home", "ctrl+a"],
|
|
23
31
|
description: "Move to line start",
|
|
24
32
|
},
|
|
25
33
|
"tui.editor.cursorLineEnd": {
|
|
26
|
-
defaultKeys: ["end", "ctrl+e"],
|
|
34
|
+
defaultKeys: ["end", "ctrl+end", "ctrl+e"],
|
|
27
35
|
description: "Move to line end",
|
|
28
36
|
},
|
|
29
37
|
"tui.editor.jumpForward": {
|
|
@@ -34,8 +42,8 @@ export const TUI_KEYBINDINGS = {
|
|
|
34
42
|
defaultKeys: "ctrl+alt+]",
|
|
35
43
|
description: "Jump backward to character",
|
|
36
44
|
},
|
|
37
|
-
"tui.editor.pageUp": { defaultKeys: "pageUp", description: "Page up" },
|
|
38
|
-
"tui.editor.pageDown": { defaultKeys: "pageDown", description: "Page down" },
|
|
45
|
+
"tui.editor.pageUp": { defaultKeys: ["pageUp", "ctrl+pageUp"], description: "Page up" },
|
|
46
|
+
"tui.editor.pageDown": { defaultKeys: ["pageDown", "ctrl+pageDown"], description: "Page down" },
|
|
39
47
|
"tui.editor.deleteCharBackward": {
|
|
40
48
|
defaultKeys: "backspace",
|
|
41
49
|
description: "Delete character backward",
|
|
@@ -79,6 +87,33 @@ export const TUI_KEYBINDINGS = {
|
|
|
79
87
|
defaultKeys: ["escape", "ctrl+c"],
|
|
80
88
|
description: "Cancel selection",
|
|
81
89
|
},
|
|
90
|
+
// These intentionally shadow the unmodified editor bindings in fullscreen mode.
|
|
91
|
+
"tui.altScreen.pageUp": {
|
|
92
|
+
defaultKeys: "pageUp",
|
|
93
|
+
description: "Scroll viewport up one page",
|
|
94
|
+
},
|
|
95
|
+
"tui.altScreen.pageDown": {
|
|
96
|
+
defaultKeys: "pageDown",
|
|
97
|
+
description: "Scroll viewport down one page",
|
|
98
|
+
},
|
|
99
|
+
"tui.altScreen.halfPageUp": {
|
|
100
|
+
defaultKeys: [],
|
|
101
|
+
description: "Scroll viewport up half a page",
|
|
102
|
+
},
|
|
103
|
+
"tui.altScreen.halfPageDown": {
|
|
104
|
+
defaultKeys: [],
|
|
105
|
+
description: "Scroll viewport down half a page",
|
|
106
|
+
},
|
|
107
|
+
"tui.altScreen.previousPrompt": {
|
|
108
|
+
defaultKeys: "ctrl+shift+up",
|
|
109
|
+
description: "Jump to previous semantic prompt",
|
|
110
|
+
},
|
|
111
|
+
"tui.altScreen.nextPrompt": {
|
|
112
|
+
defaultKeys: "ctrl+shift+down",
|
|
113
|
+
description: "Jump to next semantic prompt",
|
|
114
|
+
},
|
|
115
|
+
"tui.altScreen.top": { defaultKeys: "home", description: "Scroll viewport to top" },
|
|
116
|
+
"tui.altScreen.bottom": { defaultKeys: "end", description: "Scroll viewport to bottom" },
|
|
82
117
|
};
|
|
83
118
|
function normalizeKeys(keys) {
|
|
84
119
|
if (keys === undefined)
|