@xynogen/pix-pretty 3.0.2 → 3.2.0
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/package.json +3 -2
- package/src/ansi.ts +29 -0
- package/src/markdown-transform.ts +23 -0
- package/src/modal-frame.ts +4 -15
- package/src/provider-picker.ts +157 -17
- package/src/tui.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xynogen/pix-pretty",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Enhanced tool output rendering with syntax highlighting, file icons, tree views, diff rendering, and FFF search",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"./diff-render": "./src/diff-render.ts",
|
|
18
18
|
"./highlight": "./src/highlight.ts",
|
|
19
19
|
"./lang": "./src/lang.ts",
|
|
20
|
+
"./markdown-transform": "./src/markdown-transform.ts",
|
|
20
21
|
"./icons": "./src/icons.ts",
|
|
21
22
|
"./icon-catalog": "./src/icon-catalog.ts",
|
|
22
23
|
"./icon-persist": "./src/icon-persist.ts",
|
|
@@ -76,7 +77,7 @@
|
|
|
76
77
|
"access": "public"
|
|
77
78
|
},
|
|
78
79
|
"dependencies": {
|
|
79
|
-
"@xynogen/pix-runtime": "^0.
|
|
80
|
+
"@xynogen/pix-runtime": "^0.23.0",
|
|
80
81
|
"chalk": "^4.1.2",
|
|
81
82
|
"cli-highlight": "^2.1.11",
|
|
82
83
|
"@ff-labs/fff-node": "^0.10.6",
|
package/src/ansi.ts
CHANGED
|
@@ -32,6 +32,35 @@ export function hasAnsi(s: string): boolean {
|
|
|
32
32
|
return s.includes(ESC);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Re-open `bgOpen`/`fgOpen` after every reset inside `s`: `\x1b[0m` clears both, `49`
|
|
37
|
+
* clears the background, `39` the foreground. Keeps a panel color solid behind
|
|
38
|
+
* embedded content that ends its own styles with a full reset.
|
|
39
|
+
*/
|
|
40
|
+
export function reopenAfterResets(s: string, bgOpen: string, fgOpen = ""): string {
|
|
41
|
+
if (!bgOpen && !fgOpen) return s;
|
|
42
|
+
return s.replace(ANSI_CAPTURE_RE, (seq, params: string) => {
|
|
43
|
+
let bgReset = false;
|
|
44
|
+
let fgReset = false;
|
|
45
|
+
const codes = params === "" ? [0] : params.split(";").map(Number);
|
|
46
|
+
for (let i = 0; i < codes.length; i++) {
|
|
47
|
+
const code = codes[i];
|
|
48
|
+
// 38/48 carry color arguments (`5;n` or `2;r;g;b`); a 49 there is not a reset.
|
|
49
|
+
if (code === 38 || code === 48) i += codes[i + 1] === 5 ? 2 : 4;
|
|
50
|
+
else if (code === 0) bgReset = fgReset = true;
|
|
51
|
+
else if (code === 49) bgReset = true;
|
|
52
|
+
else if (code === 39) fgReset = true;
|
|
53
|
+
}
|
|
54
|
+
return `${seq}${bgReset ? bgOpen : ""}${fgReset ? fgOpen : ""}`;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** A `Box` background function that stays solid behind content with embedded resets. */
|
|
59
|
+
export function solidBackground(bg: (text: string) => string): (text: string) => string {
|
|
60
|
+
const bgOpen = bg("\x00").split("\x00")[0] ?? "";
|
|
61
|
+
return (text) => bg(reopenAfterResets(text, bgOpen));
|
|
62
|
+
}
|
|
63
|
+
|
|
35
64
|
// ---------------------------------------------------------------------------
|
|
36
65
|
// Low-contrast fix (same as pi-diff)
|
|
37
66
|
// ---------------------------------------------------------------------------
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display transform for Markdown that Pi does not pass through its transformer chain,
|
|
3
|
+
* such as cards drawn by entry renderers (`/btw`). pix-display registers the same
|
|
4
|
+
* pipeline it gives assistant replies; without it the Markdown stays as written.
|
|
5
|
+
* The slot lives on globalThis: Pi re-evaluates extension modules on reload.
|
|
6
|
+
*/
|
|
7
|
+
export type MarkdownTransform = (markdown: string, availableWidth: number) => string;
|
|
8
|
+
|
|
9
|
+
const KEY = Symbol.for("@xynogen/pix-pretty:markdown-transform");
|
|
10
|
+
type Slot = { [KEY]?: MarkdownTransform };
|
|
11
|
+
|
|
12
|
+
export function setMarkdownTransform(transform: MarkdownTransform | undefined): void {
|
|
13
|
+
(globalThis as Slot)[KEY] = transform;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Pass as `Markdown`'s `transform` option. A throwing transform keeps the source, as Pi does. */
|
|
17
|
+
export function transformMarkdown(markdown: string, availableWidth: number): string {
|
|
18
|
+
try {
|
|
19
|
+
return (globalThis as Slot)[KEY]?.(markdown, availableWidth) ?? markdown;
|
|
20
|
+
} catch {
|
|
21
|
+
return markdown;
|
|
22
|
+
}
|
|
23
|
+
}
|
package/src/modal-frame.ts
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
} from "@earendil-works/pi-tui";
|
|
19
19
|
import { config } from "@xynogen/pix-runtime/config";
|
|
20
20
|
import { prettySection, type RenderSize } from "@xynogen/pix-runtime/sections";
|
|
21
|
+
import { reopenAfterResets } from "./ansi.ts";
|
|
21
22
|
|
|
22
23
|
export { truncateToWidth, visibleWidth, wrapTextWithAnsi };
|
|
23
24
|
|
|
@@ -233,24 +234,12 @@ export function frameLines(opts: FrameOptions): string[] {
|
|
|
233
234
|
// Expand before framing so a long command wraps instead of losing its tail.
|
|
234
235
|
const { rows: lines } = fitModalLines(opts.lines, inner, wrap);
|
|
235
236
|
|
|
236
|
-
//
|
|
237
|
-
//
|
|
238
|
-
// \x1b[39m clears fg. Re-emitting the base opens after each keeps the modal
|
|
239
|
-
// background solid AND gives raw text a readable foreground.
|
|
237
|
+
// Re-assert the base opens after any embedded reset so the modal background stays
|
|
238
|
+
// solid AND raw text keeps a readable foreground.
|
|
240
239
|
const SENTINEL = "\x00";
|
|
241
240
|
const bgOpen = bg(SENTINEL).split(SENTINEL)[0] ?? "";
|
|
242
241
|
const fgOpen = fg ? (fg(SENTINEL).split(SENTINEL)[0] ?? "") : "";
|
|
243
|
-
const reassert = (s: string): string =>
|
|
244
|
-
bgOpen || fgOpen
|
|
245
|
-
? s.replace(/\x1b\[([0-9;]*)m/g, (seq, p: string) => {
|
|
246
|
-
const parts = p.split(";");
|
|
247
|
-
const isFull = p === "0";
|
|
248
|
-
let tail = seq;
|
|
249
|
-
if (isFull || parts.includes("49")) tail += bgOpen;
|
|
250
|
-
if (isFull || parts.includes("39")) tail += fgOpen;
|
|
251
|
-
return tail;
|
|
252
|
-
})
|
|
253
|
-
: s;
|
|
242
|
+
const reassert = (s: string): string => reopenAfterResets(s, bgOpen, fgOpen);
|
|
254
243
|
|
|
255
244
|
const row = (content: string): string => {
|
|
256
245
|
const pad = inner - visibleWidth(content);
|
package/src/provider-picker.ts
CHANGED
|
@@ -18,6 +18,8 @@ import {
|
|
|
18
18
|
visibleWidth,
|
|
19
19
|
} from "@earendil-works/pi-tui";
|
|
20
20
|
import { getErrorMessage } from "@xynogen/pix-runtime/errors";
|
|
21
|
+
import { ListFilter } from "@xynogen/pix-runtime/list-filter";
|
|
22
|
+
import { isSubTabKey, nextTab, renderSubTabBar, renderTabRule } from "@xynogen/pix-runtime/tab-bar";
|
|
21
23
|
import {
|
|
22
24
|
frameModal,
|
|
23
25
|
MIN_MODAL_HEIGHT,
|
|
@@ -165,6 +167,8 @@ export interface SettingsRow {
|
|
|
165
167
|
value: string;
|
|
166
168
|
/** Theme role for the value. Default `success`. */
|
|
167
169
|
tone?: "success" | "warning" | "muted";
|
|
170
|
+
/** Dim the label too: the row is turned off. The cursor still highlights it. */
|
|
171
|
+
dim?: boolean;
|
|
168
172
|
/** Enter edits `value` in a text field inside the row, not in a new dialog. */
|
|
169
173
|
editable?: boolean;
|
|
170
174
|
/**
|
|
@@ -195,6 +199,44 @@ export function filterChoices(choices: SettingsChoice[], query: string): Setting
|
|
|
195
199
|
|
|
196
200
|
export type SettingsAction = { key: string; value?: string };
|
|
197
201
|
|
|
202
|
+
const COLUMN_GAP = 3;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Plain toggle rows (no headings, choices or text fields) in column-major columns, so a long
|
|
206
|
+
* list fills the modal's width instead of paging down one narrow column. One column when the
|
|
207
|
+
* rows do not fit two. Exported for tests.
|
|
208
|
+
*/
|
|
209
|
+
export function settingsColumns(rows: SettingsRow[], width: number): number {
|
|
210
|
+
if (rows.length < 8 || rows.some((row) => row.section || row.choices?.length || row.editable))
|
|
211
|
+
return 1;
|
|
212
|
+
const labelWidth = Math.max(...rows.map((row) => visibleWidth(row.label)));
|
|
213
|
+
const valueWidth = Math.max(...rows.map((row) => visibleWidth(row.value)));
|
|
214
|
+
const cell = 2 + labelWidth + 2 + valueWidth;
|
|
215
|
+
return Math.max(1, Math.min(4, Math.floor((width + COLUMN_GAP) / (cell + COLUMN_GAP))));
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function renderColumns(
|
|
219
|
+
rows: SettingsRow[],
|
|
220
|
+
theme: Pick<PickerTheme, "fg">,
|
|
221
|
+
selected: number,
|
|
222
|
+
columns: number,
|
|
223
|
+
): { lines: string[]; rowLines: number[] } {
|
|
224
|
+
const labelWidth = Math.max(...rows.map((row) => visibleWidth(row.label)));
|
|
225
|
+
const valueWidth = Math.max(...rows.map((row) => visibleWidth(row.value)));
|
|
226
|
+
const perColumn = Math.ceil(rows.length / columns);
|
|
227
|
+
const lines: string[] = Array.from({ length: perColumn }, () => "");
|
|
228
|
+
const rowLines: number[] = [];
|
|
229
|
+
rows.forEach((row, index) => {
|
|
230
|
+
const line = index % perColumn;
|
|
231
|
+
const active = index === selected;
|
|
232
|
+
const labelRole = active ? "accent" : row.dim ? "dim" : "text";
|
|
233
|
+
const cell = `${active ? theme.fg("accent", "→") : " "} ${theme.fg(labelRole, row.label.padEnd(labelWidth))} ${theme.fg(row.tone ?? "success", row.value.padEnd(valueWidth))}`;
|
|
234
|
+
lines[line] += (index >= perColumn ? " ".repeat(COLUMN_GAP) : "") + cell;
|
|
235
|
+
rowLines[index] = line;
|
|
236
|
+
});
|
|
237
|
+
return { lines, rowLines };
|
|
238
|
+
}
|
|
239
|
+
|
|
198
240
|
/** Render the sectioned settings overview body. Exported for tests. */
|
|
199
241
|
export function renderSettingsRows(
|
|
200
242
|
rows: SettingsRow[],
|
|
@@ -204,20 +246,24 @@ export function renderSettingsRows(
|
|
|
204
246
|
width = 80,
|
|
205
247
|
list?: { choices: SettingsChoice[]; cursor: number; query: string; max?: number },
|
|
206
248
|
): { lines: string[]; rowLines: number[]; listLine?: number } {
|
|
249
|
+
const columns = field || list ? 1 : settingsColumns(rows, width);
|
|
250
|
+
if (columns > 1) return renderColumns(rows, theme, selected, columns);
|
|
207
251
|
const labelWidth = Math.max(...rows.map((row) => row.label.length));
|
|
208
252
|
const lines: string[] = [];
|
|
209
253
|
const rowLines: number[] = [];
|
|
210
254
|
let listLine: number | undefined;
|
|
211
255
|
let section = "";
|
|
212
256
|
rows.forEach((row, index) => {
|
|
213
|
-
|
|
257
|
+
// An empty section (rows of one sub-tab) gets no heading.
|
|
258
|
+
if (row.section !== section && row.section) {
|
|
214
259
|
if (section) lines.push("");
|
|
215
260
|
lines.push(theme.fg("dim", ` ${row.section}`));
|
|
216
261
|
section = row.section;
|
|
217
262
|
}
|
|
218
263
|
const active = index === selected;
|
|
219
264
|
rowLines[index] = lines.length;
|
|
220
|
-
const
|
|
265
|
+
const labelRole = active ? "accent" : row.dim ? "dim" : "text";
|
|
266
|
+
const label = `${active ? theme.fg("accent", "→") : " "} ${theme.fg(labelRole, row.label.padEnd(labelWidth))} `;
|
|
221
267
|
const editing = active ? field : undefined;
|
|
222
268
|
const valueWidth = Math.max(10, width - labelWidth - 4);
|
|
223
269
|
lines.push(
|
|
@@ -270,10 +316,18 @@ export interface SettingsPickerOptions {
|
|
|
270
316
|
onMount?: (redraw: () => void) => () => void;
|
|
271
317
|
/** Start row. */
|
|
272
318
|
selected?: number;
|
|
319
|
+
/**
|
|
320
|
+
* Show each row `section` as a sub-tab (`` ` `` switches) instead of a heading in one list.
|
|
321
|
+
* Off by default; one section shows no tab bar.
|
|
322
|
+
*/
|
|
323
|
+
sectionTabs?: boolean;
|
|
324
|
+
/** The shared `/pix` search line: `/` filters rows by label or section across every sub-tab. */
|
|
325
|
+
search?: boolean;
|
|
273
326
|
}
|
|
274
327
|
|
|
275
328
|
/**
|
|
276
|
-
* Show the sectioned settings overview
|
|
329
|
+
* Show the sectioned settings overview, or one section per sub-tab with `sectionTabs`.
|
|
330
|
+
* It stays open until esc, or until
|
|
277
331
|
* `onAction` returns `"close"`. For an `editable` row, enter opens a text field in
|
|
278
332
|
* the row. Resolves with the closing action, or null on escape.
|
|
279
333
|
*/
|
|
@@ -283,8 +337,23 @@ export async function showSettingsPicker(
|
|
|
283
337
|
): Promise<SettingsAction | null> {
|
|
284
338
|
const result = await ui.custom<SettingsAction | null>(
|
|
285
339
|
(tui, theme, keybindings, done) => {
|
|
286
|
-
let
|
|
287
|
-
|
|
340
|
+
let all = opts.rows();
|
|
341
|
+
const sectionsOf = (list: SettingsRow[]) => [...new Set(list.map((row) => row.section))];
|
|
342
|
+
// Start on the section of the requested row, so a reopened panel keeps its place.
|
|
343
|
+
let tab = opts.sectionTabs ? (all[opts.selected ?? 0]?.section ?? all[0]?.section ?? "") : "";
|
|
344
|
+
const filter = opts.search ? new ListFilter() : undefined;
|
|
345
|
+
// A query searches every sub-tab, like the /pix Settings tab.
|
|
346
|
+
const visible = () =>
|
|
347
|
+
filter?.query
|
|
348
|
+
? all.filter((row) => filter.matches(row.label, row.section))
|
|
349
|
+
: tab
|
|
350
|
+
? all.filter((row) => row.section === tab)
|
|
351
|
+
: all;
|
|
352
|
+
let rows = visible();
|
|
353
|
+
let selected = Math.max(
|
|
354
|
+
0,
|
|
355
|
+
Math.min(rows.indexOf(all[opts.selected ?? 0] as SettingsRow), rows.length - 1),
|
|
356
|
+
);
|
|
288
357
|
let field: Input | undefined;
|
|
289
358
|
let list: { row: SettingsRow; query: string; cursor: number } | undefined;
|
|
290
359
|
let busy = false;
|
|
@@ -304,7 +373,10 @@ export async function showSettingsPicker(
|
|
|
304
373
|
error = getErrorMessage(cause);
|
|
305
374
|
}
|
|
306
375
|
busy = false;
|
|
307
|
-
|
|
376
|
+
all = opts.rows();
|
|
377
|
+
if (tab && !sectionsOf(all).includes(tab)) tab = all[0]?.section ?? "";
|
|
378
|
+
rows = visible();
|
|
379
|
+
selected = Math.min(selected, Math.max(0, rows.length - 1));
|
|
308
380
|
redraw();
|
|
309
381
|
};
|
|
310
382
|
const edit = (row: SettingsRow) => {
|
|
@@ -330,6 +402,28 @@ export async function showSettingsPicker(
|
|
|
330
402
|
const index = (row.choices ?? []).findIndex((choice) => choice.value === row.value);
|
|
331
403
|
list = { row, query: "", cursor: Math.max(0, index) };
|
|
332
404
|
};
|
|
405
|
+
// Columns the last frame drew: ←→ jump a column, ↑↓ walk down one and on into the next.
|
|
406
|
+
let columns = 1;
|
|
407
|
+
const move = (step: -1 | 1) => {
|
|
408
|
+
if (rows.length) selected = (selected + step + rows.length) % rows.length;
|
|
409
|
+
};
|
|
410
|
+
const moveColumn = (step: -1 | 1) => {
|
|
411
|
+
const perColumn = Math.ceil(rows.length / columns);
|
|
412
|
+
const next = selected + step * perColumn;
|
|
413
|
+
if (next >= 0 && next < rows.length) selected = next;
|
|
414
|
+
else if (step > 0) selected = rows.length - 1;
|
|
415
|
+
};
|
|
416
|
+
/** Search input open: ↑↓ move through the matches, every other key edits the query. */
|
|
417
|
+
const searchInput = (search: ListFilter, data: string) => {
|
|
418
|
+
if (keybindings.matches(data, "tui.select.up")) move(-1);
|
|
419
|
+
else if (keybindings.matches(data, "tui.select.down")) move(1);
|
|
420
|
+
else {
|
|
421
|
+
search.handleInput(data);
|
|
422
|
+
rows = visible();
|
|
423
|
+
selected = Math.min(selected, Math.max(0, rows.length - 1));
|
|
424
|
+
}
|
|
425
|
+
redraw();
|
|
426
|
+
};
|
|
333
427
|
const listInput = (data: string) => {
|
|
334
428
|
if (!list) return;
|
|
335
429
|
const choices = listChoices();
|
|
@@ -361,14 +455,21 @@ export async function showSettingsPicker(
|
|
|
361
455
|
return {
|
|
362
456
|
render(width: number) {
|
|
363
457
|
const mw = modalWidth(width);
|
|
458
|
+
const tabs = tab ? sectionsOf(all) : [];
|
|
459
|
+
const shown =
|
|
460
|
+
tabs.length > 1 && !filter?.query ? rows.map((row) => ({ ...row, section: "" })) : rows;
|
|
461
|
+
columns = field || list ? 1 : settingsColumns(shown, mw - 4);
|
|
364
462
|
const body = renderSettingsRows(
|
|
365
|
-
|
|
463
|
+
// Sub-tabs name the section; search results span sections, so they keep headings.
|
|
464
|
+
shown,
|
|
366
465
|
theme,
|
|
367
466
|
selected,
|
|
368
467
|
field,
|
|
369
468
|
mw - 4,
|
|
370
469
|
list && { choices: listChoices(), cursor: list.cursor, query: list.query },
|
|
371
470
|
);
|
|
471
|
+
if (filter && rows.length === 0) body.lines.push(filter.noMatch(theme));
|
|
472
|
+
const searchLine = filter ? [filter.line(theme, mw - 4, rows.length, all.length)] : [];
|
|
372
473
|
const status = opts.status?.() ?? [];
|
|
373
474
|
if (error) status.push(theme.fg("error", error));
|
|
374
475
|
if (status.length) body.lines.push("", ...status);
|
|
@@ -378,7 +479,16 @@ export async function showSettingsPicker(
|
|
|
378
479
|
minHeight: MIN_MODAL_HEIGHT,
|
|
379
480
|
title: opts.title,
|
|
380
481
|
titleColor: (text) => theme.fg("accent", theme.bold(text)),
|
|
381
|
-
header:
|
|
482
|
+
header:
|
|
483
|
+
tabs.length > 1
|
|
484
|
+
? [
|
|
485
|
+
renderSubTabBar(tabs, tab, theme, mw - 4),
|
|
486
|
+
renderTabRule(theme, mw - 4),
|
|
487
|
+
...searchLine,
|
|
488
|
+
]
|
|
489
|
+
: searchLine.length
|
|
490
|
+
? searchLine
|
|
491
|
+
: [""],
|
|
382
492
|
body: body.lines,
|
|
383
493
|
footer: [
|
|
384
494
|
"",
|
|
@@ -388,7 +498,9 @@ export async function showSettingsPicker(
|
|
|
388
498
|
? "enter save · esc cancel"
|
|
389
499
|
: list
|
|
390
500
|
? "type to filter · ↑↓ move · enter pick · esc cancel"
|
|
391
|
-
:
|
|
501
|
+
: filter?.typing
|
|
502
|
+
? "↑↓ move · enter keep · esc clear"
|
|
503
|
+
: `↑↓${columns > 1 ? "←→" : ""} move · space/enter${all.some((row) => row.choices?.length) ? "/←→" : ""} change${tabs.length > 1 ? " · ` sub-tab" : ""}${filter ? " · / search" : ""} · esc close`,
|
|
392
504
|
),
|
|
393
505
|
],
|
|
394
506
|
selectedBodyLine: body.listLine ?? body.rowLines[selected],
|
|
@@ -404,20 +516,48 @@ export async function showSettingsPicker(
|
|
|
404
516
|
return redraw();
|
|
405
517
|
}
|
|
406
518
|
if (list) return listInput(data);
|
|
407
|
-
if (
|
|
519
|
+
if (filter?.typing) return searchInput(filter, data);
|
|
520
|
+
if (keybindings.matches(data, "tui.select.cancel")) {
|
|
521
|
+
if (!filter?.clear()) return close(null);
|
|
522
|
+
rows = visible();
|
|
523
|
+
selected = 0;
|
|
524
|
+
return redraw();
|
|
525
|
+
}
|
|
408
526
|
if (busy) return;
|
|
527
|
+
if (filter && matchesKey(data, "/")) {
|
|
528
|
+
filter.open();
|
|
529
|
+
selected = 0;
|
|
530
|
+
return redraw();
|
|
531
|
+
}
|
|
532
|
+
if (tab && isSubTabKey(data)) {
|
|
533
|
+
tab = nextTab(sectionsOf(all), tab);
|
|
534
|
+
filter?.clear();
|
|
535
|
+
rows = visible();
|
|
536
|
+
selected = 0;
|
|
537
|
+
return redraw();
|
|
538
|
+
}
|
|
409
539
|
const row = rows[selected];
|
|
410
|
-
|
|
540
|
+
// Standard /pix keys: enter or space acts on the row; ←→ step through its choices.
|
|
541
|
+
if (matchesKey(data, Key.enter) || matchesKey(data, Key.space)) {
|
|
411
542
|
if (!row) return;
|
|
412
543
|
if (row.choices?.length) openList(row);
|
|
413
544
|
else if (row.editable) edit(row);
|
|
414
545
|
else void run({ key: row.key });
|
|
415
546
|
return redraw();
|
|
416
547
|
}
|
|
417
|
-
if (
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
548
|
+
if (columns > 1 && (matchesKey(data, Key.left) || matchesKey(data, Key.right))) {
|
|
549
|
+
moveColumn(matchesKey(data, Key.left) ? -1 : 1);
|
|
550
|
+
return redraw();
|
|
551
|
+
}
|
|
552
|
+
if (row?.choices?.length && (matchesKey(data, Key.left) || matchesKey(data, Key.right))) {
|
|
553
|
+
const at = row.choices.findIndex((choice) => choice.value === row.value);
|
|
554
|
+
const step = matchesKey(data, Key.left) ? -1 : 1;
|
|
555
|
+
const next = row.choices[(at + step + row.choices.length) % row.choices.length];
|
|
556
|
+
if (next && next.value !== row.value) void run({ key: row.key, value: next.value });
|
|
557
|
+
return redraw();
|
|
558
|
+
}
|
|
559
|
+
if (keybindings.matches(data, "tui.select.up")) move(-1);
|
|
560
|
+
else if (keybindings.matches(data, "tui.select.down")) move(1);
|
|
421
561
|
else return;
|
|
422
562
|
redraw();
|
|
423
563
|
},
|
|
@@ -497,11 +637,11 @@ export async function showProviderPicker(
|
|
|
497
637
|
"",
|
|
498
638
|
field
|
|
499
639
|
? guide("enter", "submit") + sep + guide("esc", "cancel")
|
|
500
|
-
: guide("
|
|
640
|
+
: guide("↑↓", "move") +
|
|
501
641
|
sep +
|
|
502
642
|
guide("enter", "set default") +
|
|
503
643
|
sep +
|
|
504
|
-
guide("space", "
|
|
644
|
+
guide("space", "expand") +
|
|
505
645
|
sep +
|
|
506
646
|
guide("esc", "close"),
|
|
507
647
|
],
|