@easbot/tui 0.3.29 → 0.3.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,22 +1,33 @@
1
- import { EventEmitter } from 'node:events';
1
+ import { EventEmitter } from 'events';
2
2
 
3
+ declare const FILE_ATTACHMENT_SYMBOL = "#";
4
+ declare const AGENT_ATTACHMENT_SYMBOL = "@";
5
+ declare const DEFAULT_ATTACHMENT_GLOB_PATTERN = "{dirs}/{wildcard}";
6
+ declare function extractFileAttachmentPrefix(text: string): string | null;
7
+ declare function extractAgentAttachmentPrefix(text: string): string | null;
3
8
  interface AutocompleteItem {
4
9
  value: string;
5
10
  label: string;
6
11
  description?: string;
12
+ group?: string;
7
13
  }
8
14
  type Awaitable<T> = T | Promise<T>;
9
15
  interface SlashCommand {
10
16
  name: string;
17
+ label?: string;
11
18
  description?: string;
12
19
  argumentHint?: string;
20
+ group?: string;
21
+ matchAlias?: string;
13
22
  getArgumentCompletions?(argumentPrefix: string): Awaitable<AutocompleteItem[] | null>;
14
23
  }
24
+ type SlashCommandSource = () => Awaitable<SlashCommand[]>;
15
25
  interface AutocompleteSuggestions {
16
26
  items: AutocompleteItem[];
17
27
  prefix: string;
18
28
  }
