@travisennis/acai 0.0.12 → 0.0.13
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 +3 -2
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +2 -5
- package/dist/commands/history/types.d.ts +3 -2
- package/dist/commands/history/types.d.ts.map +1 -1
- package/dist/commands/init-project/utils.d.ts +0 -1
- package/dist/commands/init-project/utils.d.ts.map +1 -1
- package/dist/commands/init-project/utils.js +1 -1
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +0 -18
- package/dist/commands/share/html-renderer.d.ts.map +1 -1
- package/dist/commands/share/html-renderer.js +54 -48
- package/dist/commands/tools/index.js +39 -38
- package/dist/config/index.d.ts +0 -2
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +2 -6
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +94 -76
- package/dist/models/manager.d.ts +1 -10
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +2 -2
- package/dist/models/opencode-go-provider.d.ts +4 -4
- package/dist/models/opencode-go-provider.d.ts.map +1 -1
- package/dist/models/opencode-go-provider.js +29 -35
- package/dist/models/providers.d.ts +1 -1
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/prompts/system-prompt.d.ts +0 -2
- package/dist/prompts/system-prompt.d.ts.map +1 -1
- package/dist/prompts/system-prompt.js +6 -10
- package/dist/repl/index.d.ts +27 -11
- package/dist/repl/index.d.ts.map +1 -1
- package/dist/repl/index.js +238 -254
- package/dist/skills/index.d.ts +12 -2
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +123 -73
- package/dist/terminal/control.d.ts +1 -21
- package/dist/terminal/control.d.ts.map +1 -1
- package/dist/terminal/control.js +1 -32
- package/dist/terminal/formatting.d.ts +0 -33
- package/dist/terminal/formatting.d.ts.map +1 -1
- package/dist/terminal/formatting.js +0 -91
- package/dist/terminal/highlight/theme.d.ts +0 -37
- package/dist/terminal/highlight/theme.d.ts.map +1 -1
- package/dist/terminal/highlight/theme.js +1 -79
- package/dist/terminal/keys.d.ts +0 -97
- package/dist/terminal/keys.d.ts.map +1 -1
- package/dist/terminal/keys.js +0 -194
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +65 -51
- package/dist/terminal/style.d.ts +1 -1
- package/dist/terminal/style.d.ts.map +1 -1
- package/dist/terminal/supports-color.d.ts.map +1 -1
- package/dist/terminal/supports-color.js +38 -20
- package/dist/terminal/supports-hyperlinks.d.ts +3 -0
- package/dist/terminal/supports-hyperlinks.d.ts.map +1 -1
- package/dist/terminal/supports-hyperlinks.js +72 -31
- package/dist/terminal/table/layout-manager.d.ts +0 -20
- package/dist/terminal/table/layout-manager.d.ts.map +1 -1
- package/dist/terminal/table/layout-manager.js +68 -44
- package/dist/terminal/table/utils.d.ts +0 -1
- package/dist/terminal/table/utils.d.ts.map +1 -1
- package/dist/terminal/table/utils.js +2 -4
- package/dist/tools/apply-patch.d.ts +5 -3
- package/dist/tools/apply-patch.d.ts.map +1 -1
- package/dist/tools/apply-patch.js +154 -123
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +11 -8
- package/dist/tools/dynamic-tool-loader.d.ts +6 -1
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +154 -135
- package/dist/tools/index.d.ts +3 -133
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +0 -20
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +32 -13
- package/dist/tools/skill.d.ts.map +1 -1
- package/dist/tools/skill.js +20 -13
- package/dist/tools/web-fetch.d.ts +2 -6
- package/dist/tools/web-fetch.d.ts.map +1 -1
- package/dist/tools/web-fetch.js +59 -36
- package/dist/tools/web-search.d.ts +0 -4
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +40 -32
- package/dist/tui/autocomplete/utils.d.ts +0 -15
- package/dist/tui/autocomplete/utils.d.ts.map +1 -1
- package/dist/tui/autocomplete/utils.js +0 -85
- package/dist/tui/autocomplete.d.ts +1 -1
- package/dist/tui/autocomplete.d.ts.map +1 -1
- package/dist/tui/autocomplete.js +1 -1
- package/dist/tui/components/editor.d.ts +12 -0
- package/dist/tui/components/editor.d.ts.map +1 -1
- package/dist/tui/components/editor.js +181 -195
- package/dist/tui/components/input.d.ts +4 -0
- package/dist/tui/components/input.d.ts.map +1 -1
- package/dist/tui/components/input.js +33 -31
- package/dist/tui/components/markdown.d.ts +30 -0
- package/dist/tui/components/markdown.d.ts.map +1 -1
- package/dist/tui/components/markdown.js +274 -242
- package/dist/tui/components/modal.d.ts.map +1 -1
- package/dist/tui/components/modal.js +11 -11
- package/dist/tui/components/select-list.d.ts +5 -0
- package/dist/tui/components/select-list.d.ts.map +1 -1
- package/dist/tui/components/select-list.js +69 -98
- package/dist/tui/components/table.d.ts +6 -0
- package/dist/tui/components/table.d.ts.map +1 -1
- package/dist/tui/components/table.js +61 -52
- package/dist/tui/index.d.ts +1 -8
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +0 -8
- package/dist/tui/tui.d.ts +9 -0
- package/dist/tui/tui.d.ts.map +1 -1
- package/dist/tui/tui.js +78 -48
- package/dist/tui/utils.d.ts +7 -0
- package/dist/tui/utils.d.ts.map +1 -1
- package/dist/tui/utils.js +117 -53
- package/dist/utils/bash.d.ts.map +1 -1
- package/dist/utils/bash.js +121 -104
- package/dist/utils/command-protection.d.ts +3 -2
- package/dist/utils/command-protection.d.ts.map +1 -1
- package/dist/utils/command-protection.js +42 -33
- package/dist/utils/filesystem/operations.d.ts +0 -15
- package/dist/utils/filesystem/operations.d.ts.map +1 -1
- package/dist/utils/filesystem/operations.js +1 -38
- package/dist/utils/filesystem/security.d.ts.map +1 -1
- package/dist/utils/filesystem/security.js +22 -15
- package/dist/utils/filetype-detection.d.ts +0 -1
- package/dist/utils/filetype-detection.d.ts.map +1 -1
- package/dist/utils/filetype-detection.js +0 -12
- package/dist/utils/formatting.d.ts +0 -30
- package/dist/utils/formatting.d.ts.map +1 -1
- package/dist/utils/formatting.js +0 -44
- package/dist/utils/git.d.ts +4 -6
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +36 -46
- package/dist/utils/ignore.d.ts +1 -1
- package/dist/utils/ignore.d.ts.map +1 -1
- package/dist/utils/ignore.js +1 -1
- package/dist/utils/process.d.ts.map +1 -1
- package/dist/utils/process.js +77 -79
- package/dist/utils/yaml.d.ts +0 -1
- package/dist/utils/yaml.d.ts.map +1 -1
- package/dist/utils/yaml.js +80 -89
- package/dist/utils/zod.d.ts +0 -3
- package/dist/utils/zod.d.ts.map +1 -1
- package/dist/utils/zod.js +0 -7
- package/package.json +25 -24
- package/dist/agent/sub-agent.d.ts +0 -23
- package/dist/agent/sub-agent.d.ts.map +0 -1
- package/dist/agent/sub-agent.js +0 -109
- package/dist/commands/add-directory/index.d.ts +0 -3
- package/dist/commands/add-directory/index.d.ts.map +0 -1
- package/dist/commands/add-directory/index.js +0 -50
- package/dist/commands/add-directory/utils.d.ts +0 -3
- package/dist/commands/add-directory/utils.d.ts.map +0 -1
- package/dist/commands/add-directory/utils.js +0 -15
- package/dist/commands/clear/index.d.ts +0 -3
- package/dist/commands/clear/index.d.ts.map +0 -1
- package/dist/commands/clear/index.js +0 -13
- package/dist/commands/generate-rules/index.d.ts +0 -3
- package/dist/commands/generate-rules/index.d.ts.map +0 -1
- package/dist/commands/generate-rules/index.js +0 -206
- package/dist/commands/generate-rules/service.d.ts +0 -22
- package/dist/commands/generate-rules/service.d.ts.map +0 -1
- package/dist/commands/generate-rules/service.js +0 -103
- package/dist/commands/generate-rules/utils.d.ts +0 -5
- package/dist/commands/generate-rules/utils.d.ts.map +0 -1
- package/dist/commands/generate-rules/utils.js +0 -25
- package/dist/commands/handoff/index.d.ts +0 -3
- package/dist/commands/handoff/index.d.ts.map +0 -1
- package/dist/commands/handoff/index.js +0 -97
- package/dist/commands/handoff/utils.d.ts +0 -4
- package/dist/commands/handoff/utils.d.ts.map +0 -1
- package/dist/commands/handoff/utils.js +0 -123
- package/dist/commands/list-directories/index.d.ts +0 -3
- package/dist/commands/list-directories/index.d.ts.map +0 -1
- package/dist/commands/list-directories/index.js +0 -35
- package/dist/commands/pickup/index.d.ts +0 -3
- package/dist/commands/pickup/index.d.ts.map +0 -1
- package/dist/commands/pickup/index.js +0 -141
- package/dist/commands/pickup/types.d.ts +0 -6
- package/dist/commands/pickup/types.d.ts.map +0 -1
- package/dist/commands/pickup/types.js +0 -1
- package/dist/commands/pickup/utils.d.ts +0 -7
- package/dist/commands/pickup/utils.d.ts.map +0 -1
- package/dist/commands/pickup/utils.js +0 -56
- package/dist/commands/remove-directory/index.d.ts +0 -3
- package/dist/commands/remove-directory/index.d.ts.map +0 -1
- package/dist/commands/remove-directory/index.js +0 -55
- package/dist/commands/review/index.d.ts +0 -3
- package/dist/commands/review/index.d.ts.map +0 -1
- package/dist/commands/review/index.js +0 -12
- package/dist/commands/review/review-panel.d.ts +0 -3
- package/dist/commands/review/review-panel.d.ts.map +0 -1
- package/dist/commands/review/review-panel.js +0 -186
- package/dist/commands/review/utils.d.ts +0 -18
- package/dist/commands/review/utils.d.ts.map +0 -1
- package/dist/commands/review/utils.js +0 -146
- package/dist/commands/shell/index.d.ts +0 -3
- package/dist/commands/shell/index.d.ts.map +0 -1
- package/dist/commands/shell/index.js +0 -96
- package/dist/subagents/index.d.ts +0 -16
- package/dist/subagents/index.d.ts.map +0 -1
- package/dist/subagents/index.js +0 -231
- package/dist/terminal/index.d.ts +0 -9
- package/dist/terminal/index.d.ts.map +0 -1
- package/dist/terminal/index.js +0 -8
- package/dist/tools/agent.d.ts +0 -27
- package/dist/tools/agent.d.ts.map +0 -1
- package/dist/tools/agent.js +0 -81
- package/dist/tools/directory-tree.d.ts +0 -28
- package/dist/tools/directory-tree.d.ts.map +0 -1
- package/dist/tools/directory-tree.js +0 -154
- package/dist/tools/glob.d.ts +0 -35
- package/dist/tools/glob.d.ts.map +0 -1
- package/dist/tools/glob.js +0 -167
- package/dist/tools/grep.d.ts +0 -100
- package/dist/tools/grep.d.ts.map +0 -1
- package/dist/tools/grep.js +0 -608
- package/dist/tools/ls.d.ts +0 -26
- package/dist/tools/ls.d.ts.map +0 -1
- package/dist/tools/ls.js +0 -83
- package/dist/tui/components/header.d.ts +0 -21
- package/dist/tui/components/header.d.ts.map +0 -1
- package/dist/tui/components/header.js +0 -63
- package/dist/utils/bash/parse.d.ts +0 -19
- package/dist/utils/bash/parse.d.ts.map +0 -1
- package/dist/utils/bash/parse.js +0 -223
- package/dist/utils/bash/quote.d.ts +0 -6
- package/dist/utils/bash/quote.d.ts.map +0 -1
- package/dist/utils/bash/quote.js +0 -23
- package/dist/utils/generators.d.ts +0 -3
- package/dist/utils/generators.d.ts.map +0 -1
- package/dist/utils/generators.js +0 -25
- package/dist/utils/glob.d.ts +0 -52
- package/dist/utils/glob.d.ts.map +0 -1
- package/dist/utils/glob.js +0 -376
|
@@ -157,174 +157,206 @@ export class Markdown {
|
|
|
157
157
|
renderToken(token, width, nextTokenType) {
|
|
158
158
|
const lines = [];
|
|
159
159
|
switch (token.type) {
|
|
160
|
-
case "heading":
|
|
161
|
-
|
|
162
|
-
const headingPrefix = `${"#".repeat(headingLevel)} `;
|
|
163
|
-
const headingText = this.renderInlineTokens(token.tokens || []);
|
|
164
|
-
if (headingLevel === 1) {
|
|
165
|
-
lines.push(style.underline(this.theme.heading(headingText)));
|
|
166
|
-
}
|
|
167
|
-
else if (headingLevel === 2) {
|
|
168
|
-
lines.push(this.theme.heading(headingText));
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
lines.push(this.theme.heading(headingPrefix + headingText));
|
|
172
|
-
}
|
|
173
|
-
lines.push(""); // Add spacing after headings
|
|
160
|
+
case "heading":
|
|
161
|
+
this.renderHeadingToken(token, lines);
|
|
174
162
|
break;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const paragraphText = this.renderInlineTokens(token.tokens || []);
|
|
178
|
-
lines.push(this.theme.paragraph(paragraphText));
|
|
179
|
-
// Don't add spacing if next token is space or list
|
|
180
|
-
if (nextTokenType &&
|
|
181
|
-
nextTokenType !== "list" &&
|
|
182
|
-
nextTokenType !== "space") {
|
|
183
|
-
lines.push("");
|
|
184
|
-
}
|
|
163
|
+
case "paragraph":
|
|
164
|
+
this.renderParagraphToken(token, lines, nextTokenType);
|
|
185
165
|
break;
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if (token.lang && supportsLanguage(token.lang)) {
|
|
189
|
-
// Use syntax highlighting for supported languages
|
|
190
|
-
const highlightedCode = highlight(token.text, {
|
|
191
|
-
language: token.lang,
|
|
192
|
-
theme: this.highlightTheme,
|
|
193
|
-
});
|
|
194
|
-
const codeLines = highlightedCode.split("\n");
|
|
195
|
-
lines.push(this.theme.codeBlockBorder(`\`\`\`${token.lang}`));
|
|
196
|
-
for (const codeLine of codeLines) {
|
|
197
|
-
lines.push(style.dim(" ") + codeLine);
|
|
198
|
-
}
|
|
199
|
-
lines.push(this.theme.codeBlockBorder("```"));
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
// Fallback to basic styling for unsupported languages
|
|
203
|
-
lines.push(this.theme.codeBlockBorder(`\`\`\`${token.lang || ""}`));
|
|
204
|
-
const codeLines = token.text.split("\n");
|
|
205
|
-
for (const codeLine of codeLines) {
|
|
206
|
-
lines.push(style.dim(" ") + this.theme.codeBlock(codeLine));
|
|
207
|
-
}
|
|
208
|
-
lines.push(this.theme.codeBlockBorder("```"));
|
|
209
|
-
}
|
|
210
|
-
lines.push(""); // Add spacing after code blocks
|
|
166
|
+
case "code":
|
|
167
|
+
this.renderCodeBlockToken(token, lines);
|
|
211
168
|
break;
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
const listLines = this.renderList(token, 0);
|
|
215
|
-
lines.push(...listLines);
|
|
216
|
-
// Don't add spacing after lists if a space token follows
|
|
217
|
-
// (the space token will handle it)
|
|
169
|
+
case "list":
|
|
170
|
+
this.renderBlockListToken(token, lines);
|
|
218
171
|
break;
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const tableLines = this.renderTable(token);
|
|
222
|
-
lines.push(...tableLines);
|
|
172
|
+
case "table":
|
|
173
|
+
this.renderBlockTableToken(token, lines);
|
|
223
174
|
break;
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
const quoteText = this.renderInlineTokens(token.tokens || []);
|
|
227
|
-
const quoteLines = quoteText.split("\n");
|
|
228
|
-
for (const quoteLine of quoteLines) {
|
|
229
|
-
lines.push(this.theme.quoteBorder("│ ") + this.theme.quote(quoteLine));
|
|
230
|
-
}
|
|
231
|
-
lines.push(""); // Add spacing after blockquotes
|
|
175
|
+
case "blockquote":
|
|
176
|
+
this.renderBlockquoteToken(token, lines);
|
|
232
177
|
break;
|
|
233
|
-
}
|
|
234
178
|
case "hr":
|
|
235
|
-
|
|
236
|
-
lines.push(""); // Add spacing after horizontal rules
|
|
179
|
+
this.renderHrToken(width, lines);
|
|
237
180
|
break;
|
|
238
|
-
case "image":
|
|
239
|
-
|
|
240
|
-
if (alt.length > 0) {
|
|
241
|
-
lines.push(`[Image: ${alt} (${token.href})]`);
|
|
242
|
-
}
|
|
243
|
-
else {
|
|
244
|
-
lines.push(`[Image: ${token.href}]`);
|
|
245
|
-
}
|
|
181
|
+
case "image":
|
|
182
|
+
this.renderImageBlockToken(token, lines);
|
|
246
183
|
break;
|
|
247
|
-
}
|
|
248
184
|
case "html":
|
|
249
|
-
|
|
250
|
-
lines.push(style.dim(token.text));
|
|
185
|
+
this.renderHtmlToken(token, lines);
|
|
251
186
|
break;
|
|
252
187
|
case "space":
|
|
253
|
-
|
|
254
|
-
lines.push("");
|
|
188
|
+
this.renderSpaceToken(lines);
|
|
255
189
|
break;
|
|
256
190
|
default:
|
|
257
|
-
|
|
258
|
-
if ("text" in token && typeof token.text === "string") {
|
|
259
|
-
lines.push(token.text);
|
|
260
|
-
}
|
|
191
|
+
this.renderDefaultBlockToken(token, lines);
|
|
261
192
|
}
|
|
262
193
|
return lines;
|
|
263
194
|
}
|
|
195
|
+
renderHeadingToken(token, lines) {
|
|
196
|
+
const t = token;
|
|
197
|
+
const headingLevel = t.depth;
|
|
198
|
+
const headingPrefix = "".concat("#".repeat(headingLevel), " ");
|
|
199
|
+
const headingText = this.renderInlineTokens(t.tokens || []);
|
|
200
|
+
if (headingLevel === 1) {
|
|
201
|
+
lines.push(style.underline(this.theme.heading(headingText)));
|
|
202
|
+
}
|
|
203
|
+
else if (headingLevel === 2) {
|
|
204
|
+
lines.push(this.theme.heading(headingText));
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
lines.push(this.theme.heading(headingPrefix + headingText));
|
|
208
|
+
}
|
|
209
|
+
lines.push(""); // Add spacing after headings
|
|
210
|
+
}
|
|
211
|
+
renderParagraphToken(token, lines, nextTokenType) {
|
|
212
|
+
const t = token;
|
|
213
|
+
const paragraphText = this.renderInlineTokens(t.tokens || []);
|
|
214
|
+
lines.push(this.theme.paragraph(paragraphText));
|
|
215
|
+
// Don't add spacing if next token is space or list
|
|
216
|
+
if (nextTokenType &&
|
|
217
|
+
nextTokenType !== "list" &&
|
|
218
|
+
nextTokenType !== "space") {
|
|
219
|
+
lines.push("");
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
renderCodeBlockToken(token, lines) {
|
|
223
|
+
const t = token;
|
|
224
|
+
if (t.lang && supportsLanguage(t.lang)) {
|
|
225
|
+
// Use syntax highlighting for supported languages
|
|
226
|
+
const highlightedCode = highlight(t.text, {
|
|
227
|
+
language: t.lang,
|
|
228
|
+
theme: this.highlightTheme,
|
|
229
|
+
});
|
|
230
|
+
const codeLines = highlightedCode.split("\n");
|
|
231
|
+
lines.push(this.theme.codeBlockBorder("".concat("```", t.lang)));
|
|
232
|
+
for (const codeLine of codeLines) {
|
|
233
|
+
lines.push(style.dim(" ") + codeLine);
|
|
234
|
+
}
|
|
235
|
+
lines.push(this.theme.codeBlockBorder("```"));
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
// Fallback to basic styling for unsupported languages
|
|
239
|
+
lines.push(this.theme.codeBlockBorder("".concat("```", t.lang || "")));
|
|
240
|
+
const codeLines = t.text.split("\n");
|
|
241
|
+
for (const codeLine of codeLines) {
|
|
242
|
+
lines.push(style.dim(" ") + this.theme.codeBlock(codeLine));
|
|
243
|
+
}
|
|
244
|
+
lines.push(this.theme.codeBlockBorder("```"));
|
|
245
|
+
}
|
|
246
|
+
lines.push(""); // Add spacing after code blocks
|
|
247
|
+
}
|
|
248
|
+
renderBlockListToken(token, lines) {
|
|
249
|
+
const listLines = this.renderList(token, 0);
|
|
250
|
+
lines.push(...listLines);
|
|
251
|
+
}
|
|
252
|
+
renderBlockTableToken(token, lines) {
|
|
253
|
+
const tableLines = this.renderTable(token);
|
|
254
|
+
lines.push(...tableLines);
|
|
255
|
+
}
|
|
256
|
+
renderBlockquoteToken(token, lines) {
|
|
257
|
+
const t = token;
|
|
258
|
+
const quoteText = this.renderInlineTokens(t.tokens || []);
|
|
259
|
+
const quoteLines = quoteText.split("\n");
|
|
260
|
+
for (const quoteLine of quoteLines) {
|
|
261
|
+
lines.push(this.theme.quoteBorder("│ ") + this.theme.quote(quoteLine));
|
|
262
|
+
}
|
|
263
|
+
lines.push(""); // Add spacing after blockquotes
|
|
264
|
+
}
|
|
265
|
+
renderHrToken(width, lines) {
|
|
266
|
+
lines.push(this.theme.hr("─".repeat(Math.min(width, 80))));
|
|
267
|
+
lines.push(""); // Add spacing after horizontal rules
|
|
268
|
+
}
|
|
269
|
+
renderImageBlockToken(token, lines) {
|
|
270
|
+
const t = token;
|
|
271
|
+
const alt = (t.title ?? t.text ?? "").toString().trim();
|
|
272
|
+
if (alt.length > 0) {
|
|
273
|
+
lines.push("[Image: ".concat(alt, " (", t.href, ")]"));
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
lines.push("[Image: ".concat(t.href, "]"));
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
renderHtmlToken(token, lines) {
|
|
280
|
+
const t = token;
|
|
281
|
+
// Render HTML tags with dim styling and content as normal text
|
|
282
|
+
lines.push(style.dim(t.text));
|
|
283
|
+
}
|
|
284
|
+
renderSpaceToken(lines) {
|
|
285
|
+
// Space tokens represent blank lines in markdown
|
|
286
|
+
lines.push("");
|
|
287
|
+
}
|
|
288
|
+
renderDefaultBlockToken(token, lines) {
|
|
289
|
+
const t = token;
|
|
290
|
+
// Handle any other token types as plain text
|
|
291
|
+
if ("text" in t && typeof t.text === "string") {
|
|
292
|
+
lines.push(t.text);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
264
295
|
renderInlineTokens(tokens) {
|
|
265
296
|
let result = "";
|
|
266
297
|
for (const token of tokens) {
|
|
267
|
-
|
|
268
|
-
case "text":
|
|
269
|
-
// Text tokens in list items can have nested tokens for inline formatting
|
|
270
|
-
if (token.tokens && token.tokens.length > 0) {
|
|
271
|
-
result += this.renderInlineTokens(token.tokens);
|
|
272
|
-
}
|
|
273
|
-
else {
|
|
274
|
-
result += token.text;
|
|
275
|
-
}
|
|
276
|
-
break;
|
|
277
|
-
case "strong":
|
|
278
|
-
result += this.theme.bold(this.renderInlineTokens(token.tokens || []));
|
|
279
|
-
break;
|
|
280
|
-
case "em":
|
|
281
|
-
result += this.theme.italic(this.renderInlineTokens(token.tokens || []));
|
|
282
|
-
break;
|
|
283
|
-
case "codespan":
|
|
284
|
-
result +=
|
|
285
|
-
this.theme.codeBlockBorder("`") +
|
|
286
|
-
this.theme.code(token.text) +
|
|
287
|
-
this.theme.codeBlockBorder("`");
|
|
288
|
-
break;
|
|
289
|
-
case "link": {
|
|
290
|
-
const linkText = this.renderInlineTokens(token.tokens || []);
|
|
291
|
-
const terminalLinkText = terminalLink(linkText, token.href);
|
|
292
|
-
// If link text matches href, only show the link once
|
|
293
|
-
if (linkText === token.href) {
|
|
294
|
-
result += this.theme.link(terminalLinkText ?? linkText);
|
|
295
|
-
}
|
|
296
|
-
else {
|
|
297
|
-
result +=
|
|
298
|
-
this.theme.link(terminalLinkText ?? linkText) +
|
|
299
|
-
this.theme.linkUrl(` (${token.href})`);
|
|
300
|
-
}
|
|
301
|
-
break;
|
|
302
|
-
}
|
|
303
|
-
case "br":
|
|
304
|
-
result += "\n";
|
|
305
|
-
break;
|
|
306
|
-
case "del":
|
|
307
|
-
result += this.theme.strikethrough(this.renderInlineTokens(token.tokens || []));
|
|
308
|
-
break;
|
|
309
|
-
case "image": {
|
|
310
|
-
const alt = (token.title ?? token.text ?? "").toString().trim();
|
|
311
|
-
if (alt.length > 0) {
|
|
312
|
-
result += `[Image: ${alt} (${token.href})]`;
|
|
313
|
-
}
|
|
314
|
-
else {
|
|
315
|
-
result += `[Image: ${token.href}]`;
|
|
316
|
-
}
|
|
317
|
-
break;
|
|
318
|
-
}
|
|
319
|
-
default:
|
|
320
|
-
// Handle any other inline token types as plain text
|
|
321
|
-
if ("text" in token && typeof token.text === "string") {
|
|
322
|
-
result += token.text;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
298
|
+
result += this.renderInlineToken(token);
|
|
325
299
|
}
|
|
326
300
|
return result;
|
|
327
301
|
}
|
|
302
|
+
renderInlineToken(token) {
|
|
303
|
+
switch (token.type) {
|
|
304
|
+
case "text":
|
|
305
|
+
return this.renderTextToken(token);
|
|
306
|
+
case "strong":
|
|
307
|
+
return this.theme.bold(this.renderInlineTokens(token.tokens || []));
|
|
308
|
+
case "em":
|
|
309
|
+
return this.theme.italic(this.renderInlineTokens(token.tokens || []));
|
|
310
|
+
case "codespan":
|
|
311
|
+
return (this.theme.codeBlockBorder("`") +
|
|
312
|
+
this.theme.code(token.text) +
|
|
313
|
+
this.theme.codeBlockBorder("`"));
|
|
314
|
+
case "link":
|
|
315
|
+
return this.renderLinkToken(token);
|
|
316
|
+
case "br":
|
|
317
|
+
return "\n";
|
|
318
|
+
case "del":
|
|
319
|
+
return this.theme.strikethrough(this.renderInlineTokens(token.tokens || []));
|
|
320
|
+
case "image":
|
|
321
|
+
return this.renderImageToken(token);
|
|
322
|
+
default:
|
|
323
|
+
return this.renderDefaultToken(token);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
renderTextToken(token) {
|
|
327
|
+
const t = token;
|
|
328
|
+
// Text tokens in list items can have nested tokens for inline formatting
|
|
329
|
+
if (t.tokens && t.tokens.length > 0) {
|
|
330
|
+
return this.renderInlineTokens(t.tokens);
|
|
331
|
+
}
|
|
332
|
+
return t.text;
|
|
333
|
+
}
|
|
334
|
+
renderLinkToken(token) {
|
|
335
|
+
const t = token;
|
|
336
|
+
const linkText = this.renderInlineTokens(t.tokens || []);
|
|
337
|
+
const terminalLinkText = terminalLink(linkText, t.href);
|
|
338
|
+
// If link text matches href, only show the link once
|
|
339
|
+
if (linkText === t.href) {
|
|
340
|
+
return this.theme.link(terminalLinkText ?? linkText);
|
|
341
|
+
}
|
|
342
|
+
return (this.theme.link(terminalLinkText ?? linkText) +
|
|
343
|
+
this.theme.linkUrl(` (${t.href})`));
|
|
344
|
+
}
|
|
345
|
+
renderImageToken(token) {
|
|
346
|
+
const t = token;
|
|
347
|
+
const alt = (t.title ?? t.text ?? "").toString().trim();
|
|
348
|
+
if (alt.length > 0) {
|
|
349
|
+
return `[Image: ${alt} (${t.href})]`;
|
|
350
|
+
}
|
|
351
|
+
return `[Image: ${t.href}]`;
|
|
352
|
+
}
|
|
353
|
+
renderDefaultToken(token) {
|
|
354
|
+
// Handle any other inline token types as plain text
|
|
355
|
+
if ("text" in token && typeof token.text === "string") {
|
|
356
|
+
return token.text;
|
|
357
|
+
}
|
|
358
|
+
return "";
|
|
359
|
+
}
|
|
328
360
|
wrapLine(line, contentWidth) {
|
|
329
361
|
if (!line) {
|
|
330
362
|
return [""];
|
|
@@ -340,50 +372,41 @@ export class Markdown {
|
|
|
340
372
|
* This accounts for ANSI escape codes that are inserted between characters
|
|
341
373
|
*/
|
|
342
374
|
cleanToStyledIndex(cleanText, styledText, cleanIndex) {
|
|
343
|
-
let cleanPos = 0;
|
|
344
|
-
let styledPos = 0;
|
|
345
|
-
const escapeChar = String.fromCharCode(27);
|
|
346
|
-
// Handle edge case: if cleanIndex is 0, return 0
|
|
347
375
|
if (cleanIndex === 0) {
|
|
348
376
|
return 0;
|
|
349
377
|
}
|
|
378
|
+
const escapeChar = String.fromCharCode(27);
|
|
379
|
+
let cleanPos = 0;
|
|
380
|
+
let styledPos = 0;
|
|
350
381
|
while (styledPos < styledText.length) {
|
|
351
|
-
// If we've found all the clean characters we need, skip any escape
|
|
352
|
-
// sequences at the current position and return after them
|
|
353
382
|
if (cleanPos >= cleanIndex) {
|
|
354
|
-
|
|
355
|
-
while (styledPos < styledText.length &&
|
|
356
|
-
styledText[styledPos] === escapeChar) {
|
|
357
|
-
while (styledPos < styledText.length &&
|
|
358
|
-
styledText[styledPos] !== "m") {
|
|
359
|
-
styledPos++;
|
|
360
|
-
}
|
|
361
|
-
styledPos++; // skip 'm'
|
|
362
|
-
}
|
|
363
|
-
return styledPos;
|
|
364
|
-
}
|
|
365
|
-
const char = cleanText[cleanPos];
|
|
366
|
-
if (styledText[styledPos] === escapeChar) {
|
|
367
|
-
// Skip the entire ANSI escape sequence
|
|
368
|
-
while (styledPos < styledText.length && styledText[styledPos] !== "m") {
|
|
369
|
-
styledPos++;
|
|
370
|
-
}
|
|
371
|
-
styledPos++;
|
|
372
|
-
// Don't increment cleanPos - ANSI codes don't correspond to clean text characters
|
|
383
|
+
return this.skipAnsiAtPosition(styledText, styledPos, escapeChar);
|
|
373
384
|
}
|
|
374
|
-
|
|
375
|
-
|
|
385
|
+
styledPos = this.skipAnsiAtPosition(styledText, styledPos, escapeChar);
|
|
386
|
+
if (styledPos >= styledText.length)
|
|
387
|
+
break;
|
|
388
|
+
if (styledText[styledPos] === cleanText[cleanPos]) {
|
|
376
389
|
cleanPos++;
|
|
377
|
-
styledPos++;
|
|
378
|
-
}
|
|
379
|
-
else {
|
|
380
|
-
// Characters don't match - this shouldn't happen if cleanText is derived from styledText
|
|
381
|
-
// But to be safe, just advance styledPos
|
|
382
|
-
styledPos++;
|
|
383
390
|
}
|
|
391
|
+
styledPos++;
|
|
384
392
|
}
|
|
385
393
|
return styledPos;
|
|
386
394
|
}
|
|
395
|
+
/**
|
|
396
|
+
* Skip any ANSI escape sequences at the given position in styled text
|
|
397
|
+
* and return the position after the last complete escape sequence.
|
|
398
|
+
*/
|
|
399
|
+
skipAnsiAtPosition(styledText, position, escapeChar) {
|
|
400
|
+
let pos = position;
|
|
401
|
+
while (pos < styledText.length && styledText[pos] === escapeChar) {
|
|
402
|
+
pos++;
|
|
403
|
+
while (pos < styledText.length && styledText[pos] !== "m") {
|
|
404
|
+
pos++;
|
|
405
|
+
}
|
|
406
|
+
pos++; // skip 'm'
|
|
407
|
+
}
|
|
408
|
+
return pos;
|
|
409
|
+
}
|
|
387
410
|
/**
|
|
388
411
|
* Create a placeholder string whose visible width matches the target width.
|
|
389
412
|
* Returns null if the code span is too short to protect reliably.
|
|
@@ -403,6 +426,17 @@ export class Markdown {
|
|
|
403
426
|
}
|
|
404
427
|
return null;
|
|
405
428
|
}
|
|
429
|
+
/**
|
|
430
|
+
* Find the closing backtick for an inline code span starting at the given index.
|
|
431
|
+
*/
|
|
432
|
+
findClosingBacktick(cleanText, startIndex) {
|
|
433
|
+
for (let j = startIndex; j < cleanText.length; j++) {
|
|
434
|
+
if (cleanText[j] === "`") {
|
|
435
|
+
return j;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
return -1;
|
|
439
|
+
}
|
|
406
440
|
/**
|
|
407
441
|
* Protect inline code spans by replacing them with width-matched placeholders.
|
|
408
442
|
* This prevents wrapAnsi from breaking code spans across lines while
|
|
@@ -419,17 +453,7 @@ export class Markdown {
|
|
|
419
453
|
const backtickIndex = cleanText.indexOf("`", i);
|
|
420
454
|
if (backtickIndex === -1)
|
|
421
455
|
break;
|
|
422
|
-
|
|
423
|
-
let depth = 1;
|
|
424
|
-
for (let j = backtickIndex + 1; j < cleanText.length; j++) {
|
|
425
|
-
if (cleanText[j] === "`") {
|
|
426
|
-
depth--;
|
|
427
|
-
if (depth === 0) {
|
|
428
|
-
closingIndex = j;
|
|
429
|
-
break;
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
}
|
|
456
|
+
const closingIndex = this.findClosingBacktick(cleanText, backtickIndex + 1);
|
|
433
457
|
if (closingIndex !== -1) {
|
|
434
458
|
const styledStart = this.cleanToStyledIndex(cleanText, text, backtickIndex);
|
|
435
459
|
const styledEnd = this.cleanToStyledIndex(cleanText, text, closingIndex + 1);
|
|
@@ -502,74 +526,82 @@ export class Markdown {
|
|
|
502
526
|
: "- ";
|
|
503
527
|
// Process item tokens to handle nested lists
|
|
504
528
|
const itemLines = this.renderListItem(item.tokens || [], depth);
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
529
|
+
this.appendItemLines(lines, itemLines, indent, bullet);
|
|
530
|
+
}
|
|
531
|
+
return lines;
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Append list item lines to the output, handling nested lists
|
|
535
|
+
*/
|
|
536
|
+
appendItemLines(lines, itemLines, indent, bullet) {
|
|
537
|
+
if (itemLines.length > 0) {
|
|
538
|
+
// First line - check if it's a nested list
|
|
539
|
+
const firstLine = itemLines[0];
|
|
540
|
+
const isNestedList = this.isNestedListLine(firstLine, indent.length / 2);
|
|
541
|
+
if (isNestedList) {
|
|
542
|
+
// This is a nested list, just add it as-is (already has full indent)
|
|
543
|
+
lines.push(firstLine);
|
|
544
|
+
}
|
|
545
|
+
else {
|
|
546
|
+
// Regular text content - add indent and bullet
|
|
547
|
+
lines.push(indent + this.theme.listBullet(bullet) + firstLine);
|
|
548
|
+
}
|
|
549
|
+
// Rest of the lines
|
|
550
|
+
for (let j = 1; j < itemLines.length; j++) {
|
|
551
|
+
const line = itemLines[j];
|
|
552
|
+
const isNestedListLine = line.includes("\x1b[36m"); // cyan bullet color
|
|
553
|
+
if (isNestedListLine) {
|
|
554
|
+
// Nested list line - already has full indent
|
|
555
|
+
lines.push(line);
|
|
512
556
|
}
|
|
513
557
|
else {
|
|
514
|
-
// Regular
|
|
515
|
-
lines.push(indent
|
|
516
|
-
}
|
|
517
|
-
// Rest of the lines
|
|
518
|
-
for (let j = 1; j < itemLines.length; j++) {
|
|
519
|
-
const line = itemLines[j];
|
|
520
|
-
const isNestedListLine = line.includes("\x1b[36m"); // cyan bullet color
|
|
521
|
-
if (isNestedListLine) {
|
|
522
|
-
// Nested list line - already has full indent
|
|
523
|
-
lines.push(line);
|
|
524
|
-
}
|
|
525
|
-
else {
|
|
526
|
-
// Regular content - add parent indent + 2 spaces for continuation
|
|
527
|
-
lines.push(`${indent} ${line}`);
|
|
528
|
-
}
|
|
558
|
+
// Regular content - add parent indent + 2 spaces for continuation
|
|
559
|
+
lines.push(`${indent} ${line}`);
|
|
529
560
|
}
|
|
530
561
|
}
|
|
531
|
-
else {
|
|
532
|
-
lines.push(indent + this.theme.listBullet(bullet));
|
|
533
|
-
}
|
|
534
562
|
}
|
|
535
|
-
|
|
563
|
+
else {
|
|
564
|
+
lines.push(indent + this.theme.listBullet(bullet));
|
|
565
|
+
}
|
|
536
566
|
}
|
|
537
567
|
/**
|
|
538
568
|
* Render list item tokens, handling nested lists
|
|
539
569
|
* Returns lines WITHOUT the parent indent (renderList will add it)
|
|
540
570
|
*/
|
|
571
|
+
// Token handler map for renderListItem dispatch
|
|
572
|
+
listTokenHandlers = {
|
|
573
|
+
list: (token, parentDepth) => this.renderList(token, parentDepth + 1),
|
|
574
|
+
text: (token) => {
|
|
575
|
+
const t = token;
|
|
576
|
+
return t.tokens && t.tokens.length > 0
|
|
577
|
+
? [this.renderInlineTokens(t.tokens)]
|
|
578
|
+
: [t.text || ""];
|
|
579
|
+
},
|
|
580
|
+
paragraph: (token) => [
|
|
581
|
+
this.renderInlineTokens(token.tokens || []),
|
|
582
|
+
],
|
|
583
|
+
code: (token) => {
|
|
584
|
+
const t = token;
|
|
585
|
+
const lines = [
|
|
586
|
+
this.theme.codeBlockBorder(`\`\`\`${t.lang || ""}`),
|
|
587
|
+
];
|
|
588
|
+
const codeLines = (t.text || "").split("\n");
|
|
589
|
+
for (const codeLine of codeLines) {
|
|
590
|
+
lines.push(style.dim(" ") + this.theme.codeBlock(codeLine));
|
|
591
|
+
}
|
|
592
|
+
lines.push(this.theme.codeBlockBorder("```"));
|
|
593
|
+
return lines;
|
|
594
|
+
},
|
|
595
|
+
};
|
|
541
596
|
renderListItem(tokens, parentDepth) {
|
|
542
597
|
const lines = [];
|
|
543
598
|
for (const token of tokens) {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
const nestedLines = this.renderList(token, parentDepth + 1);
|
|
548
|
-
lines.push(...nestedLines);
|
|
549
|
-
}
|
|
550
|
-
else if (token.type === "text") {
|
|
551
|
-
// Text content (may have inline tokens)
|
|
552
|
-
const text = token.tokens && token.tokens.length > 0
|
|
553
|
-
? this.renderInlineTokens(token.tokens)
|
|
554
|
-
: token.text || "";
|
|
555
|
-
lines.push(text);
|
|
556
|
-
}
|
|
557
|
-
else if (token.type === "paragraph") {
|
|
558
|
-
// Paragraph in list item
|
|
559
|
-
const text = this.renderInlineTokens(token.tokens || []);
|
|
560
|
-
lines.push(text);
|
|
561
|
-
}
|
|
562
|
-
else if (token.type === "code") {
|
|
563
|
-
// Code block in list item
|
|
564
|
-
lines.push(this.theme.codeBlockBorder(`\`\`\`${token.lang || ""}`));
|
|
565
|
-
const codeLines = token.text.split("\n");
|
|
566
|
-
for (const codeLine of codeLines) {
|
|
567
|
-
lines.push(style.dim(" ") + this.theme.codeBlock(codeLine));
|
|
568
|
-
}
|
|
569
|
-
lines.push(this.theme.codeBlockBorder("```"));
|
|
599
|
+
const handler = this.listTokenHandlers[token.type];
|
|
600
|
+
if (handler) {
|
|
601
|
+
lines.push(...handler(token, parentDepth));
|
|
570
602
|
}
|
|
571
603
|
else {
|
|
572
|
-
//
|
|
604
|
+
// Unknown token types - try to render as inline
|
|
573
605
|
const text = this.renderInlineTokens([token]);
|
|
574
606
|
if (text) {
|
|
575
607
|
lines.push(text);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../source/tui/components/modal.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC;;GAEG;AACH,qBAAa,KAAM,SAAQ,SAAU,YAAW,SAAS;IACvD,OAAO,CAAC,KAAK,CAAS;IACf,QAAQ,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,OAAO,CAAC,CAAa;IAC7B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,cAAc,CAAK;gBAGzB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,SAAS,EAClB,QAAQ,UAAO,EACf,OAAO,CAAC,EAAE,MAAM,IAAI,EACpB,QAAQ,CAAC,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM;IAYpB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAgD/B,KAAK,IAAI,IAAI;IAMJ,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAqHxC,iBAAiB,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;CA2B7C;
|
|
1
|
+
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../source/tui/components/modal.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC;;GAEG;AACH,qBAAa,KAAM,SAAQ,SAAU,YAAW,SAAS;IACvD,OAAO,CAAC,KAAK,CAAS;IACf,QAAQ,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,OAAO,CAAC,CAAa;IAC7B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,cAAc,CAAK;gBAGzB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,SAAS,EAClB,QAAQ,UAAO,EACf,OAAO,CAAC,EAAE,MAAM,IAAI,EACpB,QAAQ,CAAC,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM;IAYpB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAgD/B,KAAK,IAAI,IAAI;IAMJ,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAqHxC,iBAAiB,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;CA2B7C;AA0CD;;GAEG;AACH,qBAAa,SAAU,SAAQ,SAAS;IACtC,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAS;gBAEb,IAAI,EAAE,MAAM,EAAE,QAAQ,SAAI,EAAE,QAAQ,SAAI;IAO3C,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;CA8CzC"}
|
|
@@ -178,6 +178,16 @@ export class Modal extends Container {
|
|
|
178
178
|
return null;
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
+
function truncateWord(word, maxWidth) {
|
|
182
|
+
let truncated = "";
|
|
183
|
+
for (const char of word) {
|
|
184
|
+
if (visibleWidth(truncated + char) > maxWidth) {
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
truncated += char;
|
|
188
|
+
}
|
|
189
|
+
return truncated;
|
|
190
|
+
}
|
|
181
191
|
function wrapLine(line, contentWidth) {
|
|
182
192
|
const words = line.split(" ");
|
|
183
193
|
const lines = [];
|
|
@@ -185,17 +195,7 @@ function wrapLine(line, contentWidth) {
|
|
|
185
195
|
for (const word of words) {
|
|
186
196
|
const currentVisible = visibleWidth(currentLine);
|
|
187
197
|
const wordVisible = visibleWidth(word);
|
|
188
|
-
|
|
189
|
-
if (wordVisible > contentWidth) {
|
|
190
|
-
let truncated = "";
|
|
191
|
-
for (const char of word) {
|
|
192
|
-
if (visibleWidth(truncated + char) > contentWidth) {
|
|
193
|
-
break;
|
|
194
|
-
}
|
|
195
|
-
truncated += char;
|
|
196
|
-
}
|
|
197
|
-
finalWord = truncated;
|
|
198
|
-
}
|
|
198
|
+
const finalWord = wordVisible > contentWidth ? truncateWord(word, contentWidth) : word;
|
|
199
199
|
if (currentVisible === 0) {
|
|
200
200
|
currentLine = finalWord;
|
|
201
201
|
}
|
|
@@ -26,8 +26,13 @@ export declare class SelectList implements Component {
|
|
|
26
26
|
setFilter(filter: string): void;
|
|
27
27
|
setSelectedIndex(index: number): void;
|
|
28
28
|
render(width: number): string[];
|
|
29
|
+
private formatItemLine;
|
|
29
30
|
wantsNavigationKeys(): boolean;
|
|
30
31
|
handleInput(keyData: string): void;
|
|
32
|
+
private moveSelectionUp;
|
|
33
|
+
private moveSelectionDown;
|
|
34
|
+
private selectCurrentItem;
|
|
35
|
+
private cancelSelection;
|
|
31
36
|
private notifySelectionChange;
|
|
32
37
|
getSelectedItem(): SelectItem | null;
|
|
33
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-list.d.ts","sourceRoot":"","sources":["../../../source/tui/components/select-list.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAG3C,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACzC,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACvC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACtC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACrC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CACnC;AAED,qBAAa,UAAW,YAAW,SAAS;IAC1C,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,aAAa,CAAoB;IACzC,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,KAAK,CAAkB;IAExB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;gBAE1C,KAAK,EAAE,UAAU,EAAE,EAAE,UAAU,SAAI,EAAE,KAAK,CAAC,EAAE,eAAe;IAOxE,OAAO,CAAC,kBAAkB;IAU1B,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE;IAQ/B,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAQ/B,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAOrC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;
|
|
1
|
+
{"version":3,"file":"select-list.d.ts","sourceRoot":"","sources":["../../../source/tui/components/select-list.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAG3C,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACzC,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACvC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACtC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACrC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CACnC;AAED,qBAAa,UAAW,YAAW,SAAS;IAC1C,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,aAAa,CAAoB;IACzC,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,KAAK,CAAkB;IAExB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;gBAE1C,KAAK,EAAE,UAAU,EAAE,EAAE,UAAU,SAAI,EAAE,KAAK,CAAC,EAAE,eAAe;IAOxE,OAAO,CAAC,kBAAkB;IAU1B,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE;IAQ/B,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAQ/B,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAOrC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IA0C/B,OAAO,CAAC,cAAc;IA6CtB,mBAAmB,IAAI,OAAO;IAI9B,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IA0BlC,OAAO,CAAC,eAAe;IAQvB,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,qBAAqB;IAO7B,eAAe,IAAI,UAAU,GAAG,IAAI;CAIrC"}
|