@easbot/tui 0.1.7
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 +833 -0
- package/dist/index.cjs +45 -0
- package/dist/index.d.cts +762 -0
- package/dist/index.d.ts +762 -0
- package/dist/index.mjs +45 -0
- package/package.json +78 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,762 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
|
|
3
|
+
interface AutocompleteItem {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
}
|
|
8
|
+
interface SlashCommand {
|
|
9
|
+
name: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
getArgumentCompletions?(argumentPrefix: string): AutocompleteItem[] | null;
|
|
12
|
+
}
|
|
13
|
+
interface AutocompleteProvider {
|
|
14
|
+
getSuggestions(lines: string[], cursorLine: number, cursorCol: number): {
|
|
15
|
+
items: AutocompleteItem[];
|
|
16
|
+
prefix: string;
|
|
17
|
+
} | null;
|
|
18
|
+
applyCompletion(lines: string[], cursorLine: number, cursorCol: number, item: AutocompleteItem, prefix: string): {
|
|
19
|
+
lines: string[];
|
|
20
|
+
cursorLine: number;
|
|
21
|
+
cursorCol: number;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
declare class CombinedAutocompleteProvider implements AutocompleteProvider {
|
|
25
|
+
private commands;
|
|
26
|
+
private basePath;
|
|
27
|
+
private fdPath;
|
|
28
|
+
constructor(commands?: (SlashCommand | AutocompleteItem)[], basePath?: string, fdPath?: string | null);
|
|
29
|
+
getSuggestions(lines: string[], cursorLine: number, cursorCol: number): {
|
|
30
|
+
items: AutocompleteItem[];
|
|
31
|
+
prefix: string;
|
|
32
|
+
} | null;
|
|
33
|
+
applyCompletion(lines: string[], cursorLine: number, cursorCol: number, item: AutocompleteItem, prefix: string): {
|
|
34
|
+
lines: string[];
|
|
35
|
+
cursorLine: number;
|
|
36
|
+
cursorCol: number;
|
|
37
|
+
};
|
|
38
|
+
private extractAtPrefix;
|
|
39
|
+
private extractPathPrefix;
|
|
40
|
+
private expandHomePath;
|
|
41
|
+
private resolveScopedFuzzyQuery;
|
|
42
|
+
private scopedPathForDisplay;
|
|
43
|
+
private getFileSuggestions;
|
|
44
|
+
private scoreEntry;
|
|
45
|
+
private getFuzzyFileSuggestions;
|
|
46
|
+
getForceFileSuggestions(lines: string[], cursorLine: number, cursorCol: number): {
|
|
47
|
+
items: AutocompleteItem[];
|
|
48
|
+
prefix: string;
|
|
49
|
+
} | null;
|
|
50
|
+
shouldTriggerFileCompletion(lines: string[], cursorLine: number, cursorCol: number): boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
interface Terminal {
|
|
54
|
+
start(onInput: (data: string) => void, onResize: () => void): void;
|
|
55
|
+
stop(): void;
|
|
56
|
+
drainInput(maxMs?: number, idleMs?: number): Promise<void>;
|
|
57
|
+
write(data: string): void;
|
|
58
|
+
get columns(): number;
|
|
59
|
+
get rows(): number;
|
|
60
|
+
get kittyProtocolActive(): boolean;
|
|
61
|
+
moveBy(lines: number): void;
|
|
62
|
+
hideCursor(): void;
|
|
63
|
+
showCursor(): void;
|
|
64
|
+
clearLine(): void;
|
|
65
|
+
clearFromCursor(): void;
|
|
66
|
+
clearScreen(): void;
|
|
67
|
+
setTitle(title: string): void;
|
|
68
|
+
}
|
|
69
|
+
declare class ProcessTerminal implements Terminal {
|
|
70
|
+
private wasRaw;
|
|
71
|
+
private inputHandler?;
|
|
72
|
+
private resizeHandler?;
|
|
73
|
+
private _kittyProtocolActive;
|
|
74
|
+
private stdinBuffer?;
|
|
75
|
+
private stdinDataHandler?;
|
|
76
|
+
private writeLogPath;
|
|
77
|
+
get kittyProtocolActive(): boolean;
|
|
78
|
+
start(onInput: (data: string) => void, onResize: () => void): void;
|
|
79
|
+
private setupStdinBuffer;
|
|
80
|
+
private queryAndEnableKittyProtocol;
|
|
81
|
+
private enableWindowsVTInput;
|
|
82
|
+
drainInput(maxMs?: number, idleMs?: number): Promise<void>;
|
|
83
|
+
stop(): void;
|
|
84
|
+
write(data: string): void;
|
|
85
|
+
get columns(): number;
|
|
86
|
+
get rows(): number;
|
|
87
|
+
moveBy(lines: number): void;
|
|
88
|
+
hideCursor(): void;
|
|
89
|
+
showCursor(): void;
|
|
90
|
+
clearLine(): void;
|
|
91
|
+
clearFromCursor(): void;
|
|
92
|
+
clearScreen(): void;
|
|
93
|
+
setTitle(title: string): void;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
declare function visibleWidth(str: string): number;
|
|
97
|
+
declare function wrapTextWithAnsi(text: string, width: number): string[];
|
|
98
|
+
declare function truncateToWidth(text: string, maxWidth: number, ellipsis?: string, pad?: boolean): string;
|
|
99
|
+
declare function sliceByColumn(line: string, startCol: number, length: number, strict?: boolean): string;
|
|
100
|
+
|
|
101
|
+
interface Component {
|
|
102
|
+
render(width: number): string[];
|
|
103
|
+
handleInput?(data: string): void;
|
|
104
|
+
wantsKeyRelease?: boolean;
|
|
105
|
+
invalidate(): void;
|
|
106
|
+
}
|
|
107
|
+
type InputListenerResult = {
|
|
108
|
+
consume?: boolean;
|
|
109
|
+
data?: string;
|
|
110
|
+
} | undefined;
|
|
111
|
+
type InputListener = (data: string) => InputListenerResult;
|
|
112
|
+
interface Focusable {
|
|
113
|
+
focused: boolean;
|
|
114
|
+
}
|
|
115
|
+
declare function isFocusable(component: Component | null): component is Component & Focusable;
|
|
116
|
+
declare const CURSOR_MARKER = "\u001B_pi:c\u0007";
|
|
117
|
+
|
|
118
|
+
type OverlayAnchor = 'center' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'top-center' | 'bottom-center' | 'left-center' | 'right-center';
|
|
119
|
+
interface OverlayMargin {
|
|
120
|
+
top?: number;
|
|
121
|
+
right?: number;
|
|
122
|
+
bottom?: number;
|
|
123
|
+
left?: number;
|
|
124
|
+
}
|
|
125
|
+
type SizeValue = number | `${number}%`;
|
|
126
|
+
interface OverlayOptions {
|
|
127
|
+
width?: SizeValue;
|
|
128
|
+
minWidth?: number;
|
|
129
|
+
maxHeight?: SizeValue;
|
|
130
|
+
anchor?: OverlayAnchor;
|
|
131
|
+
offsetX?: number;
|
|
132
|
+
offsetY?: number;
|
|
133
|
+
row?: SizeValue;
|
|
134
|
+
col?: SizeValue;
|
|
135
|
+
margin?: OverlayMargin | number;
|
|
136
|
+
visible?: (termWidth: number, termHeight: number) => boolean;
|
|
137
|
+
}
|
|
138
|
+
interface OverlayHandle {
|
|
139
|
+
hide(): void;
|
|
140
|
+
setHidden(hidden: boolean): void;
|
|
141
|
+
isHidden(): boolean;
|
|
142
|
+
}
|
|
143
|
+
declare class Container implements Component {
|
|
144
|
+
children: Component[];
|
|
145
|
+
addChild(component: Component): void;
|
|
146
|
+
removeChild(component: Component): void;
|
|
147
|
+
clear(): void;
|
|
148
|
+
invalidate(): void;
|
|
149
|
+
render(width: number): string[];
|
|
150
|
+
}
|
|
151
|
+
declare class TUI extends Container {
|
|
152
|
+
terminal: Terminal;
|
|
153
|
+
private previousLines;
|
|
154
|
+
private previousWidth;
|
|
155
|
+
private focusedComponent;
|
|
156
|
+
private inputListeners;
|
|
157
|
+
onDebug?: () => void;
|
|
158
|
+
private renderRequested;
|
|
159
|
+
private cursorRow;
|
|
160
|
+
private hardwareCursorRow;
|
|
161
|
+
private inputBuffer;
|
|
162
|
+
private cellSizeQueryPending;
|
|
163
|
+
private showHardwareCursor;
|
|
164
|
+
private clearOnShrink;
|
|
165
|
+
private maxLinesRendered;
|
|
166
|
+
private previousViewportTop;
|
|
167
|
+
private fullRedrawCount;
|
|
168
|
+
private stopped;
|
|
169
|
+
private overlayStack;
|
|
170
|
+
constructor(terminal: Terminal, showHardwareCursor?: boolean);
|
|
171
|
+
get fullRedraws(): number;
|
|
172
|
+
getShowHardwareCursor(): boolean;
|
|
173
|
+
setShowHardwareCursor(enabled: boolean): void;
|
|
174
|
+
getClearOnShrink(): boolean;
|
|
175
|
+
setClearOnShrink(enabled: boolean): void;
|
|
176
|
+
setFocus(component: Component | null): void;
|
|
177
|
+
showOverlay(component: Component, options?: OverlayOptions): OverlayHandle;
|
|
178
|
+
hideOverlay(): void;
|
|
179
|
+
hasOverlay(): boolean;
|
|
180
|
+
private isOverlayVisible;
|
|
181
|
+
private getTopmostVisibleOverlay;
|
|
182
|
+
invalidate(): void;
|
|
183
|
+
start(): void;
|
|
184
|
+
addInputListener(listener: InputListener): () => void;
|
|
185
|
+
removeInputListener(listener: InputListener): void;
|
|
186
|
+
private queryCellSize;
|
|
187
|
+
stop(): void;
|
|
188
|
+
requestRender(force?: boolean): void;
|
|
189
|
+
private handleInput;
|
|
190
|
+
private parseCellSizeResponse;
|
|
191
|
+
private resolveOverlayLayout;
|
|
192
|
+
private resolveAnchorRow;
|
|
193
|
+
private resolveAnchorCol;
|
|
194
|
+
private compositeOverlays;
|
|
195
|
+
private static readonly SEGMENT_RESET;
|
|
196
|
+
private applyLineResets;
|
|
197
|
+
private compositeLineAt;
|
|
198
|
+
private extractCursorPosition;
|
|
199
|
+
private doRender;
|
|
200
|
+
private positionHardwareCursor;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
declare class Box implements Component {
|
|
204
|
+
children: Component[];
|
|
205
|
+
private paddingX;
|
|
206
|
+
private paddingY;
|
|
207
|
+
private bgFn?;
|
|
208
|
+
private cache?;
|
|
209
|
+
constructor(paddingX?: number, paddingY?: number, bgFn?: (text: string) => string);
|
|
210
|
+
addChild(component: Component): void;
|
|
211
|
+
removeChild(component: Component): void;
|
|
212
|
+
clear(): void;
|
|
213
|
+
setBgFn(bgFn?: (text: string) => string): void;
|
|
214
|
+
private invalidateCache;
|
|
215
|
+
private matchCache;
|
|
216
|
+
invalidate(): void;
|
|
217
|
+
render(width: number): string[];
|
|
218
|
+
private applyBg;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
declare class Text implements Component {
|
|
222
|
+
private text;
|
|
223
|
+
private paddingX;
|
|
224
|
+
private paddingY;
|
|
225
|
+
private customBgFn?;
|
|
226
|
+
private cachedText?;
|
|
227
|
+
private cachedWidth?;
|
|
228
|
+
private cachedLines?;
|
|
229
|
+
constructor(text?: string, paddingX?: number, paddingY?: number, customBgFn?: (text: string) => string);
|
|
230
|
+
setText(text: string): void;
|
|
231
|
+
setCustomBgFn(customBgFn?: (text: string) => string): void;
|
|
232
|
+
invalidate(): void;
|
|
233
|
+
render(width: number): string[];
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
declare class Loader extends Text {
|
|
237
|
+
private spinnerColorFn;
|
|
238
|
+
private messageColorFn;
|
|
239
|
+
private message;
|
|
240
|
+
private frames;
|
|
241
|
+
private currentFrame;
|
|
242
|
+
private intervalId;
|
|
243
|
+
private ui;
|
|
244
|
+
constructor(ui: TUI, spinnerColorFn: (str: string) => string, messageColorFn: (str: string) => string, message?: string);
|
|
245
|
+
render(width: number): string[];
|
|
246
|
+
start(): void;
|
|
247
|
+
stop(): void;
|
|
248
|
+
setMessage(message: string): void;
|
|
249
|
+
private updateDisplay;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
declare class CancellableLoader extends Loader {
|
|
253
|
+
private abortController;
|
|
254
|
+
onAbort?: () => void;
|
|
255
|
+
get signal(): AbortSignal;
|
|
256
|
+
get aborted(): boolean;
|
|
257
|
+
handleInput(data: string): void;
|
|
258
|
+
dispose(): void;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
interface SelectItem {
|
|
262
|
+
value: string;
|
|
263
|
+
label: string;
|
|
264
|
+
description?: string;
|
|
265
|
+
}
|
|
266
|
+
interface SelectListTheme {
|
|
267
|
+
selectedPrefix: (text: string) => string;
|
|
268
|
+
selectedText: (text: string) => string;
|
|
269
|
+
description: (text: string) => string;
|
|
270
|
+
scrollInfo: (text: string) => string;
|
|
271
|
+
noMatch: (text: string) => string;
|
|
272
|
+
}
|
|
273
|
+
declare class SelectList implements Component {
|
|
274
|
+
private items;
|
|
275
|
+
private filteredItems;
|
|
276
|
+
private selectedIndex;
|
|
277
|
+
private maxVisible;
|
|
278
|
+
private theme;
|
|
279
|
+
onSelect?: (item: SelectItem) => void;
|
|
280
|
+
onCancel?: () => void;
|
|
281
|
+
onSelectionChange?: (item: SelectItem) => void;
|
|
282
|
+
constructor(items: SelectItem[], maxVisible: number, theme: SelectListTheme);
|
|
283
|
+
setFilter(filter: string): void;
|
|
284
|
+
setSelectedIndex(index: number): void;
|
|
285
|
+
invalidate(): void;
|
|
286
|
+
render(width: number): string[];
|
|
287
|
+
handleInput(keyData: string): void;
|
|
288
|
+
private notifySelectionChange;
|
|
289
|
+
getSelectedItem(): SelectItem | null;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
interface EditorTheme {
|
|
293
|
+
borderColor: (str: string) => string;
|
|
294
|
+
selectList: SelectListTheme;
|
|
295
|
+
}
|
|
296
|
+
interface EditorOptions {
|
|
297
|
+
paddingX?: number;
|
|
298
|
+
autocompleteMaxVisible?: number;
|
|
299
|
+
}
|
|
300
|
+
declare class Editor implements Component, Focusable {
|
|
301
|
+
private state;
|
|
302
|
+
focused: boolean;
|
|
303
|
+
protected tui: TUI;
|
|
304
|
+
private theme;
|
|
305
|
+
private paddingX;
|
|
306
|
+
private lastWidth;
|
|
307
|
+
private scrollOffset;
|
|
308
|
+
borderColor: (str: string) => string;
|
|
309
|
+
private autocompleteProvider?;
|
|
310
|
+
private autocompleteList?;
|
|
311
|
+
private autocompleteState;
|
|
312
|
+
private autocompletePrefix;
|
|
313
|
+
private autocompleteMaxVisible;
|
|
314
|
+
private pastes;
|
|
315
|
+
private pasteCounter;
|
|
316
|
+
private pasteBuffer;
|
|
317
|
+
private isInPaste;
|
|
318
|
+
private history;
|
|
319
|
+
private historyIndex;
|
|
320
|
+
private killRing;
|
|
321
|
+
private lastAction;
|
|
322
|
+
private jumpMode;
|
|
323
|
+
private preferredVisualCol;
|
|
324
|
+
private undoStack;
|
|
325
|
+
onSubmit?: (text: string) => void;
|
|
326
|
+
onChange?: (text: string) => void;
|
|
327
|
+
disableSubmit: boolean;
|
|
328
|
+
constructor(tui: TUI, theme: EditorTheme, options?: EditorOptions);
|
|
329
|
+
getPaddingX(): number;
|
|
330
|
+
setPaddingX(padding: number): void;
|
|
331
|
+
getAutocompleteMaxVisible(): number;
|
|
332
|
+
setAutocompleteMaxVisible(maxVisible: number): void;
|
|
333
|
+
setAutocompleteProvider(provider: AutocompleteProvider): void;
|
|
334
|
+
addToHistory(text: string): void;
|
|
335
|
+
private isEditorEmpty;
|
|
336
|
+
private isOnFirstVisualLine;
|
|
337
|
+
private isOnLastVisualLine;
|
|
338
|
+
private navigateHistory;
|
|
339
|
+
private setTextInternal;
|
|
340
|
+
invalidate(): void;
|
|
341
|
+
render(width: number): string[];
|
|
342
|
+
handleInput(data: string): void;
|
|
343
|
+
private layoutText;
|
|
344
|
+
getText(): string;
|
|
345
|
+
getExpandedText(): string;
|
|
346
|
+
getLines(): string[];
|
|
347
|
+
getCursor(): {
|
|
348
|
+
line: number;
|
|
349
|
+
col: number;
|
|
350
|
+
};
|
|
351
|
+
setText(text: string): void;
|
|
352
|
+
insertTextAtCursor(text: string): void;
|
|
353
|
+
private insertTextAtCursorInternal;
|
|
354
|
+
private insertCharacter;
|
|
355
|
+
private handlePaste;
|
|
356
|
+
private addNewLine;
|
|
357
|
+
private shouldSubmitOnBackslashEnter;
|
|
358
|
+
private submitValue;
|
|
359
|
+
private handleBackspace;
|
|
360
|
+
private setCursorCol;
|
|
361
|
+
private moveToVisualLine;
|
|
362
|
+
private computeVerticalMoveColumn;
|
|
363
|
+
private moveToLineStart;
|
|
364
|
+
private moveToLineEnd;
|
|
365
|
+
private deleteToStartOfLine;
|
|
366
|
+
private deleteToEndOfLine;
|
|
367
|
+
private deleteWordBackwards;
|
|
368
|
+
private deleteWordForward;
|
|
369
|
+
private handleForwardDelete;
|
|
370
|
+
private buildVisualLineMap;
|
|
371
|
+
private findCurrentVisualLine;
|
|
372
|
+
private moveCursor;
|
|
373
|
+
private pageScroll;
|
|
374
|
+
private moveWordBackwards;
|
|
375
|
+
private yank;
|
|
376
|
+
private yankPop;
|
|
377
|
+
private insertYankedText;
|
|
378
|
+
private deleteYankedText;
|
|
379
|
+
private pushUndoSnapshot;
|
|
380
|
+
private undo;
|
|
381
|
+
private jumpToChar;
|
|
382
|
+
private moveWordForwards;
|
|
383
|
+
private isSlashMenuAllowed;
|
|
384
|
+
private isAtStartOfMessage;
|
|
385
|
+
private isInSlashCommandContext;
|
|
386
|
+
private tryTriggerAutocomplete;
|
|
387
|
+
private handleTabCompletion;
|
|
388
|
+
private handleSlashCommandCompletion;
|
|
389
|
+
private forceFileAutocomplete;
|
|
390
|
+
private cancelAutocomplete;
|
|
391
|
+
isShowingAutocomplete(): boolean;
|
|
392
|
+
private updateAutocomplete;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
type ImageProtocol = 'kitty' | 'iterm2' | null;
|
|
396
|
+
interface TerminalCapabilities {
|
|
397
|
+
images: ImageProtocol;
|
|
398
|
+
trueColor: boolean;
|
|
399
|
+
hyperlinks: boolean;
|
|
400
|
+
}
|
|
401
|
+
interface CellDimensions {
|
|
402
|
+
widthPx: number;
|
|
403
|
+
heightPx: number;
|
|
404
|
+
}
|
|
405
|
+
interface ImageDimensions {
|
|
406
|
+
widthPx: number;
|
|
407
|
+
heightPx: number;
|
|
408
|
+
}
|
|
409
|
+
interface ImageRenderOptions {
|
|
410
|
+
maxWidthCells?: number;
|
|
411
|
+
maxHeightCells?: number;
|
|
412
|
+
preserveAspectRatio?: boolean;
|
|
413
|
+
imageId?: number;
|
|
414
|
+
}
|
|
415
|
+
declare function getCellDimensions(): CellDimensions;
|
|
416
|
+
declare function setCellDimensions(dims: CellDimensions): void;
|
|
417
|
+
declare function detectCapabilities(): TerminalCapabilities;
|
|
418
|
+
declare function getCapabilities(): TerminalCapabilities;
|
|
419
|
+
declare function resetCapabilitiesCache(): void;
|
|
420
|
+
declare function allocateImageId(): number;
|
|
421
|
+
declare function encodeKitty(base64Data: string, options?: {
|
|
422
|
+
columns?: number;
|
|
423
|
+
rows?: number;
|
|
424
|
+
imageId?: number;
|
|
425
|
+
}): string;
|
|
426
|
+
declare function deleteKittyImage(imageId: number): string;
|
|
427
|
+
declare function deleteAllKittyImages(): string;
|
|
428
|
+
declare function encodeITerm2(base64Data: string, options?: {
|
|
429
|
+
width?: number | string;
|
|
430
|
+
height?: number | string;
|
|
431
|
+
name?: string;
|
|
432
|
+
preserveAspectRatio?: boolean;
|
|
433
|
+
inline?: boolean;
|
|
434
|
+
}): string;
|
|
435
|
+
declare function calculateImageRows(imageDimensions: ImageDimensions, targetWidthCells: number, cellDimensions?: CellDimensions): number;
|
|
436
|
+
declare function getPngDimensions(base64Data: string): ImageDimensions | null;
|
|
437
|
+
declare function getJpegDimensions(base64Data: string): ImageDimensions | null;
|
|
438
|
+
declare function getGifDimensions(base64Data: string): ImageDimensions | null;
|
|
439
|
+
declare function getWebpDimensions(base64Data: string): ImageDimensions | null;
|
|
440
|
+
declare function getImageDimensions(base64Data: string, mimeType: string): ImageDimensions | null;
|
|
441
|
+
declare function renderImage(base64Data: string, imageDimensions: ImageDimensions, options?: ImageRenderOptions): {
|
|
442
|
+
sequence: string;
|
|
443
|
+
rows: number;
|
|
444
|
+
imageId?: number;
|
|
445
|
+
} | null;
|
|
446
|
+
declare function imageFallback(mimeType: string, dimensions?: ImageDimensions, filename?: string): string;
|
|
447
|
+
|
|
448
|
+
interface ImageTheme {
|
|
449
|
+
fallbackColor: (str: string) => string;
|
|
450
|
+
}
|
|
451
|
+
interface ImageOptions {
|
|
452
|
+
maxWidthCells?: number;
|
|
453
|
+
maxHeightCells?: number;
|
|
454
|
+
filename?: string;
|
|
455
|
+
imageId?: number;
|
|
456
|
+
}
|
|
457
|
+
declare class Image implements Component {
|
|
458
|
+
private base64Data;
|
|
459
|
+
private mimeType;
|
|
460
|
+
private dimensions;
|
|
461
|
+
private theme;
|
|
462
|
+
private options;
|
|
463
|
+
private imageId?;
|
|
464
|
+
private cachedLines?;
|
|
465
|
+
private cachedWidth?;
|
|
466
|
+
constructor(base64Data: string, mimeType: string, theme: ImageTheme, options?: ImageOptions, dimensions?: ImageDimensions);
|
|
467
|
+
getImageId(): number | undefined;
|
|
468
|
+
invalidate(): void;
|
|
469
|
+
render(width: number): string[];
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
declare class Input implements Component, Focusable {
|
|
473
|
+
private value;
|
|
474
|
+
private cursor;
|
|
475
|
+
onSubmit?: (value: string) => void;
|
|
476
|
+
onEscape?: () => void;
|
|
477
|
+
focused: boolean;
|
|
478
|
+
private pasteBuffer;
|
|
479
|
+
private isInPaste;
|
|
480
|
+
private killRing;
|
|
481
|
+
private lastAction;
|
|
482
|
+
private undoStack;
|
|
483
|
+
getValue(): string;
|
|
484
|
+
setValue(value: string): void;
|
|
485
|
+
handleInput(data: string): void;
|
|
486
|
+
private insertCharacter;
|
|
487
|
+
private handleBackspace;
|
|
488
|
+
private handleForwardDelete;
|
|
489
|
+
private deleteToLineStart;
|
|
490
|
+
private deleteToLineEnd;
|
|
491
|
+
private deleteWordBackwards;
|
|
492
|
+
private deleteWordForward;
|
|
493
|
+
private yank;
|
|
494
|
+
private yankPop;
|
|
495
|
+
private pushUndo;
|
|
496
|
+
private undo;
|
|
497
|
+
private moveWordBackwards;
|
|
498
|
+
private moveWordForwards;
|
|
499
|
+
private handlePaste;
|
|
500
|
+
invalidate(): void;
|
|
501
|
+
render(width: number): string[];
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
interface DefaultTextStyle {
|
|
505
|
+
color?: (text: string) => string;
|
|
506
|
+
bgColor?: (text: string) => string;
|
|
507
|
+
bold?: boolean;
|
|
508
|
+
italic?: boolean;
|
|
509
|
+
strikethrough?: boolean;
|
|
510
|
+
underline?: boolean;
|
|
511
|
+
}
|
|
512
|
+
interface MarkdownTheme {
|
|
513
|
+
heading: (text: string) => string;
|
|
514
|
+
link: (text: string) => string;
|
|
515
|
+
linkUrl: (text: string) => string;
|
|
516
|
+
code: (text: string) => string;
|
|
517
|
+
codeBlock: (text: string) => string;
|
|
518
|
+
codeBlockBorder: (text: string) => string;
|
|
519
|
+
quote: (text: string) => string;
|
|
520
|
+
quoteBorder: (text: string) => string;
|
|
521
|
+
hr: (text: string) => string;
|
|
522
|
+
listBullet: (text: string) => string;
|
|
523
|
+
bold: (text: string) => string;
|
|
524
|
+
italic: (text: string) => string;
|
|
525
|
+
strikethrough: (text: string) => string;
|
|
526
|
+
underline: (text: string) => string;
|
|
527
|
+
highlightCode?: (code: string, lang?: string) => string[];
|
|
528
|
+
codeBlockIndent?: string;
|
|
529
|
+
}
|
|
530
|
+
declare class Markdown implements Component {
|
|
531
|
+
private text;
|
|
532
|
+
private paddingX;
|
|
533
|
+
private paddingY;
|
|
534
|
+
private defaultTextStyle?;
|
|
535
|
+
private theme;
|
|
536
|
+
private defaultStylePrefix?;
|
|
537
|
+
private cachedText?;
|
|
538
|
+
private cachedWidth?;
|
|
539
|
+
private cachedLines?;
|
|
540
|
+
constructor(text: string, paddingX: number, paddingY: number, theme: MarkdownTheme, defaultTextStyle?: DefaultTextStyle);
|
|
541
|
+
setText(text: string): void;
|
|
542
|
+
invalidate(): void;
|
|
543
|
+
render(width: number): string[];
|
|
544
|
+
private applyDefaultStyle;
|
|
545
|
+
private getDefaultStylePrefix;
|
|
546
|
+
private getStylePrefix;
|
|
547
|
+
private getDefaultInlineStyleContext;
|
|
548
|
+
private renderToken;
|
|
549
|
+
private renderInlineTokens;
|
|
550
|
+
private renderList;
|
|
551
|
+
private renderListItem;
|
|
552
|
+
private getLongestWordWidth;
|
|
553
|
+
private wrapCellText;
|
|
554
|
+
private renderTable;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
interface SettingItem {
|
|
558
|
+
id: string;
|
|
559
|
+
label: string;
|
|
560
|
+
description?: string;
|
|
561
|
+
currentValue: string;
|
|
562
|
+
values?: string[];
|
|
563
|
+
submenu?: (currentValue: string, done: (selectedValue?: string) => void) => Component;
|
|
564
|
+
}
|
|
565
|
+
interface SettingsListTheme {
|
|
566
|
+
label: (text: string, selected: boolean) => string;
|
|
567
|
+
value: (text: string, selected: boolean) => string;
|
|
568
|
+
description: (text: string) => string;
|
|
569
|
+
cursor: string;
|
|
570
|
+
hint: (text: string) => string;
|
|
571
|
+
}
|
|
572
|
+
interface SettingsListOptions {
|
|
573
|
+
enableSearch?: boolean;
|
|
574
|
+
}
|
|
575
|
+
declare class SettingsList implements Component {
|
|
576
|
+
private items;
|
|
577
|
+
private filteredItems;
|
|
578
|
+
private theme;
|
|
579
|
+
private selectedIndex;
|
|
580
|
+
private maxVisible;
|
|
581
|
+
private onChange;
|
|
582
|
+
private onCancel;
|
|
583
|
+
private searchInput?;
|
|
584
|
+
private searchEnabled;
|
|
585
|
+
private submenuComponent;
|
|
586
|
+
private submenuItemIndex;
|
|
587
|
+
constructor(items: SettingItem[], maxVisible: number, theme: SettingsListTheme, onChange: (id: string, newValue: string) => void, onCancel: () => void, options?: SettingsListOptions);
|
|
588
|
+
updateValue(id: string, newValue: string): void;
|
|
589
|
+
invalidate(): void;
|
|
590
|
+
render(width: number): string[];
|
|
591
|
+
private renderMainList;
|
|
592
|
+
handleInput(data: string): void;
|
|
593
|
+
private activateItem;
|
|
594
|
+
private closeSubmenu;
|
|
595
|
+
private applyFilter;
|
|
596
|
+
private addHintLine;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
declare class Spacer implements Component {
|
|
600
|
+
private lines;
|
|
601
|
+
constructor(lines?: number);
|
|
602
|
+
setLines(lines: number): void;
|
|
603
|
+
invalidate(): void;
|
|
604
|
+
render(_width: number): string[];
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
declare class TruncatedText implements Component {
|
|
608
|
+
private text;
|
|
609
|
+
private paddingX;
|
|
610
|
+
private paddingY;
|
|
611
|
+
constructor(text: string, paddingX?: number, paddingY?: number);
|
|
612
|
+
invalidate(): void;
|
|
613
|
+
render(width: number): string[];
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
interface EditorComponent extends Component {
|
|
617
|
+
getText(): string;
|
|
618
|
+
setText(text: string): void;
|
|
619
|
+
handleInput(data: string): void;
|
|
620
|
+
onSubmit?: (text: string) => void;
|
|
621
|
+
onChange?: (text: string) => void;
|
|
622
|
+
addToHistory?(text: string): void;
|
|
623
|
+
insertTextAtCursor?(text: string): void;
|
|
624
|
+
getExpandedText?(): string;
|
|
625
|
+
setAutocompleteProvider?(provider: AutocompleteProvider): void;
|
|
626
|
+
borderColor?: (str: string) => string;
|
|
627
|
+
setPaddingX?(padding: number): void;
|
|
628
|
+
setAutocompleteMaxVisible?(maxVisible: number): void;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
interface FuzzyMatch {
|
|
632
|
+
matches: boolean;
|
|
633
|
+
score: number;
|
|
634
|
+
}
|
|
635
|
+
declare function fuzzyMatch(query: string, text: string): FuzzyMatch;
|
|
636
|
+
declare function fuzzyFilter<T>(items: T[], query: string, getText: (item: T) => string): T[];
|
|
637
|
+
|
|
638
|
+
declare function setKittyProtocolActive(active: boolean): void;
|
|
639
|
+
declare function isKittyProtocolActive(): boolean;
|
|
640
|
+
type Letter = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z';
|
|
641
|
+
type SymbolKey = '`' | '-' | '=' | '[' | ']' | '\\' | ';' | "'" | ',' | '.' | '/' | '!' | '@' | '#' | '$' | '%' | '^' | '&' | '*' | '(' | ')' | '_' | '+' | '|' | '~' | '{' | '}' | ':' | '<' | '>' | '?';
|
|
642
|
+
type SpecialKey = 'escape' | 'esc' | 'enter' | 'return' | 'tab' | 'space' | 'backspace' | 'delete' | 'insert' | 'clear' | 'home' | 'end' | 'pageUp' | 'pageDown' | 'up' | 'down' | 'left' | 'right' | 'f1' | 'f2' | 'f3' | 'f4' | 'f5' | 'f6' | 'f7' | 'f8' | 'f9' | 'f10' | 'f11' | 'f12';
|
|
643
|
+
type BaseKey = Letter | SymbolKey | SpecialKey;
|
|
644
|
+
type KeyId = BaseKey | `ctrl+${BaseKey}` | `shift+${BaseKey}` | `alt+${BaseKey}` | `ctrl+shift+${BaseKey}` | `shift+ctrl+${BaseKey}` | `ctrl+alt+${BaseKey}` | `alt+ctrl+${BaseKey}` | `shift+alt+${BaseKey}` | `alt+shift+${BaseKey}` | `ctrl+shift+alt+${BaseKey}` | `ctrl+alt+shift+${BaseKey}` | `shift+ctrl+alt+${BaseKey}` | `shift+alt+ctrl+${BaseKey}` | `alt+ctrl+shift+${BaseKey}` | `alt+shift+ctrl+${BaseKey}`;
|
|
645
|
+
declare const Key: {
|
|
646
|
+
readonly escape: "escape";
|
|
647
|
+
readonly esc: "esc";
|
|
648
|
+
readonly enter: "enter";
|
|
649
|
+
readonly return: "return";
|
|
650
|
+
readonly tab: "tab";
|
|
651
|
+
readonly space: "space";
|
|
652
|
+
readonly backspace: "backspace";
|
|
653
|
+
readonly delete: "delete";
|
|
654
|
+
readonly insert: "insert";
|
|
655
|
+
readonly clear: "clear";
|
|
656
|
+
readonly home: "home";
|
|
657
|
+
readonly end: "end";
|
|
658
|
+
readonly pageUp: "pageUp";
|
|
659
|
+
readonly pageDown: "pageDown";
|
|
660
|
+
readonly up: "up";
|
|
661
|
+
readonly down: "down";
|
|
662
|
+
readonly left: "left";
|
|
663
|
+
readonly right: "right";
|
|
664
|
+
readonly f1: "f1";
|
|
665
|
+
readonly f2: "f2";
|
|
666
|
+
readonly f3: "f3";
|
|
667
|
+
readonly f4: "f4";
|
|
668
|
+
readonly f5: "f5";
|
|
669
|
+
readonly f6: "f6";
|
|
670
|
+
readonly f7: "f7";
|
|
671
|
+
readonly f8: "f8";
|
|
672
|
+
readonly f9: "f9";
|
|
673
|
+
readonly f10: "f10";
|
|
674
|
+
readonly f11: "f11";
|
|
675
|
+
readonly f12: "f12";
|
|
676
|
+
readonly backtick: "`";
|
|
677
|
+
readonly hyphen: "-";
|
|
678
|
+
readonly equals: "=";
|
|
679
|
+
readonly leftbracket: "[";
|
|
680
|
+
readonly rightbracket: "]";
|
|
681
|
+
readonly backslash: "\\";
|
|
682
|
+
readonly semicolon: ";";
|
|
683
|
+
readonly quote: "'";
|
|
684
|
+
readonly comma: ",";
|
|
685
|
+
readonly period: ".";
|
|
686
|
+
readonly slash: "/";
|
|
687
|
+
readonly exclamation: "!";
|
|
688
|
+
readonly at: "@";
|
|
689
|
+
readonly hash: "#";
|
|
690
|
+
readonly dollar: "$";
|
|
691
|
+
readonly percent: "%";
|
|
692
|
+
readonly caret: "^";
|
|
693
|
+
readonly ampersand: "&";
|
|
694
|
+
readonly asterisk: "*";
|
|
695
|
+
readonly leftparen: "(";
|
|
696
|
+
readonly rightparen: ")";
|
|
697
|
+
readonly underscore: "_";
|
|
698
|
+
readonly plus: "+";
|
|
699
|
+
readonly pipe: "|";
|
|
700
|
+
readonly tilde: "~";
|
|
701
|
+
readonly leftbrace: "{";
|
|
702
|
+
readonly rightbrace: "}";
|
|
703
|
+
readonly colon: ":";
|
|
704
|
+
readonly lessthan: "<";
|
|
705
|
+
readonly greaterthan: ">";
|
|
706
|
+
readonly question: "?";
|
|
707
|
+
readonly ctrl: <K extends BaseKey>(key: K) => `ctrl+${K}`;
|
|
708
|
+
readonly shift: <K extends BaseKey>(key: K) => `shift+${K}`;
|
|
709
|
+
readonly alt: <K extends BaseKey>(key: K) => `alt+${K}`;
|
|
710
|
+
readonly ctrlShift: <K extends BaseKey>(key: K) => `ctrl+shift+${K}`;
|
|
711
|
+
readonly shiftCtrl: <K extends BaseKey>(key: K) => `shift+ctrl+${K}`;
|
|
712
|
+
readonly ctrlAlt: <K extends BaseKey>(key: K) => `ctrl+alt+${K}`;
|
|
713
|
+
readonly altCtrl: <K extends BaseKey>(key: K) => `alt+ctrl+${K}`;
|
|
714
|
+
readonly shiftAlt: <K extends BaseKey>(key: K) => `shift+alt+${K}`;
|
|
715
|
+
readonly altShift: <K extends BaseKey>(key: K) => `alt+shift+${K}`;
|
|
716
|
+
readonly ctrlShiftAlt: <K extends BaseKey>(key: K) => `ctrl+shift+alt+${K}`;
|
|
717
|
+
};
|
|
718
|
+
type KeyEventType = 'press' | 'repeat' | 'release';
|
|
719
|
+
declare function isKeyRelease(data: string): boolean;
|
|
720
|
+
declare function isKeyRepeat(data: string): boolean;
|
|
721
|
+
declare function matchesKey(data: string, keyId: KeyId): boolean;
|
|
722
|
+
declare function parseKey(data: string): string | undefined;
|
|
723
|
+
|
|
724
|
+
type EditorAction = 'cursorUp' | 'cursorDown' | 'cursorLeft' | 'cursorRight' | 'cursorWordLeft' | 'cursorWordRight' | 'cursorLineStart' | 'cursorLineEnd' | 'jumpForward' | 'jumpBackward' | 'pageUp' | 'pageDown' | 'deleteCharBackward' | 'deleteCharForward' | 'deleteWordBackward' | 'deleteWordForward' | 'deleteToLineStart' | 'deleteToLineEnd' | 'newLine' | 'submit' | 'tab' | 'selectUp' | 'selectDown' | 'selectPageUp' | 'selectPageDown' | 'selectConfirm' | 'selectCancel' | 'copy' | 'yank' | 'yankPop' | 'undo' | 'expandTools' | 'toggleSessionPath' | 'toggleSessionSort' | 'renameSession' | 'deleteSession' | 'deleteSessionNoninvasive';
|
|
725
|
+
|
|
726
|
+
type EditorKeybindingsConfig = {
|
|
727
|
+
[K in EditorAction]?: KeyId | KeyId[];
|
|
728
|
+
};
|
|
729
|
+
declare const DEFAULT_EDITOR_KEYBINDINGS: Required<EditorKeybindingsConfig>;
|
|
730
|
+
declare class EditorKeybindingsManager {
|
|
731
|
+
private actionToKeys;
|
|
732
|
+
constructor(config?: EditorKeybindingsConfig);
|
|
733
|
+
private buildMaps;
|
|
734
|
+
matches(data: string, action: EditorAction): boolean;
|
|
735
|
+
getKeys(action: EditorAction): KeyId[];
|
|
736
|
+
setConfig(config: EditorKeybindingsConfig): void;
|
|
737
|
+
}
|
|
738
|
+
declare function getEditorKeybindings(): EditorKeybindingsManager;
|
|
739
|
+
declare function setEditorKeybindings(manager: EditorKeybindingsManager): void;
|
|
740
|
+
|
|
741
|
+
type StdinBufferOptions = {
|
|
742
|
+
timeout?: number;
|
|
743
|
+
};
|
|
744
|
+
type StdinBufferEventMap = {
|
|
745
|
+
data: [string];
|
|
746
|
+
paste: [string];
|
|
747
|
+
};
|
|
748
|
+
declare class StdinBuffer extends EventEmitter<StdinBufferEventMap> {
|
|
749
|
+
private buffer;
|
|
750
|
+
private timeout;
|
|
751
|
+
private readonly timeoutMs;
|
|
752
|
+
private pasteMode;
|
|
753
|
+
private pasteBuffer;
|
|
754
|
+
constructor(options?: StdinBufferOptions);
|
|
755
|
+
process(data: string | Buffer): void;
|
|
756
|
+
flush(): string[];
|
|
757
|
+
clear(): void;
|
|
758
|
+
getBuffer(): string;
|
|
759
|
+
destroy(): void;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
export { type AutocompleteItem, type AutocompleteProvider, Box, CURSOR_MARKER, CancellableLoader, type CellDimensions, CombinedAutocompleteProvider, type Component, Container, DEFAULT_EDITOR_KEYBINDINGS, type DefaultTextStyle, Editor, type EditorAction, type EditorComponent, type EditorKeybindingsConfig, EditorKeybindingsManager, type EditorOptions, type EditorTheme, type Focusable, type FuzzyMatch, Image, type ImageDimensions, type ImageOptions, type ImageProtocol, type ImageRenderOptions, type ImageTheme, Input, Key, type KeyEventType, type KeyId, Loader, Markdown, type MarkdownTheme, type OverlayAnchor, type OverlayHandle, type OverlayMargin, type OverlayOptions, ProcessTerminal, type SelectItem, SelectList, type SelectListTheme, type SettingItem, SettingsList, type SettingsListTheme, type SizeValue, type SlashCommand, Spacer, StdinBuffer, type StdinBufferEventMap, type StdinBufferOptions, TUI, type Terminal, type TerminalCapabilities, Text, TruncatedText, allocateImageId, calculateImageRows, deleteAllKittyImages, deleteKittyImage, detectCapabilities, encodeITerm2, encodeKitty, fuzzyFilter, fuzzyMatch, getCapabilities, getCellDimensions, getEditorKeybindings, getGifDimensions, getImageDimensions, getJpegDimensions, getPngDimensions, getWebpDimensions, imageFallback, isFocusable, isKeyRelease, isKeyRepeat, isKittyProtocolActive, matchesKey, parseKey, renderImage, resetCapabilitiesCache, setCellDimensions, setEditorKeybindings, setKittyProtocolActive, sliceByColumn, truncateToWidth, visibleWidth, wrapTextWithAnsi };
|