19
29
  interface AutocompleteProvider {
30
+ triggerCharacters?: string[];
20
31
  getSuggestions(lines: string[], cursorLine: number, cursorCol: number, options: {
21
32
  signal: AbortSignal;
22
33
  force?: boolean;
@@ -31,8 +42,15 @@ interface AutocompleteProvider {
31
42
  declare class CombinedAutocompleteProvider implements AutocompleteProvider {
32
43
  private commands;
33
44
  private basePath;
34
- private fdPath;
35
- constructor(commands: (SlashCommand | AutocompleteItem)[] | undefined, basePath: string, fdPath?: string | null);
45
+ private commandSource?;
46
+ private attachmentGlobPattern;
47
+ private attachmentWildcard;
48
+ constructor(commands: (SlashCommand | AutocompleteItem)[] | undefined, basePath: string, commandSource?: SlashCommandSource, options?: {
49
+ attachmentGlobPattern?: string;
50
+ attachmentWildcard?: string;
51
+ });
52
+ setCommands(commands: (SlashCommand | AutocompleteItem)[]): void;
53
+ private resolveCommands;
36
54
  getSuggestions(lines: string[], cursorLine: number, cursorCol: number, options: {
37
55
  signal: AbortSignal;
38
56
  force?: boolean;
@@ -42,18 +60,95 @@ declare class CombinedAutocompleteProvider implements AutocompleteProvider {
42
60
  cursorLine: number;
43
61
  cursorCol: number;
44
62
  };
45
- private extractAtPrefix;
46
- private extractHashPrefix;
63
+ private extractFilePrefix;
64
+ private extractAgentPrefix;
47
65
  private extractPathPrefix;
48
66
  private expandHomePath;
49
- private resolveScopedFuzzyQuery;
50
- private scopedPathForDisplay;
51
67
  private getFileSuggestions;
52
68
  private scoreEntry;
69
+ private getBaseDirSuggestions;
53
70
  private getFuzzyFileSuggestions;
54
71
  shouldTriggerFileCompletion(lines: string[], cursorLine: number, cursorCol: number): boolean;
55
72
  }
56
73
 
74
+ interface RgbColor {
75
+ r: number;
76
+ g: number;
77
+ b: number;
78
+ }
79
+ type TerminalColorScheme = 'dark' | 'light';
80
+ interface TerminalColors {
81
+ foreground?: RgbColor;
82
+ background?: RgbColor;
83
+ palette?: RgbColor[];
84
+ }
85
+ declare function parseTerminalColorSchemeReport(data: string): TerminalColorScheme | undefined;
86
+
87
+ interface IndexedColor {
88
+ readonly kind: 'indexed';
89
+ readonly index: number;
90
+ }
91
+ interface RgbColorValue {
92
+ readonly kind: 'rgb';
93
+ readonly r: number;
94
+ readonly g: number;
95
+ readonly b: number;
96
+ }
97
+ interface OklchColorValue {
98
+ readonly kind: 'oklch';
99
+ readonly l: number;
100
+ readonly c: number;
101
+ readonly h: number;
102
+ }
103
+ type Color = IndexedColor | RgbColorValue | OklchColorValue;
104
+ type TerminalColorMode = '256color' | 'truecolor';
105
+ type ColorMixSpace = 'oklch' | 'srgb';
106
+ interface OklchChannels {
107
+ l: number;
108
+ c: number;
109
+ h: number;
110
+ }
111
+ interface OkhslChannels {
112
+ h: number;
113
+ s: number;
114
+ l: number;
115
+ }
116
+ interface TextAttributes {
117
+ bold?: boolean;
118
+ dim?: boolean;
119
+ italic?: boolean;
120
+ underline?: boolean;
121
+ inverse?: boolean;
122
+ strikethrough?: boolean;
123
+ }
124
+ interface TextStyle extends TextAttributes {
125
+ fg?: Color;
126
+ bg?: Color;
127
+ }
128
+ declare function indexedColor(index: number): IndexedColor;
129
+ declare function rgbColor(r: number, g: number, b: number): RgbColorValue;
130
+ declare function oklchColor(l: number, c: number, h: number): OklchColorValue;
131
+ declare function okhslColor(h: number, s: number, l: number): RgbColorValue;
132
+ declare function colorToOkhsl(color: Color): OkhslChannels;
133
+ declare function parseColor(value: string | number): Color;
134
+ declare function colorToRgb(color: Color): RgbColor;
135
+ declare function colorToOklch(color: Color): OklchChannels;
136
+ declare function colorToHex(color: Color): string;
137
+ declare function mixColors(first: Color, second: Color, amount: number, space?: ColorMixSpace): Color;
138
+ declare function foregroundAnsi(color: Color, mode: TerminalColorMode): string;
139
+ declare function backgroundAnsi(color: Color, mode: TerminalColorMode): string;
140
+ declare function styleText(text: string, options: TextStyle, mode: TerminalColorMode): string;
141
+ declare function styleTextWithAnsi(text: string, fgAnsi: string | undefined, bgAnsi: string | undefined, options: TextAttributes): string;
142
+
143
+ interface ProgramStatus {
144
+ state: 'idle' | 'working' | 'blocked' | 'done' | 'error' | 'clear';
145
+ app?: string;
146
+ kind?: 'permission' | 'question' | 'auth';
147
+ message?: string;
148
+ }
149
+ declare function formatProgramStatus(status: ProgramStatus): string;
150
+
151
+ declare function isAppleTerminalSession(): boolean;
57
152
  interface Terminal {
58
153
  start(onInput: (data: string) => void, onResize: () => void): void;
59
154
  stop(): void;
@@ -70,6 +165,7 @@ interface Terminal {
70
165
  clearScreen(): void;
71
166
  setTitle(title: string): void;
72
167
  setProgress(active: boolean): void;
168
+ setProgramStatus(status: ProgramStatus): void;
73
169
  }
74
170
  declare class ProcessTerminal implements Terminal {
75
171
  private wasRaw;
@@ -77,14 +173,32 @@ declare class ProcessTerminal implements Terminal {
77
173
  private resizeHandler?;
78
174
  private _kittyProtocolActive;
79
175
  private _modifyOtherKeysActive;
176
+ private keyboardProtocolPushed;
177
+ private pendingKeyboardProtocolDeviceAttributes;
178
+ private keyboardProtocolNegotiationBuffer;
179
+ private keyboardProtocolBufferFlushTimer?;
80
180
  private stdinBuffer?;
81
181
  private stdinDataHandler?;
82
182
  private progressInterval?;
183
+ private programStatus?;
184
+ private programStatusSupported;
185
+ private programStatusQueryPending;
83
186
  private writeLogPath;
84
187
  get kittyProtocolActive(): boolean;
188
+ get modifyOtherKeysActive(): boolean;
85
189
  start(onInput: (data: string) => void, onResize: () => void): void;
86
190
  private setupStdinBuffer;
87
191
  private queryAndEnableKittyProtocol;
192
+ private handleKeyboardProtocolNegotiationSequence;
193
+ private readKeyboardProtocolNegotiationSequence;
194
+ private setKeyboardProtocolNegotiationBuffer;
195
+ private clearKeyboardProtocolNegotiationBuffer;
196
+ private flushKeyboardProtocolNegotiationBufferAsInput;
197
+ private scheduleKeyboardProtocolNegotiationBufferFlush;
198
+ private clearKeyboardProtocolNegotiationBufferFlushTimer;
199
+ private forwardInputSequence;
200
+ private enableModifyOtherKeys;
201
+ private disableModifyOtherKeys;
88
202
  private enableWindowsVTInput;
89
203
  drainInput(maxMs?: number, idleMs?: number): Promise<void>;
90
204
  stop(): void;
@@ -98,30 +212,72 @@ declare class ProcessTerminal implements Terminal {
98
212
  clearFromCursor(): void;
99
213
  clearScreen(): void;
100
214
  setTitle(title: string): void;
215
+ setProgramStatus(status: ProgramStatus): void;
216
+ private writeProgramStatus;
101
217
  setProgress(active: boolean): void;
102
218
  private clearProgressInterval;
103
219
  }
104
220
 
105
221
  declare function visibleWidth(str: string): number;
222
+ declare function stripTerminalSequences(str: string): string;
223
+ declare function getOsc8LinkAtColumn(line: string, column: number): string | undefined;
106
224
  declare function wrapTextWithAnsi(text: string, width: number): string[];
107
225
  declare function truncateToWidth(text: string, maxWidth: number, ellipsis?: string, pad?: boolean): string;
226
+ declare function sliceByColumn(line: string, startCol: number, length: number, strict?: boolean): string;
108
227
 
228
+ type TuiMouseEventType = 'press' | 'release' | 'move' | 'drag' | 'click' | 'wheel';
229
+ type TuiMouseButton = 'left' | 'middle' | 'right' | 'none';
230
+ interface TuiMouseEvent {
231
+ type: TuiMouseEventType;
232
+ button: TuiMouseButton;
233
+ x: number;
234
+ y: number;
235
+ screenX: number;
236
+ screenY: number;
237
+ width: number;
238
+ height: number;
239
+ shift: boolean;
240
+ alt: boolean;
241
+ ctrl: boolean;
242
+ wheelDelta?: number;
243
+ clickCount?: number;
244
+ }
245
+ interface TuiMouseEventResult {
246
+ handled?: boolean;
247
+ capture?: boolean;
248
+ focus?: boolean;
249
+ render?: boolean;
250
+ }
251
+ interface TuiMouseDispatchTarget {
252
+ component: Component;
253
+ originX: number;
254
+ originY: number;
255
+ width: number;
256
+ height: number;
257
+ }
258
+ interface TuiMouseDispatchResult extends TuiMouseEventResult {
259
+ handled: true;
260
+ target: TuiMouseDispatchTarget;
261
+ focusTarget?: Component;
262
+ }
109
263
  interface Component {
110
264
  render(width: number): string[];
111
265
  handleInput?(data: string): void;
266
+ handleMouse?(event: TuiMouseEvent): TuiMouseEventResult | undefined;
112
267
  wantsKeyRelease?: boolean;
113
268
  invalidate(): void;
114
269
  }
115
- type InputListenerResult = {
270
+ type TuiInputListenerResult = {
116
271
  consume?: boolean;
117
272
  data?: string;
118
273
  } | undefined;
119
- type InputListener = (data: string) => InputListenerResult;
274
+ type TuiInputListener = (data: string) => TuiInputListenerResult;
120
275
  interface Focusable {
121
276
  focused: boolean;
122
277
  }
123
278
  declare function isFocusable(component: Component | null): component is Component & Focusable;
124
279
  declare const CURSOR_MARKER = "\u001B_pi:c\u0007";
280
+ declare function renderFakeCursor(text: string): string;
125
281
 
126
282
  type OverlayAnchor = 'center' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'top-center' | 'bottom-center' | 'left-center' | 'right-center';
127
283
  interface OverlayMargin {
@@ -144,76 +300,169 @@ interface OverlayOptions {
144
300
  visible?: (termWidth: number, termHeight: number) => boolean;
145
301
  nonCapturing?: boolean;
146
302
  }
303
+ interface OverlayUnfocusOptions {
304
+ target: Component | null;
305
+ }
306
+ interface OverlayBounds {
307
+ row: number;
308
+ col: number;
309
+ width: number;
310
+ height: number;
311
+ }
147
312
  interface OverlayHandle {
148
313
  hide(): void;
149
314
  setHidden(hidden: boolean): void;
150
315
  isHidden(): boolean;
151
316
  focus(): void;
152
- unfocus(): void;
317
+ unfocus(options?: OverlayUnfocusOptions): void;
153
318
  isFocused(): boolean;
319
+ getBounds(): OverlayBounds | undefined;
154
320
  }
155
321
  declare class Container implements Component {
156
322
  children: Component[];
323
+ private mouseLayout?;
157
324
  addChild(component: Component): void;
158
325
  removeChild(component: Component): void;
159
326
  clear(): void;
160
327
  invalidate(): void;
328
+ handleMouse(event: TuiMouseEvent): TuiMouseDispatchResult | undefined;
161
329
  render(width: number): string[];
162
330
  }
163
- declare class TUI extends Container {
331
+ declare function compositeTuiLine(baseLine: string, overlayLine: string, startCol: number, overlayWidth: number, totalWidth: number): string;
332
+ type TuiMode = 'regular' | 'fullscreen';
333
+ interface TuiStopOptions {
334
+ preserveScreen?: boolean;
335
+ }
336
+ interface TUI extends Component {
337
+ readonly mode: TuiMode;
338
+ children: Component[];
339
+ terminal: Terminal;
340
+ onDebug?: () => void;
341
+ readonly fullRedraws: number;
342
+ addChild(component: Component): void;
343
+ removeChild(component: Component): void;
344
+ clear(): void;
345
+ getShowHardwareCursor(): boolean;
346
+ setShowHardwareCursor(enabled: boolean): void;
347
+ getClearOnShrink(): boolean;
348
+ setClearOnShrink(enabled: boolean): void;
349
+ setFocus(component: Component | null): void;
350
+ showOverlay(component: Component, options?: OverlayOptions): OverlayHandle;
351
+ hideOverlay(): void;
352
+ hasOverlay(): boolean;
353
+ start(): void;
354
+ stop(options?: TuiStopOptions): void;
355
+ renderNow(force?: boolean): void;
356
+ requestRender(force?: boolean): void;
357
+ addInputListener(listener: TuiInputListener): () => void;
358
+ removeInputListener(listener: TuiInputListener): void;
359
+ onTerminalColorSchemeChange(listener: (scheme: TerminalColorScheme) => void): () => void;
360
+ setTerminalColorSchemeNotifications(enabled: boolean): void;
361
+ queryTerminalColors(options: {
362
+ timeoutMs: number;
363
+ onLateReply?: (colors: TerminalColors) => void;
364
+ }): Promise<TerminalColors>;
365
+ }
366
+ declare const VIEWPORT_TUI: unique symbol;
367
+ interface ViewportTUI extends TUI {
368
+ readonly [VIEWPORT_TUI]: true;
369
+ setLayoutRoot(component: Component | undefined): void;
370
+ }
371
+ declare function isViewportTUI(tui: TUI): tui is ViewportTUI;
372
+ declare abstract class TuiBase extends Container implements TUI {
373
+ abstract readonly mode: TuiMode;
164
374
  terminal: Terminal;
165
- private previousLines;
166
- private previousWidth;
167
- private previousHeight;
168
375
  private focusedComponent;
169
376
  private inputListeners;
170
377
  onDebug?: () => void;
171
378
  private renderRequested;
379
+ private immediateRenderScheduled;
172
380
  private renderTimer;
173
381
  private lastRenderAt;
174
382
  private static readonly MIN_RENDER_INTERVAL_MS;
175
- private cursorRow;
176
- private hardwareCursorRow;
177
383
  private showHardwareCursor;
178
384
  private clearOnShrink;
179
- private maxLinesRendered;
180
- private previousViewportTop;
181
- private fullRedrawCount;
182
- private stopped;
385
+ protected fullRedrawCount: number;
386
+ protected stopped: boolean;
387
+ private pendingTerminalColorQueries;
388
+ private terminalColorSchemeListeners;
389
+ private terminalColorSchemeNotificationsEnabled;
390
+ protected readonly logDirectory: string | undefined;
183
391
  private focusOrderCounter;
184
392
  private overlayStack;
185
- constructor(terminal: Terminal, showHardwareCursor?: boolean);
393
+ private renderedOverlayLayouts;
394
+ get hasOverlayEntries(): boolean;
395
+ private overlayFocusRestore;
396
+ constructor(terminal: Terminal, showHardwareCursor?: boolean, logDirectory?: string);
397
+ protected abstract doRender(): void;
398
+ protected resetRenderState(): void;
399
+ protected beforeTerminalStart(): void;
400
+ protected afterTerminalStart(): void;
401
+ protected beforeTerminalStop(_options: TuiStopOptions): void;
402
+ protected afterTerminalStop(_options: TuiStopOptions): void;
186
403
  get fullRedraws(): number;
187
404
  getShowHardwareCursor(): boolean;
188
405
  setShowHardwareCursor(enabled: boolean): void;
189
406
  getClearOnShrink(): boolean;
190
407
  setClearOnShrink(enabled: boolean): void;
408
+ getFocusedComponent(): Component | null;
191
409
  setFocus(component: Component | null): void;
410
+ private setFocusInternal;
411
+ private clearOverlayFocusRestore;
412
+ private clearOverlayFocusRestoreFor;
413
+ private resolveBlockedOverlayFocusResume;
414
+ private getVisibleOverlayFocusRestore;
415
+ private isOverlayFocusAncestor;
416
+ private retargetOverlayPreFocus;
417
+ protected getMountedRoots(): readonly Component[];
418
+ private isComponentMounted;
419
+ private containsComponent;
192
420
  showOverlay(component: Component, options?: OverlayOptions): OverlayHandle;
193
421
  hideOverlay(): void;
422
+ private hideTerminalCursor;
194
423
  hasOverlay(): boolean;
424
+ protected isOverlayFocused(): boolean;
425
+ protected resolveMouseFocusTarget(component: Component): Component;
426
+ protected dispatchMouseToOverlay(event: TuiMouseEvent): {
427
+ hit: boolean;
428
+ result?: TuiMouseDispatchResult;
429
+ };
195
430
  private isOverlayVisible;
196
431
  private getTopmostVisibleOverlay;
197
432
  invalidate(): void;
198
433
  start(): void;
199
- addInputListener(listener: InputListener): () => void;
200
- removeInputListener(listener: InputListener): void;
434
+ addInputListener(listener: TuiInputListener): () => void;
435
+ removeInputListener(listener: TuiInputListener): void;
436
+ onTerminalColorSchemeChange(listener: (scheme: TerminalColorScheme) => void): () => void;
437
+ setTerminalColorSchemeNotifications(enabled: boolean): void;
201
438
  private queryCellSize;
202
- stop(): void;
439
+ stop(options?: TuiStopOptions): void;
440
+ renderNow(force?: boolean): void;
203
441
  requestRender(force?: boolean): void;
442
+ private requestImmediateRender;
443
+ private cancelRenderTimer;
204
444
  private scheduleRender;
205
- private handleInput;
445
+ private handleTerminalInput;
446
+ private consumeTerminalColorResponse;
447
+ private terminalColorQueryResult;
448
+ private completeTerminalColorQuery;
449
+ private consumeTerminalColorSchemeReport;
206
450
  private consumeCellSizeResponse;
207
451
  private resolveOverlayLayout;
208
452
  private resolveAnchorRow;
209
453
  private resolveAnchorCol;
210
- private compositeOverlays;
211
- private static readonly SEGMENT_RESET;
212
- private applyLineResets;
454
+ protected compositeOverlays(lines: string[], termWidth: number, termHeight: number): string[];
455
+ protected applyLineResets(lines: string[]): string[];
213
456
  private compositeLineAt;
214
- private extractCursorPosition;
215
- private doRender;
216
- private positionHardwareCursor;
457
+ protected extractCursorPosition(lines: string[], height: number): {
458
+ row: number;
459
+ col: number;
460
+ } | null;
461
+ protected resolveFakeCursors(lines: string[]): string[];
462
+ queryTerminalColors({ timeoutMs, onLateReply }: {
463
+ timeoutMs: number;
464
+ onLateReply?: (colors: TerminalColors) => void;
465
+ }): Promise<TerminalColors>;
217
466
  }
218
467
 
219
468
  declare class Box implements Component {
@@ -222,14 +471,17 @@ declare class Box implements Component {
222
471
  private paddingY;
223
472
  private bgFn?;
224
473
  private cache?;
474
+ private mouseLayout?;
225
475
  constructor(paddingX?: number, paddingY?: number, bgFn?: (text: string) => string);
226
476
  addChild(component: Component): void;
227
477
  removeChild(component: Component): void;
228
478
  clear(): void;
229
479
  setBgFn(bgFn?: (text: string) => string): void;
480
+ setPaddingX(paddingX: number): void;
230
481
  private invalidateCache;
231
482
  private matchCache;
232
483
  invalidate(): void;
484
+ handleMouse(event: TuiMouseEvent): TuiMouseDispatchResult | undefined;
233
485
  render(width: number): string[];
234
486
  private applyBg;
235
487
  }
@@ -245,6 +497,7 @@ declare class Text implements Component {
245
497
  constructor(text?: string, paddingX?: number, paddingY?: number, customBgFn?: (text: string) => string);
246
498
  setText(text: string): void;
247
499
  setCustomBgFn(customBgFn?: (text: string) => string): void;
500
+ setPaddingX(paddingX: number): void;
248
501
  invalidate(): void;
249
502
  render(width: number): string[];
250
503
  }
@@ -254,22 +507,24 @@ interface LoaderIndicatorOptions {
254
507
  intervalMs?: number;
255
508
  }
256
509
  declare class Loader extends Text {
257
- private spinnerColorFn;
258
- private messageColorFn;
259
- private message;
260
510
  private frames;
261
511
  private intervalMs;
262
512
  private currentFrame;
263
513
  private intervalId;
264
514
  private ui;
265
515
  private renderIndicatorVerbatim;
516
+ private spinnerColorFn;
517
+ private messageColorFn;
518
+ private message;
266
519
  constructor(ui: TUI, spinnerColorFn: (str: string) => string, messageColorFn: (str: string) => string, message?: string, indicator?: LoaderIndicatorOptions);
267
520
  render(width: number): string[];
268
521
  start(): void;
269
522
  stop(): void;
270
523
  setMessage(message: string): void;
524
+ invalidate(): void;
271
525
  setIndicator(indicator?: LoaderIndicatorOptions): void;
272
526
  private restartAnimation;
527
+ protected getRenderedIndicator(): string;
273
528
  private updateDisplay;
274
529
  }
275
530
 
@@ -286,6 +541,7 @@ interface SelectItem {
286
541
  value: string;
287
542
  label: string;
288
543
  description?: string;
544
+ group?: string;
289
545
  }
290
546
  interface SelectListTheme {
291
547
  selectedPrefix: (text: string) => string;
@@ -310,6 +566,7 @@ declare class SelectList implements Component {
310
566
  private items;
311
567
  private filteredItems;
312
568
  private selectedIndex;
569
+ private mousePressedIndex;
313
570
  private maxVisible;
314
571
  private theme;
315
572
  private layout;
@@ -321,7 +578,9 @@ declare class SelectList implements Component {
321
578
  setSelectedIndex(index: number): void;
322
579
  invalidate(): void;
323
580
  render(width: number): string[];
581
+ handleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined;
324
582
  handleInput(keyData: string): void;
583
+ private getVisibleRange;
325
584
  private renderItem;
326
585
  private getPrimaryColumnWidth;
327
586
  private getPrimaryColumnBounds;
@@ -346,9 +605,14 @@ declare class Editor implements Component, Focusable {
346
605
  private theme;
347
606
  private paddingX;
348
607
  private lastWidth;
608
+ private renderedVisibleLineCount;
609
+ private renderedAutocompleteHeight;
349
610
  private scrollOffset;
350
611
  borderColor: (str: string) => string;
351
612
  private autocompleteProvider?;
613
+ private autocompleteTriggerCharacters;
614
+ private autocompleteTriggerPattern;
615
+ private autocompleteDebouncePattern;
352
616
  private autocompleteList?;
353
617
  private autocompleteState;
354
618
  private autocompletePrefix;
@@ -364,6 +628,7 @@ declare class Editor implements Component, Focusable {
364
628
  private isInPaste;
365
629
  private history;
366
630
  private historyIndex;
631
+ private historyDraft;
367
632
  private killRing;
368
633
  private lastAction;
369
634
  private jumpMode;
@@ -373,6 +638,7 @@ declare class Editor implements Component, Focusable {
373
638
  onSubmit?: (text: string) => void;
374
639
  onChange?: (text: string) => void;
375
640
  disableSubmit: boolean;
641
+ shouldAutoSubmitSlashCommand?: (item: AutocompleteItem, prefix: string) => boolean;
376
642
  constructor(tui: TUI, theme: EditorTheme, options?: EditorOptions);
377
643
  private validPasteIds;
378
644
  private segment;
@@ -386,9 +652,13 @@ declare class Editor implements Component, Focusable {
386
652
  private isOnFirstVisualLine;
387
653
  private isOnLastVisualLine;
388
654
  private navigateHistory;
655
+ private exitHistoryBrowsing;
389
656
  private setTextInternal;
390
657
  invalidate(): void;
658
+ protected renderTopBorder(width: number, hiddenLineCount: number): string;
659
+ protected renderBottomBorder(width: number, hiddenLineCount: number): string;
391
660
  render(width: number): string[];
661
+ handleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined;
392
662
  handleInput(data: string): void;
393
663
  private layoutText;
394
664
  getText(): string;
@@ -444,6 +714,7 @@ declare class Editor implements Component, Focusable {
444
714
  private forceFileAutocomplete;
445
715
  private requestAutocomplete;
446
716
  private startAutocompleteRequest;
717
+ private setAutocompleteTriggerCharacters;
447
718
  private getAutocompleteDebounceMs;
448
719
  private runAutocompleteRequest;
449
720
  private isAutocompleteRequestCurrent;
@@ -455,6 +726,74 @@ declare class Editor implements Component, Focusable {
455
726
  private updateAutocomplete;
456
727
  }
457
728
 
729
+ declare const LAYOUT_NODE: unique symbol;
730
+ interface LayoutViewport {
731
+ width: number;
732
+ height: number;
733
+ }
734
+ interface StackLayoutEntry {
735
+ component: Component;
736
+ basis?: number | 'auto';
737
+ grow?: number;
738
+ shrink?: number;
739
+ minSize?: number;
740
+ maxSize?: number;
741
+ visible?: (viewport: LayoutViewport) => boolean;
742
+ }
743
+ interface StackLayoutNode {
744
+ type: 'vstack' | 'hstack';
745
+ entries: readonly StackLayoutEntry[];
746
+ gap: number;
747
+ align: 'stretch' | 'start' | 'center' | 'end';
748
+ }
749
+ interface ScrollLayoutState {
750
+ readonly scrollTop: number;
751
+ readonly primary: boolean;
752
+ readonly overscroll: 'chain' | 'contain';
753
+ readonly viewportHeight: number;
754
+ getContentWidth(width: number): number;
755
+ updateLayout(contentHeight: number, viewportHeight: number, requestRender: () => void): void;
756
+ }
757
+ interface ScrollLayoutNode {
758
+ type: 'scroll';
759
+ component: Component;
760
+ state: ScrollLayoutState;
761
+ }
762
+
763
+ interface StackEntryOptions {
764
+ basis?: number | 'auto';
765
+ grow?: number;
766
+ shrink?: number;
767
+ minSize?: number;
768
+ maxSize?: number;
769
+ visible?: (viewport: LayoutViewport) => boolean;
770
+ }
771
+ interface StackEntry extends StackEntryOptions {
772
+ component: Component;
773
+ }
774
+ type StackChild = Component | StackEntry;
775
+ interface StackOptions {
776
+ gap?: number;
777
+ align?: 'stretch' | 'start' | 'center' | 'end';
778
+ }
779
+ declare abstract class Stack extends Container {
780
+ protected readonly entries: StackLayoutEntry[];
781
+ protected readonly gap: number;
782
+ protected readonly align: 'stretch' | 'start' | 'center' | 'end';
783
+ protected abstract readonly layoutType: 'vstack' | 'hstack';
784
+ constructor(children?: StackChild[], options?: StackOptions);
785
+ addChild(component: Component, options?: StackEntryOptions): void;
786
+ removeChild(component: Component): void;
787
+ clear(): void;
788
+ [LAYOUT_NODE](): StackLayoutNode;
789
+ }
790
+
791
+ declare class HStack extends Stack {
792
+ protected readonly layoutType: "hstack";
793
+ constructor(children?: StackChild[], options?: StackOptions);
794
+ render(width: number): string[];
795
+ }
796
+
458
797
  type ImageProtocol = 'kitty' | 'iterm2' | null;
459
798
  interface TerminalCapabilities {
460
799
  images: ImageProtocol;
@@ -474,18 +813,22 @@ interface ImageRenderOptions {
474
813
  maxHeightCells?: number;
475
814
  preserveAspectRatio?: boolean;
476
815
  imageId?: number;
816
+ moveCursor?: boolean;
477
817
  }
478
818
  declare function getCellDimensions(): CellDimensions;
479
819
  declare function setCellDimensions(dims: CellDimensions): void;
480
- declare function detectCapabilities(): TerminalCapabilities;
820
+ declare function detectCapabilities(tmuxForwardsHyperlink?: () => boolean): TerminalCapabilities;
481
821
  declare function getCapabilities(): TerminalCapabilities;
822
+ declare function getTerminalColorMode(capabilities?: TerminalCapabilities): TerminalColorMode;
482
823
  declare function resetCapabilitiesCache(): void;
824
+ declare function setCapabilityOverrides(overrides: Partial<TerminalCapabilities>): void;
483
825
  declare function setCapabilities(caps: TerminalCapabilities): void;
484
826
  declare function allocateImageId(): number;
485
827
  declare function encodeKitty(base64Data: string, options?: {
486
828
  columns?: number;
487
829
  rows?: number;
488
830
  imageId?: number;
831
+ moveCursor?: boolean;
489
832
  }): string;
490
833
  declare function deleteKittyImage(imageId: number): string;
491
834
  declare function deleteAllKittyImages(): string;
@@ -504,12 +847,15 @@ declare function getWebpDimensions(base64Data: string): ImageDimensions | null;
504
847
  declare function getImageDimensions(base64Data: string, mimeType: string): ImageDimensions | null;
505
848
  declare function renderImage(base64Data: string, imageDimensions: ImageDimensions, options?: ImageRenderOptions): {
506
849
  sequence: string;
850
+ columns: number;
507
851
  rows: number;
508
852
  imageId?: number;
509
853
  } | null;
510
854
  declare function hyperlink(text: string, url: string): string;
511
855
  declare function imageFallback(mimeType: string, dimensions?: ImageDimensions, filename?: string): string;
512
856
 
857
+ type ImageTranscoder = (base64Data: string, mimeType: string) => string | null;
858
+ declare function setImageTranscoder(transcoder: ImageTranscoder | undefined): void;
513
859
  interface ImageTheme {
514
860
  fallbackColor: (str: string) => string;
515
861
  }
@@ -526,6 +872,7 @@ declare class Image implements Component {
526
872
  private theme;
527
873
  private options;
528
874
  private imageId?;
875
+ private pngData?;
529
876
  private cachedLines?;
530
877
  private cachedWidth?;
531
878
  constructor(base64Data: string, mimeType: string, theme: ImageTheme, options?: ImageOptions, dimensions?: ImageDimensions);
@@ -534,9 +881,18 @@ declare class Image implements Component {
534
881
  render(width: number): string[];
535
882
  }
536
883
 
884
+ interface InputOptions {
885
+ prompt?: string;
886
+ placeholder?: string;
887
+ placeholderStyle?: (text: string) => string;
888
+ }
537
889
  declare class Input implements Component, Focusable {
538
890
  private value;
539
891
  private cursor;
892
+ private readonly prompt;
893
+ private readonly placeholder;
894
+ private readonly placeholderStyle;
895
+ private renderedStartColumn;
540
896
  onSubmit?: (value: string) => void;
541
897
  onEscape?: () => void;
542
898
  focused: boolean;
@@ -545,9 +901,11 @@ declare class Input implements Component, Focusable {
545
901
  private killRing;
546
902
  private lastAction;
547
903
  private undoStack;
904
+ constructor(options?: InputOptions);
548
905
  getValue(): string;
549
906
  setValue(value: string): void;
550
907
  handleInput(data: string): void;
908
+ handleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined;
551
909
  private insertCharacter;
552
910
  private handleBackspace;
553
911
  private handleForwardDelete;
@@ -592,17 +950,25 @@ interface MarkdownTheme {
592
950
  highlightCode?: (code: string, lang?: string) => string[];
593
951
  codeBlockIndent?: string;
594
952
  }
953
+ interface MarkdownOptions {
954
+ preserveOrderedListMarkers?: boolean;
955
+ preserveBackslashEscapes?: boolean;
956
+ transform?: (markdown: string, availableWidth: number) => string;
957
+ renderLatex?: boolean;
958
+ }
595
959
  declare class Markdown implements Component {
596
960
  private text;
597
961
  private paddingX;
598
962
  private paddingY;
599
963
  private defaultTextStyle?;
600
964
  private theme;
965
+ private options;
601
966
  private defaultStylePrefix?;
602
967
  private cachedText?;
603
968
  private cachedWidth?;
604
969
  private cachedLines?;
605
- constructor(text: string, paddingX: number, paddingY: number, theme: MarkdownTheme, defaultTextStyle?: DefaultTextStyle);
970
+ private cachedTokens?;
971
+ constructor(text: string, paddingX: number, paddingY: number, theme: MarkdownTheme, defaultTextStyle?: DefaultTextStyle, options?: MarkdownOptions);
606
972
  setText(text: string): void;
607
973
  invalidate(): void;
608
974
  render(width: number): string[];
@@ -612,20 +978,89 @@ declare class Markdown implements Component {
612
978
  private getDefaultInlineStyleContext;
613
979
  private renderToken;
614
980
  private renderInlineTokens;
981
+ private getOrderedListMarker;
982
+ private getUnorderedListMarker;
615
983
  private renderList;
616
- private renderListItem;
617
984
  private getLongestWordWidth;
618
985
  private wrapCellText;
619
986
  private renderTable;
620
987
  }
621
988
 
989
+ type MouseRegionHandler = (event: TuiMouseEvent) => TuiMouseEventResult | undefined;
990
+ declare class MouseRegion implements Component {
991
+ private readonly child;
992
+ private readonly onMouse;
993
+ constructor(child: Component, onMouse: MouseRegionHandler);
994
+ render(width: number): string[];
995
+ handleMouse(event: TuiMouseEvent): TuiMouseDispatchResult | TuiMouseEventResult | undefined;
996
+ invalidate(): void;
997
+ }
998
+
999
+ type ScrollViewScrollbar = 'hidden' | 'auto' | 'always';
1000
+ interface ScrollViewOptions {
1001
+ axis?: 'vertical';
1002
+ follow?: 'none' | 'end';
1003
+ primary?: boolean;
1004
+ overscroll?: 'chain' | 'contain';
1005
+ scrollbar?: ScrollViewScrollbar;
1006
+ scrollbarTrackStyle?: (text: string) => string;
1007
+ scrollbarThumbStyle?: (text: string) => string;
1008
+ scrollbarHideDelayMs?: number;
1009
+ }
1010
+ interface ScrollViewScrollToOptions {
1011
+ disableFollow?: boolean;
1012
+ }
1013
+ declare class ScrollView extends Container {
1014
+ private readonly child;
1015
+ readonly followEnd: boolean;
1016
+ readonly primary: boolean;
1017
+ readonly overscroll: 'chain' | 'contain';
1018
+ readonly scrollbarTrackStyle: (text: string) => string;
1019
+ readonly scrollbarThumbStyle: (text: string) => string;
1020
+ private currentScrollbar;
1021
+ private readonly scrollbarHideDelayMs;
1022
+ private currentScrollTop;
1023
+ private contentHeight;
1024
+ private currentViewportHeight;
1025
+ private followingEnd;
1026
+ private followSuppressedAtEnd;
1027
+ private requestRenderCallback;
1028
+ private transientScrollbarVisible;
1029
+ private scrollbarActive;
1030
+ private scrollbarHideTimer;
1031
+ constructor(component: Component, options?: ScrollViewOptions);
1032
+ get scrollTop(): number;
1033
+ get isFollowingEnd(): boolean;
1034
+ get viewportHeight(): number;
1035
+ get scrollbar(): ScrollViewScrollbar;
1036
+ get isScrollbarVisible(): boolean;
1037
+ get isScrollbarActive(): boolean;
1038
+ setScrollbar(scrollbar: ScrollViewScrollbar): void;
1039
+ getContentWidth(width: number): number;
1040
+ private markScrollbarActivity;
1041
+ private hideTransientScrollbar;
1042
+ setScrollbarActive(active: boolean): void;
1043
+ scrollTo(scrollTop: number, options?: ScrollViewScrollToOptions): void;
1044
+ scrollBy(lines: number): number;
1045
+ scrollToStart(): void;
1046
+ scrollToEnd(): void;
1047
+ updateLayout(contentHeight: number, viewportHeight: number, requestRender: () => void): void;
1048
+ addChild(_component: Component): void;
1049
+ removeChild(_component: Component): void;
1050
+ clear(): void;
1051
+ render(width: number): string[];
1052
+ [LAYOUT_NODE](): ScrollLayoutNode;
1053
+ }
1054
+
622
1055
  interface SettingItem {
623
1056
  id: string;
624
1057
  label: string;
625
1058
  description?: string;
626
1059
  currentValue: string;
627
1060
  values?: string[];
628
- submenu?: (currentValue: string, done: (selectedValue?: string) => void) => Component;
1061
+ submenu?: (currentValue: string, done: (selectedValue?: string, options?: {
1062
+ navigateTo?: string;
1063
+ }) => void) => Component;
629
1064
  }
630
1065
  interface SettingsListTheme {
631
1066
  label: (text: string, selected: boolean) => string;
@@ -642,6 +1077,7 @@ declare class SettingsList implements Component {
642
1077
  private filteredItems;
643
1078
  private theme;
644
1079
  private selectedIndex;
1080
+ private mousePressedIndex;
645
1081
  private maxVisible;
646
1082
  private onChange;
647
1083
  private onCancel;
@@ -649,12 +1085,17 @@ declare class SettingsList implements Component {
649
1085
  private searchEnabled;
650
1086
  private submenuComponent;
651
1087
  private submenuItemIndex;
1088
+ private navigateAfterClose;
652
1089
  constructor(items: SettingItem[], maxVisible: number, theme: SettingsListTheme, onChange: (id: string, newValue: string) => void, onCancel: () => void, options?: SettingsListOptions);
653
1090
  updateValue(id: string, newValue: string): void;
1091
+ selectItem(id: string): void;
654
1092
  invalidate(): void;
655
1093
  render(width: number): string[];
656
1094
  private renderMainList;
1095
+ handleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined;
657
1096
  handleInput(data: string): void;
1097
+ private getDisplayItems;
1098
+ private getVisibleRange;
658
1099
  private activateItem;
659
1100
  private closeSubmenu;
660
1101
  private applyFilter;
@@ -678,6 +1119,12 @@ declare class TruncatedText implements Component {
678
1119
  render(width: number): string[];
679
1120
  }
680
1121
 
1122
+ declare class VStack extends Stack {
1123
+ protected readonly layoutType: "vstack";
1124
+ constructor(children?: StackChild[], options?: StackOptions);
1125
+ render(width: number): string[];
1126
+ }
1127
+
681
1128
  interface EditorComponent extends Component {
682
1129
  getText(): string;
683
1130
  setText(text: string): void;
@@ -803,6 +1250,8 @@ declare function decodeKittyPrintable(data: string): string | undefined;
803
1250
  interface Keybindings {
804
1251
  'tui.editor.cursorUp': true;
805
1252
  'tui.editor.cursorDown': true;
1253
+ 'tui.editor.historyPrevious': true;
1254
+ 'tui.editor.historyNext': true;
806
1255
  'tui.editor.cursorLeft': true;
807
1256
  'tui.editor.cursorRight': true;
808
1257
  'tui.editor.cursorWordLeft': true;
@@ -832,6 +1281,20 @@ interface Keybindings {
832
1281
  'tui.select.pageDown': true;
833
1282
  'tui.select.confirm': true;
834
1283
  'tui.select.cancel': true;
1284
+ 'tui.altScreen.pageUp': true;
1285
+ 'tui.altScreen.pageDown': true;
1286
+ 'tui.altScreen.halfPageUp': true;
1287
+ 'tui.altScreen.halfPageDown': true;
1288
+ 'tui.altScreen.lineUp': true;
1289
+ 'tui.altScreen.lineDown': true;
1290
+ 'tui.altScreen.previousPrompt': true;
1291
+ 'tui.altScreen.nextPrompt': true;
1292
+ 'tui.altScreen.search': true;
1293
+ 'tui.altScreen.searchNext': true;
1294
+ 'tui.altScreen.searchPrevious': true;
1295
+ 'tui.altScreen.searchClose': true;
1296
+ 'tui.altScreen.top': true;
1297
+ 'tui.altScreen.bottom': true;
835
1298
  }
836
1299
  type Keybinding = keyof Keybindings;
837
1300
  interface KeybindingDefinition {
@@ -849,6 +1312,14 @@ declare const TUI_KEYBINDINGS: {
849
1312
  readonly defaultKeys: "down";
850
1313
  readonly description: "Move cursor down";
851
1314
  };
1315
+ readonly 'tui.editor.historyPrevious': {
1316
+ readonly defaultKeys: [];
1317
+ readonly description: "Select previous prompt history entry";
1318
+ };
1319
+ readonly 'tui.editor.historyNext': {
1320
+ readonly defaultKeys: [];
1321
+ readonly description: "Select next prompt history entry";
1322
+ };
852
1323
  readonly 'tui.editor.cursorLeft': {
853
1324
  readonly defaultKeys: ["left", "ctrl+b"];
854
1325
  readonly description: "Move cursor left";
@@ -882,11 +1353,11 @@ declare const TUI_KEYBINDINGS: {
882
1353
  readonly description: "Jump backward to character";
883
1354
  };
884
1355
  readonly 'tui.editor.pageUp': {
885
- readonly defaultKeys: "pageUp";
1356
+ readonly defaultKeys: ["pageUp", "ctrl+pageUp"];
886
1357
  readonly description: "Page up";
887
1358
  };
888
1359
  readonly 'tui.editor.pageDown': {
889
- readonly defaultKeys: "pageDown";
1360
+ readonly defaultKeys: ["pageDown", "ctrl+pageDown"];
890
1361
  readonly description: "Page down";
891
1362
  };
892
1363
  readonly 'tui.editor.deleteCharBackward': {
@@ -926,7 +1397,7 @@ declare const TUI_KEYBINDINGS: {
926
1397
  readonly description: "Undo";
927
1398
  };
928
1399
  readonly 'tui.input.newLine': {
929
- readonly defaultKeys: "shift+enter";
1400
+ readonly defaultKeys: ["shift+enter", "ctrl+j"];
930
1401
  readonly description: "Insert newline";
931
1402
  };
932
1403
  readonly 'tui.input.submit': {
@@ -965,6 +1436,62 @@ declare const TUI_KEYBINDINGS: {
965
1436
  readonly defaultKeys: ["escape", "ctrl+c"];
966
1437
  readonly description: "Cancel selection";
967
1438
  };
1439
+ readonly 'tui.altScreen.pageUp': {
1440
+ readonly defaultKeys: "pageUp";
1441
+ readonly description: "Scroll viewport up one page";
1442
+ };
1443
+ readonly 'tui.altScreen.pageDown': {
1444
+ readonly defaultKeys: "pageDown";
1445
+ readonly description: "Scroll viewport down one page";
1446
+ };
1447
+ readonly 'tui.altScreen.halfPageUp': {
1448
+ readonly defaultKeys: [];
1449
+ readonly description: "Scroll viewport up half a page";
1450
+ };
1451
+ readonly 'tui.altScreen.halfPageDown': {
1452
+ readonly defaultKeys: [];
1453
+ readonly description: "Scroll viewport down half a page";
1454
+ };
1455
+ readonly 'tui.altScreen.lineUp': {
1456
+ readonly defaultKeys: [];
1457
+ readonly description: "Scroll viewport up one line";
1458
+ };
1459
+ readonly 'tui.altScreen.lineDown': {
1460
+ readonly defaultKeys: [];
1461
+ readonly description: "Scroll viewport down one line";
1462
+ };
1463
+ readonly 'tui.altScreen.previousPrompt': {
1464
+ readonly defaultKeys: ["ctrl+shift+up", "ctrl+up"];
1465
+ readonly description: "Jump to previous semantic prompt";
1466
+ };
1467
+ readonly 'tui.altScreen.nextPrompt': {
1468
+ readonly defaultKeys: ["ctrl+shift+down", "ctrl+down"];
1469
+ readonly description: "Jump to next semantic prompt";
1470
+ };
1471
+ readonly 'tui.altScreen.search': {
1472
+ readonly defaultKeys: "ctrl+shift+f";
1473
+ readonly description: "Search the primary scroll view";
1474
+ };
1475
+ readonly 'tui.altScreen.searchNext': {
1476
+ readonly defaultKeys: ["enter", "ctrl+g"];
1477
+ readonly description: "Select the next search match";
1478
+ };
1479
+ readonly 'tui.altScreen.searchPrevious': {
1480
+ readonly defaultKeys: ["shift+enter", "ctrl+shift+g"];
1481
+ readonly description: "Select the previous search match";
1482
+ };
1483
+ readonly 'tui.altScreen.searchClose': {
1484
+ readonly defaultKeys: "escape";
1485
+ readonly description: "Close transcript search";
1486
+ };
1487
+ readonly 'tui.altScreen.top': {
1488
+ readonly defaultKeys: "ctrl+home";
1489
+ readonly description: "Scroll viewport to top";
1490
+ };
1491
+ readonly 'tui.altScreen.bottom': {
1492
+ readonly defaultKeys: "ctrl+end";
1493
+ readonly description: "Scroll viewport to bottom";
1494
+ };
968
1495
  };
969
1496
  interface KeybindingConflict {
970
1497
  key: KeyId;
@@ -979,7 +1506,7 @@ declare class KeybindingsManager {
979
1506
  private rebuild;
980
1507
  matches(data: string, keybinding: Keybinding): boolean;
981
1508
  getKeys(keybinding: Keybinding): KeyId[];
982
- getDefinition(keybinding: Keybinding): KeybindingDefinition | undefined;
1509
+ getDefinition(keybinding: Keybinding): KeybindingDefinition;
983
1510
  getConflicts(): KeybindingConflict[];
984
1511
  setUserBindings(userBindings: KeybindingsConfig): void;
985
1512
  getUserBindings(): KeybindingsConfig;
@@ -988,8 +1515,60 @@ declare class KeybindingsManager {
988
1515
  declare function setKeybindings(keybindings: KeybindingsManager): void;
989
1516
  declare function getKeybindings(): KeybindingsManager;
990
1517
 
1518
+ interface RenderLatexOptions {
1519
+ display?: boolean;
1520
+ }
1521
+ declare function renderLatex(source: string, options?: RenderLatexOptions): string | undefined;
1522
+
1523
+ declare class MockTerminal implements Terminal {
1524
+ writes: string[];
1525
+ inputHandler?: (data: string) => void;
1526
+ resizeHandler?: () => void;
1527
+ programStatuses: ProgramStatus[];
1528
+ progressStates: boolean[];
1529
+ private _columns;
1530
+ private _rows;
1531
+ private _kittyActive;
1532
+ constructor(columns?: number, rows?: number);
1533
+ start(onInput: (data: string) => void, onResize: () => void): void;
1534
+ drainInput(_maxMs?: number, _idleMs?: number): Promise<void>;
1535
+ stop(): void;
1536
+ write(data: string): void;
1537
+ get columns(): number;
1538
+ get rows(): number;
1539
+ get kittyProtocolActive(): boolean;
1540
+ setColumns(columns: number): void;
1541
+ setRows(rows: number): void;
1542
+ feedInput(data: string): void;
1543
+ resize(columns: number, rows: number): void;
1544
+ moveBy(lines: number): void;
1545
+ hideCursor(): void;
1546
+ showCursor(): void;
1547
+ clearLine(): void;
1548
+ clearFromCursor(): void;
1549
+ clearScreen(): void;
1550
+ setTitle(title: string): void;
1551
+ setProgramStatus(status: ProgramStatus): void;
1552
+ setProgress(active: boolean): void;
1553
+ output(): string;
1554
+ }
1555
+
1556
+ type ModifierKey = 'shift' | 'command' | 'control' | 'option';
1557
+ interface NativeClipboard {
1558
+ getText(): Promise<string | null | undefined>;
1559
+ getImage(): Promise<Uint8Array | null | undefined>;
1560
+ getFilePaths?(): Promise<string[] | null | undefined>;
1561
+ setText?(text: string): Promise<void>;
1562
+ }
1563
+ declare function getNativeClipboard(): NativeClipboard | undefined;
1564
+
1565
+ declare function isNativeModifierPressed(key: ModifierKey): boolean;
1566
+
1567
+ declare const oklabToOkhslLightness: (x: number) => number;
1568
+
991
1569
  type StdinBufferOptions = {
992
1570
  timeout?: number;
1571
+ escapeTimeout?: number;
993
1572
  };
994
1573
  type StdinBufferEventMap = {
995
1574
  data: [string];
@@ -999,6 +1578,7 @@ declare class StdinBuffer extends EventEmitter<StdinBufferEventMap> {
999
1578
  private buffer;
1000
1579
  private timeout;
1001
1580
  private readonly timeoutMs;
1581
+ private readonly escapeTimeoutMs;
1002
1582
  private pasteMode;
1003
1583
  private pasteBuffer;
1004
1584
  private pendingKittyPrintableCodepoint;
@@ -1011,4 +1591,177 @@ declare class StdinBuffer extends EventEmitter<StdinBufferEventMap> {
1011
1591
  destroy(): void;
1012
1592
  }
1013
1593
 
1014
- export { type AutocompleteItem, type AutocompleteProvider, type AutocompleteSuggestions, Box, CURSOR_MARKER, CancellableLoader, type CellDimensions, CombinedAutocompleteProvider, type Component, Container, type DefaultTextStyle, Editor, type EditorComponent, 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, type Keybinding, type KeybindingConflict, type KeybindingDefinition, type KeybindingDefinitions, type Keybindings, type KeybindingsConfig, KeybindingsManager, Loader, type LoaderIndicatorOptions, Markdown, type MarkdownTheme, type OverlayAnchor, type OverlayHandle, type OverlayMargin, type OverlayOptions, ProcessTerminal, type SelectItem, SelectList, type SelectListLayoutOptions, type SelectListTheme, type SelectListTruncatePrimaryContext, type SettingItem, SettingsList, type SettingsListTheme, type SizeValue, type SlashCommand, Spacer, StdinBuffer, type StdinBufferEventMap, type StdinBufferOptions, TUI, TUI_KEYBINDINGS, type Terminal, type TerminalCapabilities, Text, TruncatedText, allocateImageId, calculateImageRows, decodeKittyPrintable, deleteAllKittyImages, deleteKittyImage, detectCapabilities, encodeITerm2, encodeKitty, fuzzyFilter, fuzzyMatch, getCapabilities, getCellDimensions, getGifDimensions, getImageDimensions, getJpegDimensions, getKeybindings, getPngDimensions, getWebpDimensions, hyperlink, imageFallback, isFocusable, isKeyRelease, isKeyRepeat, isKittyProtocolActive, matchesKey, parseKey, renderImage, resetCapabilitiesCache, setCapabilities, setCellDimensions, setKeybindings, setKittyProtocolActive, truncateToWidth, visibleWidth, wrapTextWithAnsi };
1594
+ type WheelScrollLines = number | 'auto';
1595
+
1596
+ interface TuiAltScreenOptions {
1597
+ wheelScrollLines?: WheelScrollLines;
1598
+ mouse?: boolean;
1599
+ searchMatchStyle?: (text: string) => string;
1600
+ searchCurrentMatchStyle?: (text: string) => string;
1601
+ searchNavigationButtonStyle?: (text: string, hovered: boolean) => string;
1602
+ scrollToEndIndicator?: () => string;
1603
+ openUrl?: (url: string) => void;
1604
+ onRightClickPaste?: () => void;
1605
+ copyOnSelect?: boolean;
1606
+ copySelection?: (text: string) => Promise<boolean | string>;
1607
+ }
1608
+ declare class TuiAltScreen extends TuiBase implements ViewportTUI {
1609
+ readonly mode: "fullscreen";
1610
+ readonly [VIEWPORT_TUI]: true;
1611
+ private previousScreen;
1612
+ private lastDocument;
1613
+ private previousScreenWidth;
1614
+ private previousScreenHeight;
1615
+ private layoutRoot;
1616
+ private currentLayout;
1617
+ private readonly implicitDocument;
1618
+ private readonly implicitScrollView;
1619
+ private readonly flashes;
1620
+ private altScreenActive;
1621
+ private imageProtocol;
1622
+ private savedCapabilities?;
1623
+ private readonly uploadedKittyImages;
1624
+ private selectionAnchor?;
1625
+ private selectionFocus?;
1626
+ private selectionGranularity;
1627
+ private selectionInitialRange?;
1628
+ private lastClick?;
1629
+ private selectionDragPointer?;
1630
+ private selectionAutoScrollDirection;
1631
+ private selectionAutoScrollTimer?;
1632
+ private selectionPressActive;
1633
+ private scrollbarDrag?;
1634
+ private scrollbarHover?;
1635
+ private scrollToEndIndicatorRect?;
1636
+ private activeSearch?;
1637
+ private pressedUrl?;
1638
+ private selectionDragged;
1639
+ private mouseCapture?;
1640
+ private mousePressTarget?;
1641
+ private mousePressPoint?;
1642
+ private mousePressMoved;
1643
+ private lastComponentClick?;
1644
+ private readonly wheelScroll;
1645
+ private readonly mouseEnabled;
1646
+ private readonly searchMatchStyle;
1647
+ private readonly searchCurrentMatchStyle;
1648
+ private readonly searchNavigationButtonStyle;
1649
+ private readonly scrollToEndIndicator?;
1650
+ private readonly openUrl?;
1651
+ private readonly onRightClickPaste?;
1652
+ private copyOnSelect;
1653
+ private readonly copySelection?;
1654
+ constructor(terminal: Terminal, showHardwareCursor?: boolean, logDirectory?: string, options?: TuiAltScreenOptions);
1655
+ get viewportTop(): number;
1656
+ get isFollowingOutput(): boolean;
1657
+ setWheelScrollLines(lines: WheelScrollLines): void;
1658
+ getCopyOnSelect(): boolean;
1659
+ setCopyOnSelect(enabled: boolean): void;
1660
+ hasActiveSelection(): boolean;
1661
+ copyActiveSelectionToClipboard(): Promise<boolean>;
1662
+ resetTextSelection(): void;
1663
+ getScreenLines(): string[];
1664
+ setLayoutRoot(component: Component | undefined): void;
1665
+ render(width: number): string[];
1666
+ protected getMountedRoots(): readonly Component[];
1667
+ private getPrimaryScrollView;
1668
+ protected beforeTerminalStart(): void;
1669
+ protected beforeTerminalStop(_options: TuiStopOptions): void;
1670
+ protected afterTerminalStop(options: TuiStopOptions): void;
1671
+ private deleteKittyImages;
1672
+ private prepareKittyScreen;
1673
+ protected resetRenderState(): void;
1674
+ scrollBy(lines: number): void;
1675
+ scrollToTop(): void;
1676
+ scrollToBottom(): void;
1677
+ private scrollToPrompt;
1678
+ private toggleSearch;
1679
+ private closeSearch;
1680
+ private updateSearchQuery;
1681
+ private navigateSearch;
1682
+ private getSearchNavigationDirectionAt;
1683
+ private handleSearchMouseEvent;
1684
+ private refreshSearch;
1685
+ flash(message: string, durationMs?: number): void;
1686
+ private shouldDeferViewportInputToOverlay;
1687
+ private clearComponentMouseGesture;
1688
+ private handleViewportInput;
1689
+ private decodeMouseButton;
1690
+ private createMouseEvent;
1691
+ private dispatchMouseToLayout;
1692
+ private applyMouseDispatchResult;
1693
+ private dispatchMouseToTarget;
1694
+ private getComponentClickCount;
1695
+ private clearTextSelection;
1696
+ private handleMouseEvent;
1697
+ private parseWheelEvent;
1698
+ private routeWheel;
1699
+ private parseSgrMouseEvent;
1700
+ private handleRightClickPaste;
1701
+ private handleScrollToEndIndicatorMouseEvent;
1702
+ private getScrollbarTargetAt;
1703
+ private setScrollbarHover;
1704
+ private updateScrollbarHover;
1705
+ private stopScrollbarHover;
1706
+ private scrollScrollbarToPointer;
1707
+ private handleScrollbarMouseEvent;
1708
+ private stopScrollbarDrag;
1709
+ private getScrollSelectionPoint;
1710
+ private getSelectionPoint;
1711
+ private getSelectionSourceLine;
1712
+ private getWordSelection;
1713
+ private getLineSelection;
1714
+ private updateSelectionFocus;
1715
+ private getClickCount;
1716
+ private updateSelectionAutoScroll;
1717
+ private autoScrollSelection;
1718
+ private stopSelectionAutoScroll;
1719
+ private handleSelectionMouseEvent;
1720
+ private getSelectionBounds;
1721
+ private getSelectionColumns;
1722
+ private getActiveSelectionText;
1723
+ private copySelectionToClipboard;
1724
+ private copyTextToClipboard;
1725
+ private applySearchTextHighlight;
1726
+ private applySearchHighlights;
1727
+ private applySelectionHighlight;
1728
+ private applySelection;
1729
+ private isMouseSequence;
1730
+ private compositeScrollToEndIndicator;
1731
+ private compositeFlashes;
1732
+ protected doRender(): void;
1733
+ }
1734
+
1735
+ interface TuiMainScreenRenderState {
1736
+ previousLines: string[];
1737
+ previousWidth: number;
1738
+ previousHeight: number;
1739
+ cursorRow: number;
1740
+ hardwareCursorRow: number;
1741
+ maxLinesRendered: number;
1742
+ previousViewportTop: number;
1743
+ }
1744
+ declare class TuiMainScreen extends TuiBase implements TUI {
1745
+ readonly mode: "regular";
1746
+ private previousLines;
1747
+ private previousKittyImageIds;
1748
+ private previousWidth;
1749
+ private previousHeight;
1750
+ private cursorRow;
1751
+ private hardwareCursorRow;
1752
+ private maxLinesRendered;
1753
+ private previousViewportTop;
1754
+ captureRenderState(): TuiMainScreenRenderState;
1755
+ restoreRenderState(state: TuiMainScreenRenderState): void;
1756
+ protected resetRenderState(): void;
1757
+ protected beforeTerminalStop(options: TuiStopOptions): void;
1758
+ private collectKittyImageIds;
1759
+ private deleteKittyImages;
1760
+ private getKittyImageReservedRows;
1761
+ private expandChangedRangeForKittyImages;
1762
+ private deleteChangedKittyImages;
1763
+ protected doRender(): void;
1764
+ private positionHardwareCursor;
1765
+ }
1766
+
1767
+ export { AGENT_ATTACHMENT_SYMBOL, type AutocompleteItem, type AutocompleteProvider, type AutocompleteSuggestions, Box, CURSOR_MARKER, CancellableLoader, type CellDimensions, type Color, type ColorMixSpace, CombinedAutocompleteProvider, type Component, Container, DEFAULT_ATTACHMENT_GLOB_PATTERN, type DefaultTextStyle, Editor, type EditorComponent, type EditorOptions, type EditorTheme, FILE_ATTACHMENT_SYMBOL, type Focusable, type FuzzyMatch, HStack, Image, type ImageDimensions, type ImageOptions, type ImageProtocol, type ImageRenderOptions, type ImageTheme, type ImageTranscoder, type IndexedColor, Input, Key, type KeyEventType, type KeyId, type Keybinding, type KeybindingConflict, type KeybindingDefinition, type KeybindingDefinitions, type Keybindings, type KeybindingsConfig, KeybindingsManager, Loader, type LoaderIndicatorOptions, Markdown, type MarkdownOptions, type MarkdownTheme, MockTerminal, type ModifierKey, MouseRegion, type MouseRegionHandler, type NativeClipboard, type OkhslChannels, type OklchChannels, type OklchColorValue, type OverlayAnchor, type OverlayBounds, type OverlayHandle, type OverlayMargin, type OverlayOptions, type OverlayUnfocusOptions, ProcessTerminal, type ProgramStatus, type RenderLatexOptions, type RgbColor, type RgbColorValue, ScrollView, type ScrollViewOptions, type ScrollViewScrollToOptions, type ScrollViewScrollbar, type SelectItem, SelectList, type SelectListLayoutOptions, type SelectListTheme, type SelectListTruncatePrimaryContext, type SettingItem, SettingsList, type SettingsListTheme, type SizeValue, type SlashCommand, type SlashCommandSource, Spacer, type StackChild, type StackEntry, type StackEntryOptions, type StackOptions, StdinBuffer, type StdinBufferEventMap, type StdinBufferOptions, type TUI, TUI_KEYBINDINGS, type Terminal, type TerminalCapabilities, type TerminalColorMode, type TerminalColorScheme, type TerminalColors, Text, type TextAttributes, type TextStyle, TruncatedText, TuiAltScreen, type TuiAltScreenOptions, type TuiInputListener, type TuiInputListenerResult, TuiMainScreen, type TuiMainScreenRenderState, type TuiMode, type TuiMouseButton, type TuiMouseEvent, type TuiMouseEventResult, type TuiMouseEventType, type TuiStopOptions, VStack, type ViewportTUI, type WheelScrollLines, allocateImageId, backgroundAnsi, calculateImageRows, colorToHex, colorToOkhsl, colorToOklch, colorToRgb, compositeTuiLine, decodeKittyPrintable, deleteAllKittyImages, deleteKittyImage, detectCapabilities, encodeITerm2, encodeKitty, extractAgentAttachmentPrefix, extractFileAttachmentPrefix, foregroundAnsi, formatProgramStatus, fuzzyFilter, fuzzyMatch, getCapabilities, getCellDimensions, getGifDimensions, getImageDimensions, getJpegDimensions, getKeybindings, getNativeClipboard, getOsc8LinkAtColumn, getPngDimensions, getTerminalColorMode, getWebpDimensions, hyperlink, imageFallback, indexedColor, isAppleTerminalSession, isFocusable, isKeyRelease, isKeyRepeat, isKittyProtocolActive, isNativeModifierPressed, isViewportTUI, matchesKey, mixColors, okhslColor, oklabToOkhslLightness, oklchColor, parseColor, parseKey, parseTerminalColorSchemeReport, renderFakeCursor, renderImage, renderLatex, resetCapabilitiesCache, rgbColor, setCapabilities, setCapabilityOverrides, setCellDimensions, setImageTranscoder, setKeybindings, setKittyProtocolActive, sliceByColumn, stripTerminalSequences, styleText, styleTextWithAnsi, truncateToWidth, visibleWidth, wrapTextWithAnsi };