@jpillora/ghostty-web 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2072 @@
1
+ export declare class CanvasRenderer {
2
+ private canvas;
3
+ private ctx;
4
+ private fontSize;
5
+ private fontFamily;
6
+ private cursorStyle;
7
+ private cursorBlink;
8
+ private theme;
9
+ private devicePixelRatio;
10
+ private metrics;
11
+ private palette;
12
+ private cursorVisible;
13
+ private cursorBlinkInterval?;
14
+ private lastCursorPosition;
15
+ private lastViewportY;
16
+ private currentBuffer;
17
+ private selectionManager?;
18
+ private currentSelectionCoords;
19
+ private hoveredHyperlinkId;
20
+ private previousHoveredHyperlinkId;
21
+ private hoveredLinkRange;
22
+ private previousHoveredLinkRange;
23
+ constructor(canvas: HTMLCanvasElement, options?: RendererOptions);
24
+ private measureFont;
25
+ /**
26
+ * Remeasure font metrics (call after font loads or changes)
27
+ */
28
+ remeasureFont(): void;
29
+ private rgbToCSS;
30
+ /**
31
+ * Resize canvas to fit terminal dimensions
32
+ */
33
+ resize(cols: number, rows: number): void;
34
+ /**
35
+ * Render the terminal buffer to canvas
36
+ */
37
+ render(buffer: IRenderable, forceAll?: boolean, viewportY?: number, scrollbackProvider?: IScrollbackProvider, scrollbarOpacity?: number): void;
38
+ /**
39
+ * Render a single line using two-pass approach:
40
+ * 1. First pass: Draw all cell backgrounds
41
+ * 2. Second pass: Draw all cell text and decorations
42
+ *
43
+ * This two-pass approach is necessary for proper rendering of complex scripts
44
+ * like Devanagari where diacritics (like vowel sign ि) can extend LEFT of the
45
+ * base character into the previous cell's visual area. If we draw backgrounds
46
+ * and text in a single pass (cell by cell), the background of cell N would
47
+ * cover any left-extending portions of graphemes from cell N-1.
48
+ */
49
+ private renderLine;
50
+ /**
51
+ * Render a cell's background only (Pass 1 of two-pass rendering)
52
+ * Selection highlighting is integrated here to avoid z-order issues with
53
+ * complex glyphs (like Devanagari) that extend outside their cell bounds.
54
+ */
55
+ private renderCellBackground;
56
+ /**
57
+ * Render a cell's text and decorations (Pass 2 of two-pass rendering)
58
+ * Selection foreground color is applied here to match the selection background.
59
+ */
60
+ private renderCellText;
61
+ /**
62
+ * Render cursor
63
+ */
64
+ private renderCursor;
65
+ private startCursorBlink;
66
+ private stopCursorBlink;
67
+ /**
68
+ * Update theme colors
69
+ */
70
+ setTheme(theme: ITheme): void;
71
+ /**
72
+ * Update font size
73
+ */
74
+ setFontSize(size: number): void;
75
+ /**
76
+ * Update font family
77
+ */
78
+ setFontFamily(family: string): void;
79
+ /**
80
+ * Update cursor style
81
+ */
82
+ setCursorStyle(style: 'block' | 'underline' | 'bar'): void;
83
+ /**
84
+ * Enable/disable cursor blinking
85
+ */
86
+ setCursorBlink(enabled: boolean): void;
87
+ /**
88
+ * Get current font metrics
89
+ */
90
+ /**
91
+ * Render scrollbar (Phase 2)
92
+ * Shows scroll position and allows click/drag interaction
93
+ * @param opacity Opacity level (0-1) for fade in/out effect
94
+ */
95
+ private renderScrollbar;
96
+ getMetrics(): FontMetrics;
97
+ /**
98
+ * Get canvas element (needed by SelectionManager)
99
+ */
100
+ getCanvas(): HTMLCanvasElement;
101
+ /**
102
+ * Set selection manager (for rendering selection)
103
+ */
104
+ setSelectionManager(manager: SelectionManager): void;
105
+ /**
106
+ * Check if a cell at (x, y) is within the current selection.
107
+ * Uses cached selection coordinates for performance.
108
+ */
109
+ private isInSelection;
110
+ /**
111
+ * Set the currently hovered hyperlink ID for rendering underlines
112
+ */
113
+ setHoveredHyperlinkId(hyperlinkId: number): void;
114
+ /**
115
+ * Set the currently hovered link range for rendering underlines (for regex-detected URLs)
116
+ * Pass null to clear the hover state
117
+ */
118
+ setHoveredLinkRange(range: {
119
+ startX: number;
120
+ startY: number;
121
+ endX: number;
122
+ endY: number;
123
+ } | null): void;
124
+ /**
125
+ * Get character cell width (for coordinate conversion)
126
+ */
127
+ get charWidth(): number;
128
+ /**
129
+ * Get character cell height (for coordinate conversion)
130
+ */
131
+ get charHeight(): number;
132
+ /**
133
+ * Clear entire canvas
134
+ */
135
+ clear(): void;
136
+ /**
137
+ * Cleanup resources
138
+ */
139
+ dispose(): void;
140
+ }
141
+
142
+ /**
143
+ * Cell style flags (bitfield)
144
+ */
145
+ export declare enum CellFlags {
146
+ BOLD = 1,
147
+ ITALIC = 2,
148
+ UNDERLINE = 4,
149
+ STRIKETHROUGH = 8,
150
+ INVERSE = 16,
151
+ INVISIBLE = 32,
152
+ BLINK = 64,
153
+ FAINT = 128
154
+ }
155
+
156
+ /**
157
+ * Cursor position and visibility
158
+ */
159
+ export declare interface Cursor {
160
+ x: number;
161
+ y: number;
162
+ visible: boolean;
163
+ }
164
+
165
+ /**
166
+ * Dirty state from RenderState
167
+ */
168
+ export declare enum DirtyState {
169
+ NONE = 0,
170
+ PARTIAL = 1,
171
+ FULL = 2
172
+ }
173
+
174
+ export declare class EventEmitter<T> {
175
+ private listeners;
176
+ fire(arg: T): void;
177
+ event: IEvent<T>;
178
+ dispose(): void;
179
+ }
180
+
181
+ export declare class FitAddon implements ITerminalAddon {
182
+ private _terminal?;
183
+ private _resizeObserver?;
184
+ private _resizeDebounceTimer?;
185
+ private _lastCols?;
186
+ private _lastRows?;
187
+ private _isResizing;
188
+ /**
189
+ * Activate the addon (called by Terminal.loadAddon)
190
+ */
191
+ activate(terminal: ITerminalCore): void;
192
+ /**
193
+ * Dispose the addon and clean up resources
194
+ */
195
+ dispose(): void;
196
+ /**
197
+ * Fit the terminal to its container
198
+ *
199
+ * Calculates optimal dimensions and resizes the terminal.
200
+ * Does nothing if dimensions cannot be calculated or haven't changed.
201
+ */
202
+ fit(): void;
203
+ /**
204
+ * Propose dimensions to fit the terminal to its container
205
+ *
206
+ * Calculates cols and rows based on:
207
+ * - Terminal container element dimensions (clientWidth/Height)
208
+ * - Terminal element padding
209
+ * - Font metrics (character cell size)
210
+ * - Scrollbar width reservation
211
+ *
212
+ * @returns Proposed dimensions or undefined if cannot calculate
213
+ */
214
+ proposeDimensions(): ITerminalDimensions | undefined;
215
+ /**
216
+ * Observe the terminal's container for resize events
217
+ *
218
+ * Sets up a ResizeObserver to automatically call fit() when the
219
+ * container size changes. Resize events are debounced to avoid
220
+ * excessive calls during window drag operations.
221
+ *
222
+ * Call dispose() to stop observing.
223
+ */
224
+ observeResize(): void;
225
+ }
226
+
227
+ export declare interface FontMetrics {
228
+ width: number;
229
+ height: number;
230
+ baseline: number;
231
+ }
232
+
233
+ /* Excluded from this release type: getGhostty */
234
+
235
+ /**
236
+ * Main Ghostty WASM wrapper class
237
+ */
238
+ export declare class Ghostty {
239
+ private exports;
240
+ private memory;
241
+ constructor(wasmInstance: WebAssembly.Instance);
242
+ createKeyEncoder(): KeyEncoder;
243
+ createTerminal(cols?: number, rows?: number, config?: GhosttyTerminalConfig): GhosttyTerminal;
244
+ /**
245
+ * Load a Ghostty instance (compile + instantiate).
246
+ * Each call creates a fully isolated WASM instance with its own memory.
247
+ */
248
+ static load(wasmPath?: string): Promise<Ghostty>;
249
+ /**
250
+ * Compile WASM bytes into a reusable module (expensive, do once).
251
+ * The compiled module can be instantiated multiple times via fromModule().
252
+ */
253
+ static compile(wasmPath?: string): Promise<WebAssembly.Module>;
254
+ /**
255
+ * Create a new Ghostty instance from a pre-compiled module (cheap, do per terminal).
256
+ * Each call returns an isolated instance with its own WASM memory.
257
+ */
258
+ static fromModule(module: WebAssembly.Module): Ghostty;
259
+ private static compileFromPath;
260
+ }
261
+
262
+ /**
263
+ * Cell structure matching ghostty_cell_t in C (16 bytes)
264
+ */
265
+ export declare interface GhosttyCell {
266
+ codepoint: number;
267
+ fg_r: number;
268
+ fg_g: number;
269
+ fg_b: number;
270
+ bg_r: number;
271
+ bg_g: number;
272
+ bg_b: number;
273
+ flags: number;
274
+ width: number;
275
+ hyperlink_id: number;
276
+ grapheme_len: number;
277
+ }
278
+
279
+ /**
280
+ * GhosttyTerminal - High-performance terminal emulator
281
+ *
282
+ * Uses Ghostty's native RenderState for optimal performance:
283
+ * - ONE call to update all state (renderStateUpdate)
284
+ * - ONE call to get all cells (getViewport)
285
+ * - No per-row WASM boundary crossings!
286
+ */
287
+ export declare class GhosttyTerminal {
288
+ private exports;
289
+ private memory;
290
+ private handle;
291
+ private _cols;
292
+ private _rows;
293
+ /** Size of GhosttyCell in WASM (16 bytes) */
294
+ private static readonly CELL_SIZE;
295
+ /** Reusable buffer for viewport operations */
296
+ private viewportBufferPtr;
297
+ private viewportBufferSize;
298
+ /** Cell pool for zero-allocation rendering */
299
+ private cellPool;
300
+ constructor(exports: GhosttyWasmExports, memory: WebAssembly.Memory, cols?: number, rows?: number, config?: GhosttyTerminalConfig);
301
+ get cols(): number;
302
+ get rows(): number;
303
+ write(data: string | Uint8Array): void;
304
+ resize(cols: number, rows: number): void;
305
+ free(): void;
306
+ /**
307
+ * Update render state from terminal.
308
+ *
309
+ * This syncs the RenderState with the current Terminal state.
310
+ * The dirty state (full/partial/none) is stored in the WASM RenderState
311
+ * and can be queried via isRowDirty(). When dirty==full, isRowDirty()
312
+ * returns true for ALL rows.
313
+ *
314
+ * The WASM layer automatically detects screen switches (normal <-> alternate)
315
+ * and returns FULL dirty state when switching screens (e.g., vim exit).
316
+ *
317
+ * Safe to call multiple times - dirty state persists until markClean().
318
+ */
319
+ update(): DirtyState;
320
+ /**
321
+ * Get cursor state from render state.
322
+ * Ensures render state is fresh by calling update().
323
+ */
324
+ getCursor(): RenderStateCursor;
325
+ /**
326
+ * Get default colors from render state
327
+ */
328
+ getColors(): RenderStateColors;
329
+ /**
330
+ * Check if a specific row is dirty
331
+ */
332
+ isRowDirty(y: number): boolean;
333
+ /**
334
+ * Mark render state as clean (call after rendering)
335
+ */
336
+ markClean(): void;
337
+ /**
338
+ * Get ALL viewport cells in ONE WASM call - the key performance optimization!
339
+ * Returns a reusable cell array (zero allocation after warmup).
340
+ */
341
+ getViewport(): GhosttyCell[];
342
+ /**
343
+ * Get line - for compatibility, extracts from viewport.
344
+ * Ensures render state is fresh by calling update().
345
+ * Returns a COPY of the cells to avoid pool reference issues.
346
+ */
347
+ getLine(y: number): GhosttyCell[] | null;
348
+ /** For compatibility with old API */
349
+ isDirty(): boolean;
350
+ /**
351
+ * Check if a full redraw is needed (screen change, resize, etc.)
352
+ * Note: This calls update() to ensure fresh state. Safe to call multiple times.
353
+ */
354
+ needsFullRedraw(): boolean;
355
+ /** Mark render state as clean after rendering */
356
+ clearDirty(): void;
357
+ isAlternateScreen(): boolean;
358
+ hasBracketedPaste(): boolean;
359
+ hasFocusEvents(): boolean;
360
+ hasMouseTracking(): boolean;
361
+ /** Get dimensions - for compatibility */
362
+ getDimensions(): {
363
+ cols: number;
364
+ rows: number;
365
+ };
366
+ /** Get number of scrollback lines (history, not including active screen) */
367
+ getScrollbackLength(): number;
368
+ /**
369
+ * Get a line from the scrollback buffer.
370
+ * Ensures render state is fresh by calling update().
371
+ * @param offset 0 = oldest line, (length-1) = most recent scrollback line
372
+ */
373
+ getScrollbackLine(offset: number): GhosttyCell[] | null;
374
+ /** Check if a row in the active screen is wrapped (soft-wrapped to next line) */
375
+ isRowWrapped(row: number): boolean;
376
+ /**
377
+ * Get the hyperlink URI for a cell at the given position.
378
+ * @param row Row index (0-based, in active viewport)
379
+ * @param col Column index (0-based)
380
+ * @returns The URI string, or null if no hyperlink at that position
381
+ */
382
+ getHyperlinkUri(row: number, col: number): string | null;
383
+ /**
384
+ * Get the hyperlink URI for a cell in the scrollback buffer.
385
+ * @param offset Scrollback line offset (0 = oldest, scrollback_len-1 = newest)
386
+ * @param col Column index (0-based)
387
+ * @returns The URI string, or null if no hyperlink at that position
388
+ */
389
+ getScrollbackHyperlinkUri(offset: number, col: number): string | null;
390
+ /**
391
+ * Check if there are pending responses from the terminal.
392
+ * Responses are generated by escape sequences like DSR (Device Status Report).
393
+ */
394
+ hasResponse(): boolean;
395
+ /**
396
+ * Read pending responses from the terminal.
397
+ * Returns the response string, or null if no responses pending.
398
+ *
399
+ * Responses are generated by escape sequences that require replies:
400
+ * - DSR 6 (cursor position): Returns \x1b[row;colR
401
+ * - DSR 5 (operating status): Returns \x1b[0n
402
+ */
403
+ readResponse(): string | null;
404
+ /**
405
+ * Query arbitrary terminal mode by number
406
+ * @param mode Mode number (e.g., 25 for cursor visibility, 2004 for bracketed paste)
407
+ * @param isAnsi True for ANSI modes, false for DEC modes (default: false)
408
+ */
409
+ getMode(mode: number, isAnsi?: boolean): boolean;
410
+ private initCellPool;
411
+ private parseCellsIntoPool;
412
+ /** Small buffer for grapheme lookups (reused to avoid allocation) */
413
+ private graphemeBuffer;
414
+ private graphemeBufferPtr;
415
+ /**
416
+ * Get all codepoints for a grapheme cluster at the given position.
417
+ * For most cells this returns a single codepoint, but for complex scripts
418
+ * (Hindi, emoji with ZWJ, etc.) it returns multiple codepoints.
419
+ * @returns Array of codepoints, or null on error
420
+ */
421
+ getGrapheme(row: number, col: number): number[] | null;
422
+ /**
423
+ * Get a string representation of the grapheme at the given position.
424
+ * This properly handles complex scripts like Hindi, emoji with ZWJ, etc.
425
+ */
426
+ getGraphemeString(row: number, col: number): string;
427
+ /**
428
+ * Get all codepoints for a grapheme cluster in the scrollback buffer.
429
+ * @param offset Scrollback line offset (0 = oldest)
430
+ * @param col Column index
431
+ * @returns Array of codepoints, or null on error
432
+ */
433
+ getScrollbackGrapheme(offset: number, col: number): number[] | null;
434
+ /**
435
+ * Get a string representation of a grapheme in the scrollback buffer.
436
+ */
437
+ getScrollbackGraphemeString(offset: number, col: number): string;
438
+ private invalidateBuffers;
439
+ }
440
+
441
+ /**
442
+ * Terminal configuration (passed to ghostty_terminal_new_with_config)
443
+ * All color values use 0xRRGGBB format. A value of 0 means "use default".
444
+ */
445
+ declare interface GhosttyTerminalConfig {
446
+ scrollbackLimit?: number;
447
+ fgColor?: number;
448
+ bgColor?: number;
449
+ cursorColor?: number;
450
+ palette?: number[];
451
+ }
452
+
453
+ /**
454
+ * Interface for libghostty-vt WASM exports
455
+ */
456
+ declare interface GhosttyWasmExports extends WebAssembly.Exports {
457
+ memory: WebAssembly.Memory;
458
+ ghostty_wasm_alloc_opaque(): number;
459
+ ghostty_wasm_free_opaque(ptr: number): void;
460
+ ghostty_wasm_alloc_u8_array(len: number): number;
461
+ ghostty_wasm_free_u8_array(ptr: number, len: number): void;
462
+ ghostty_wasm_alloc_u16_array(len: number): number;
463
+ ghostty_wasm_free_u16_array(ptr: number, len: number): void;
464
+ ghostty_wasm_alloc_u8(): number;
465
+ ghostty_wasm_free_u8(ptr: number): void;
466
+ ghostty_wasm_alloc_usize(): number;
467
+ ghostty_wasm_free_usize(ptr: number): void;
468
+ ghostty_sgr_new(allocator: number, parserPtrPtr: number): number;
469
+ ghostty_sgr_free(parser: number): void;
470
+ ghostty_sgr_reset(parser: number): void;
471
+ ghostty_sgr_set_params(parser: number, paramsPtr: number, subsPtr: number, paramsLen: number): number;
472
+ ghostty_sgr_next(parser: number, attrPtr: number): boolean;
473
+ ghostty_sgr_attribute_tag(attrPtr: number): number;
474
+ ghostty_sgr_attribute_value(attrPtr: number, tagPtr: number): number;
475
+ ghostty_wasm_alloc_sgr_attribute(): number;
476
+ ghostty_wasm_free_sgr_attribute(ptr: number): void;
477
+ ghostty_key_encoder_new(allocator: number, encoderPtrPtr: number): number;
478
+ ghostty_key_encoder_free(encoder: number): void;
479
+ ghostty_key_encoder_setopt(encoder: number, option: number, valuePtr: number): number;
480
+ ghostty_key_encoder_encode(encoder: number, eventPtr: number, bufPtr: number, bufLen: number, writtenPtr: number): number;
481
+ ghostty_key_event_new(allocator: number, eventPtrPtr: number): number;
482
+ ghostty_key_event_free(event: number): void;
483
+ ghostty_key_event_set_action(event: number, action: number): void;
484
+ ghostty_key_event_set_key(event: number, key: number): void;
485
+ ghostty_key_event_set_mods(event: number, mods: number): void;
486
+ ghostty_key_event_set_utf8(event: number, ptr: number, len: number): void;
487
+ ghostty_terminal_new(cols: number, rows: number): TerminalHandle;
488
+ ghostty_terminal_new_with_config(cols: number, rows: number, configPtr: number): TerminalHandle;
489
+ ghostty_terminal_free(terminal: TerminalHandle): void;
490
+ ghostty_terminal_resize(terminal: TerminalHandle, cols: number, rows: number): void;
491
+ ghostty_terminal_write(terminal: TerminalHandle, dataPtr: number, dataLen: number): void;
492
+ ghostty_render_state_update(terminal: TerminalHandle): number;
493
+ ghostty_render_state_get_cols(terminal: TerminalHandle): number;
494
+ ghostty_render_state_get_rows(terminal: TerminalHandle): number;
495
+ ghostty_render_state_get_cursor_x(terminal: TerminalHandle): number;
496
+ ghostty_render_state_get_cursor_y(terminal: TerminalHandle): number;
497
+ ghostty_render_state_get_cursor_visible(terminal: TerminalHandle): boolean;
498
+ ghostty_render_state_get_bg_color(terminal: TerminalHandle): number;
499
+ ghostty_render_state_get_fg_color(terminal: TerminalHandle): number;
500
+ ghostty_render_state_is_row_dirty(terminal: TerminalHandle, row: number): boolean;
501
+ ghostty_render_state_mark_clean(terminal: TerminalHandle): void;
502
+ ghostty_render_state_get_viewport(terminal: TerminalHandle, bufPtr: number, bufLen: number): number;
503
+ ghostty_render_state_get_grapheme(terminal: TerminalHandle, row: number, col: number, bufPtr: number, bufLen: number): number;
504
+ ghostty_terminal_is_alternate_screen(terminal: TerminalHandle): boolean;
505
+ ghostty_terminal_has_mouse_tracking(terminal: TerminalHandle): number;
506
+ ghostty_terminal_get_mode(terminal: TerminalHandle, mode: number, isAnsi: boolean): number;
507
+ ghostty_terminal_get_scrollback_length(terminal: TerminalHandle): number;
508
+ ghostty_terminal_get_scrollback_line(terminal: TerminalHandle, offset: number, bufPtr: number, bufLen: number): number;
509
+ ghostty_terminal_get_scrollback_grapheme(terminal: TerminalHandle, offset: number, col: number, bufPtr: number, bufLen: number): number;
510
+ ghostty_terminal_is_row_wrapped(terminal: TerminalHandle, row: number): number;
511
+ ghostty_terminal_get_hyperlink_uri(terminal: TerminalHandle, row: number, col: number, bufPtr: number, bufLen: number): number;
512
+ ghostty_terminal_get_scrollback_hyperlink_uri(terminal: TerminalHandle, offset: number, col: number, bufPtr: number, bufLen: number): number;
513
+ ghostty_terminal_has_response(terminal: TerminalHandle): boolean;
514
+ ghostty_terminal_read_response(terminal: TerminalHandle, bufPtr: number, bufLen: number): number;
515
+ }
516
+
517
+ /**
518
+ * A terminal buffer (normal or alternate screen)
519
+ */
520
+ declare interface IBuffer {
521
+ /** Buffer type: 'normal' or 'alternate' */
522
+ readonly type: 'normal' | 'alternate';
523
+ /** Cursor X position (0-indexed) */
524
+ readonly cursorX: number;
525
+ /** Cursor Y position (0-indexed, relative to viewport) */
526
+ readonly cursorY: number;
527
+ /** Viewport Y position (scroll offset, 0 = bottom of scrollback) */
528
+ readonly viewportY: number;
529
+ /** Base Y position (always 0 for normal buffer, may vary for alternate) */
530
+ readonly baseY: number;
531
+ /** Total buffer length (rows + scrollback for normal, just rows for alternate) */
532
+ readonly length: number;
533
+ /**
534
+ * Get a line from the buffer
535
+ * @param y Line index (0 = top of scrollback for normal buffer)
536
+ * @returns Line object or undefined if out of bounds
537
+ */
538
+ getLine(y: number): IBufferLine | undefined;
539
+ /**
540
+ * Get the null cell (used for empty/uninitialized cells)
541
+ */
542
+ getNullCell(): IBufferCell;
543
+ }
544
+
545
+ /**
546
+ * A single cell in the buffer
547
+ */
548
+ declare interface IBufferCell {
549
+ /** Character(s) in this cell (may be empty, single char, or emoji) */
550
+ getChars(): string;
551
+ /** Unicode codepoint (0 for null cell) */
552
+ getCode(): number;
553
+ /** Character width (1 = normal, 2 = wide/emoji, 0 = combining) */
554
+ getWidth(): number;
555
+ /** Foreground color index (for palette colors) or -1 for RGB */
556
+ getFgColorMode(): number;
557
+ /** Background color index (for palette colors) or -1 for RGB */
558
+ getBgColorMode(): number;
559
+ /** Foreground RGB color (or 0 for default) */
560
+ getFgColor(): number;
561
+ /** Background RGB color (or 0 for default) */
562
+ getBgColor(): number;
563
+ /** Whether cell has bold style */
564
+ isBold(): number;
565
+ /** Whether cell has italic style */
566
+ isItalic(): number;
567
+ /** Whether cell has underline style */
568
+ isUnderline(): number;
569
+ /** Whether cell has strikethrough style */
570
+ isStrikethrough(): number;
571
+ /** Whether cell has blink style */
572
+ isBlink(): number;
573
+ /** Whether cell has inverse video style */
574
+ isInverse(): number;
575
+ /** Whether cell has invisible style */
576
+ isInvisible(): number;
577
+ /** Whether cell has faint/dim style */
578
+ isFaint(): number;
579
+ /** Get hyperlink ID for this cell (0 = no link) */
580
+ getHyperlinkId(): number;
581
+ /** Get the Unicode codepoint for this cell */
582
+ getCodepoint(): number;
583
+ /** Whether cell has dim/faint attribute (boolean version) */
584
+ isDim(): boolean;
585
+ }
586
+
587
+ /**
588
+ * Represents a coordinate in the terminal buffer
589
+ */
590
+ export declare interface IBufferCellPosition {
591
+ x: number;
592
+ y: number;
593
+ }
594
+
595
+ /**
596
+ * A single line in the buffer
597
+ */
598
+ declare interface IBufferLine {
599
+ /** Length of the line (in columns) */
600
+ readonly length: number;
601
+ /** Whether this line wraps to the next line */
602
+ readonly isWrapped: boolean;
603
+ /**
604
+ * Get a cell from this line
605
+ * @param x Column index (0-indexed)
606
+ * @returns Cell object or undefined if out of bounds
607
+ */
608
+ getCell(x: number): IBufferCell | undefined;
609
+ /**
610
+ * Translate the line to a string
611
+ * @param trimRight Whether to trim trailing whitespace (default: false)
612
+ * @param startColumn Start column (default: 0)
613
+ * @param endColumn End column (default: length)
614
+ * @returns String representation of the line
615
+ */
616
+ translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string;
617
+ }
618
+
619
+ /**
620
+ * Minimal buffer line interface for URL detection
621
+ */
622
+ declare interface IBufferLineForUrlProvider {
623
+ length: number;
624
+ getCell(x: number): {
625
+ getCodepoint(): number;
626
+ } | undefined;
627
+ }
628
+
629
+ /**
630
+ * Top-level buffer API namespace
631
+ * Provides access to active, normal, and alternate screen buffers
632
+ */
633
+ declare interface IBufferNamespace {
634
+ /** The currently active buffer (normal or alternate) */
635
+ readonly active: IBuffer;
636
+ /** The normal buffer (primary screen) */
637
+ readonly normal: IBuffer;
638
+ /** The alternate buffer (used by full-screen apps like vim) */
639
+ readonly alternate: IBuffer;
640
+ /** Event fired when buffer changes (normal ↔ alternate) */
641
+ readonly onBufferChange: IEvent<IBuffer>;
642
+ }
643
+
644
+ /**
645
+ * Buffer range for selection coordinates
646
+ */
647
+ export declare interface IBufferRange {
648
+ start: {
649
+ x: number;
650
+ y: number;
651
+ };
652
+ end: {
653
+ x: number;
654
+ y: number;
655
+ };
656
+ }
657
+
658
+ /**
659
+ * Represents a range in the terminal buffer
660
+ * Can span multiple lines for wrapped links
661
+ */
662
+ declare interface IBufferRange_2 {
663
+ start: IBufferCellPosition;
664
+ end: IBufferCellPosition;
665
+ }
666
+
667
+ export declare interface IDisposable {
668
+ dispose(): void;
669
+ }
670
+
671
+ export declare type IEvent<T> = (listener: (arg: T) => void) => IDisposable;
672
+
673
+ /**
674
+ * Keyboard event with key and DOM event
675
+ */
676
+ export declare interface IKeyEvent {
677
+ key: string;
678
+ domEvent: KeyboardEvent;
679
+ }
680
+
681
+ /**
682
+ * Represents a detected link in the terminal
683
+ */
684
+ export declare interface ILink {
685
+ /** The URL or text of the link */
686
+ text: string;
687
+ /** The range of the link in the buffer (may span multiple lines) */
688
+ range: IBufferRange_2;
689
+ /** Called when the link is activated (clicked with modifier) */
690
+ activate(event: MouseEvent): void;
691
+ /** Optional: called when mouse enters/leaves the link */
692
+ hover?(isHovered: boolean): void;
693
+ /** Optional: called to clean up resources */
694
+ dispose?(): void;
695
+ }
696
+
697
+ /**
698
+ * Provides link detection for a specific type of link
699
+ * Examples: OSC 8 hyperlinks, URL regex detection
700
+ */
701
+ export declare interface ILinkProvider {
702
+ /**
703
+ * Provide links for a given row
704
+ * @param y Absolute row in buffer (0-based)
705
+ * @param callback Called with detected links (or undefined if none)
706
+ */
707
+ provideLinks(y: number, callback: (links: ILink[] | undefined) => void): void;
708
+ /** Optional: called when terminal is disposed */
709
+ dispose?(): void;
710
+ }
711
+
712
+ /**
713
+ * Initialize the ghostty-web library by compiling the WASM module.
714
+ * Must be called before creating any Terminal instances.
715
+ *
716
+ * The compiled module is cached and used to create isolated WASM instances
717
+ * for each Terminal (each gets its own memory space).
718
+ *
719
+ * @example
720
+ * ```typescript
721
+ * import { init, Terminal } from 'ghostty-web';
722
+ *
723
+ * await init();
724
+ * const term = new Terminal();
725
+ * term.open(document.getElementById('terminal'));
726
+ * ```
727
+ */
728
+ export declare function init(): Promise<void>;
729
+
730
+ export declare class InputHandler {
731
+ private encoder;
732
+ private container;
733
+ private inputElement?;
734
+ private onDataCallback;
735
+ private onBellCallback;
736
+ private onKeyCallback?;
737
+ private customKeyEventHandler?;
738
+ private getModeCallback?;
739
+ private onCopyCallback?;
740
+ private mouseConfig?;
741
+ private keydownListener;
742
+ private keypressListener;
743
+ private pasteListener;
744
+ private beforeInputListener;
745
+ private inputListener;
746
+ private compositionStartListener;
747
+ private compositionUpdateListener;
748
+ private compositionEndListener;
749
+ private mousedownListener;
750
+ private mouseupListener;
751
+ private mousemoveListener;
752
+ private wheelListener;
753
+ private isComposing;
754
+ private isDisposed;
755
+ private mouseButtonsPressed;
756
+ private lastKeyDownData;
757
+ private lastKeyDownTime;
758
+ private lastPasteData;
759
+ private lastPasteTime;
760
+ private lastPasteSource;
761
+ private lastCompositionData;
762
+ private lastCompositionTime;
763
+ private lastBeforeInputData;
764
+ private lastBeforeInputTime;
765
+ private static readonly BEFORE_INPUT_IGNORE_MS;
766
+ private dictationBuffer;
767
+ private dictationFlushed;
768
+ private dictationFlushTimer;
769
+ private static readonly DICTATION_FLUSH_MS;
770
+ /**
771
+ * Create a new InputHandler
772
+ * @param ghostty - Ghostty instance (for creating KeyEncoder)
773
+ * @param container - DOM element to attach listeners to
774
+ * @param onData - Callback for terminal data (escape sequences to send to PTY)
775
+ * @param onBell - Callback for bell/beep event
776
+ * @param onKey - Optional callback for raw key events
777
+ * @param customKeyEventHandler - Optional custom key event handler
778
+ * @param getMode - Optional callback to query terminal mode state (for application cursor mode)
779
+ * @param onCopy - Optional callback to handle copy (Cmd+C/Ctrl+C with selection)
780
+ * @param inputElement - Optional input element for beforeinput events
781
+ * @param mouseConfig - Optional mouse tracking configuration
782
+ */
783
+ constructor(ghostty: Ghostty, container: HTMLElement, onData: (data: string) => void, onBell: () => void, onKey?: (keyEvent: IKeyEvent) => void, customKeyEventHandler?: (event: KeyboardEvent) => boolean, getMode?: (mode: number) => boolean, onCopy?: () => boolean, inputElement?: HTMLElement, mouseConfig?: MouseTrackingConfig);
784
+ /**
785
+ * Set custom key event handler (for runtime updates)
786
+ */
787
+ setCustomKeyEventHandler(handler: (event: KeyboardEvent) => boolean): void;
788
+ /**
789
+ * Attach keyboard event listeners to container
790
+ */
791
+ private attach;
792
+ /**
793
+ * Map KeyboardEvent.code to USB HID Key enum value
794
+ * @param code - KeyboardEvent.code value
795
+ * @returns Key enum value or null if unmapped
796
+ */
797
+ private mapKeyCode;
798
+ /**
799
+ * Extract modifier flags from KeyboardEvent
800
+ * @param event - KeyboardEvent
801
+ * @returns Mods flags
802
+ */
803
+ private extractModifiers;
804
+ /**
805
+ * Check if this is a printable character with no special modifiers
806
+ * @param event - KeyboardEvent
807
+ * @returns true if printable character
808
+ */
809
+ private isPrintableCharacter;
810
+ /**
811
+ * Handle keydown event
812
+ * @param event - KeyboardEvent
813
+ */
814
+ private handleKeyDown;
815
+ /**
816
+ * Handle paste event from clipboard
817
+ * @param event - ClipboardEvent
818
+ */
819
+ private handlePaste;
820
+ /**
821
+ * Handle beforeinput event (mobile/IME input)
822
+ * @param event - InputEvent
823
+ */
824
+ private handleBeforeInput;
825
+ /**
826
+ * Handle input event on textarea (fallback for dictation, autofill, etc.)
827
+ * Catches text that was inserted into the textarea but not captured by
828
+ * beforeinput or composition handlers (e.g. iOS dictation with null event.data).
829
+ */
830
+ private handleInputEvent;
831
+ /**
832
+ * Buffer text from dictation-like input. Collects fragments and flushes
833
+ * after a short delay to handle iOS dictation's replace-partial pattern.
834
+ */
835
+ private bufferDictation;
836
+ /**
837
+ * Flush buffered dictation text to the terminal. If a previous partial
838
+ * was already flushed and the new buffer starts with it, only send the
839
+ * suffix (new text beyond what was already sent). This avoids duplication
840
+ * without needing backspace characters.
841
+ */
842
+ private flushDictation;
843
+ /**
844
+ * Reset dictation tracking state (called when non-dictation input occurs)
845
+ */
846
+ private resetDictation;
847
+ /**
848
+ * Handle compositionstart event
849
+ */
850
+ private handleCompositionStart;
851
+ /**
852
+ * Handle compositionupdate event
853
+ */
854
+ private handleCompositionUpdate;
855
+ /**
856
+ * Handle compositionend event
857
+ */
858
+ private handleCompositionEnd;
859
+ /**
860
+ * Cleanup text nodes in container after composition
861
+ */
862
+ private cleanupCompositionTextNodes;
863
+ /**
864
+ * Convert pixel coordinates to terminal cell coordinates
865
+ */
866
+ private pixelToCell;
867
+ /**
868
+ * Get modifier flags for mouse event
869
+ */
870
+ private getMouseModifiers;
871
+ /**
872
+ * Encode mouse event as SGR sequence
873
+ * SGR format: \x1b[<Btn;Col;RowM (press/motion) or \x1b[<Btn;Col;Rowm (release)
874
+ */
875
+ private encodeMouseSGR;
876
+ /**
877
+ * Encode mouse event as X10/normal sequence (legacy format)
878
+ * Format: \x1b[M<Btn+32><Col+32><Row+32>
879
+ */
880
+ private encodeMouseX10;
881
+ /**
882
+ * Send mouse event to terminal
883
+ */
884
+ private sendMouseEvent;
885
+ /**
886
+ * Handle mousedown event
887
+ */
888
+ private handleMouseDown;
889
+ /**
890
+ * Handle mouseup event
891
+ */
892
+ private handleMouseUp;
893
+ /**
894
+ * Handle mousemove event
895
+ */
896
+ private handleMouseMove;
897
+ /**
898
+ * Handle wheel event (scroll)
899
+ */
900
+ private handleWheel;
901
+ /**
902
+ * Emit paste data with bracketed paste support
903
+ */
904
+ private emitPasteData;
905
+ /**
906
+ * Record keydown data for beforeinput de-duplication
907
+ */
908
+ private recordKeyDownData;
909
+ /**
910
+ * Record paste data for beforeinput de-duplication
911
+ */
912
+ private recordPasteData;
913
+ /**
914
+ * Check if beforeinput should be ignored due to a recent keydown
915
+ */
916
+ private shouldIgnoreBeforeInput;
917
+ /**
918
+ * Check if beforeinput text should be ignored due to a recent composition end
919
+ */
920
+ private shouldIgnoreBeforeInputFromComposition;
921
+ /**
922
+ * Check if composition end should be ignored due to a recent beforeinput text
923
+ */
924
+ private shouldIgnoreCompositionEnd;
925
+ /**
926
+ * Record beforeinput text for composition de-duplication
927
+ */
928
+ private recordBeforeInputData;
929
+ /**
930
+ * Record composition end data for beforeinput de-duplication
931
+ */
932
+ private recordCompositionData;
933
+ /**
934
+ * Check if paste should be ignored due to a recent paste event from another source
935
+ */
936
+ private shouldIgnorePasteEvent;
937
+ /**
938
+ * Get current time in milliseconds
939
+ */
940
+ private getNow;
941
+ /**
942
+ * Dispose the InputHandler and remove event listeners
943
+ */
944
+ dispose(): void;
945
+ /**
946
+ * Check if handler is disposed
947
+ */
948
+ isActive(): boolean;
949
+ }
950
+
951
+ export declare interface IRenderable {
952
+ getLine(y: number): GhosttyCell[] | null;
953
+ getCursor(): {
954
+ x: number;
955
+ y: number;
956
+ visible: boolean;
957
+ };
958
+ getDimensions(): {
959
+ cols: number;
960
+ rows: number;
961
+ };
962
+ isRowDirty(y: number): boolean;
963
+ /** Returns true if a full redraw is needed (e.g., screen change) */
964
+ needsFullRedraw?(): boolean;
965
+ clearDirty(): void;
966
+ /**
967
+ * Get the full grapheme string for a cell at (row, col).
968
+ * For cells with grapheme_len > 0, this returns all codepoints combined.
969
+ * For simple cells, returns the single character.
970
+ */
971
+ getGraphemeString?(row: number, col: number): string;
972
+ }
973
+
974
+ declare interface IScrollbackProvider {
975
+ getScrollbackLine(offset: number): GhosttyCell[] | null;
976
+ getScrollbackLength(): number;
977
+ }
978
+
979
+ export declare interface ITerminalAddon {
980
+ activate(terminal: ITerminalCore): void;
981
+ dispose(): void;
982
+ }
983
+
984
+ export declare interface ITerminalCore {
985
+ cols: number;
986
+ rows: number;
987
+ element?: HTMLElement;
988
+ textarea?: HTMLTextAreaElement;
989
+ }
990
+
991
+ export declare interface ITerminalDimensions {
992
+ cols: number;
993
+ rows: number;
994
+ }
995
+
996
+ /**
997
+ * Minimal terminal interface required by LinkDetector
998
+ * Keeps coupling low and testing easy
999
+ */
1000
+ declare interface ITerminalForLinkDetector {
1001
+ buffer: {
1002
+ active: {
1003
+ getLine(y: number): {
1004
+ length: number;
1005
+ getCell(x: number): {
1006
+ getHyperlinkId(): number;
1007
+ } | undefined;
1008
+ } | undefined;
1009
+ };
1010
+ };
1011
+ }
1012
+
1013
+ /**
1014
+ * Minimal terminal interface required by OSC8LinkProvider
1015
+ */
1016
+ declare interface ITerminalForOSC8Provider {
1017
+ buffer: {
1018
+ active: {
1019
+ length: number;
1020
+ getLine(y: number): {
1021
+ length: number;
1022
+ getCell(x: number): {
1023
+ getHyperlinkId(): number;
1024
+ } | undefined;
1025
+ } | undefined;
1026
+ };
1027
+ };
1028
+ wasmTerm?: {
1029
+ getHyperlinkUri(row: number, col: number): string | null;
1030
+ getScrollbackHyperlinkUri(offset: number, col: number): string | null;
1031
+ getScrollbackLength(): number;
1032
+ };
1033
+ }
1034
+
1035
+ /**
1036
+ * Minimal terminal interface required by UrlRegexProvider
1037
+ */
1038
+ declare interface ITerminalForUrlProvider {
1039
+ buffer: {
1040
+ active: {
1041
+ getLine(y: number): IBufferLineForUrlProvider | undefined;
1042
+ };
1043
+ };
1044
+ }
1045
+
1046
+ export declare interface ITerminalOptions {
1047
+ cols?: number;
1048
+ rows?: number;
1049
+ cursorBlink?: boolean;
1050
+ cursorStyle?: 'block' | 'underline' | 'bar';
1051
+ theme?: ITheme;
1052
+ scrollback?: number;
1053
+ fontSize?: number;
1054
+ fontFamily?: string;
1055
+ allowTransparency?: boolean;
1056
+ convertEol?: boolean;
1057
+ disableStdin?: boolean;
1058
+ smoothScrollDuration?: number;
1059
+ ghostty?: Ghostty;
1060
+ }
1061
+
1062
+ export declare interface ITheme {
1063
+ foreground?: string;
1064
+ background?: string;
1065
+ cursor?: string;
1066
+ cursorAccent?: string;
1067
+ selectionBackground?: string;
1068
+ selectionForeground?: string;
1069
+ black?: string;
1070
+ red?: string;
1071
+ green?: string;
1072
+ yellow?: string;
1073
+ blue?: string;
1074
+ magenta?: string;
1075
+ cyan?: string;
1076
+ white?: string;
1077
+ brightBlack?: string;
1078
+ brightRed?: string;
1079
+ brightGreen?: string;
1080
+ brightYellow?: string;
1081
+ brightBlue?: string;
1082
+ brightMagenta?: string;
1083
+ brightCyan?: string;
1084
+ brightWhite?: string;
1085
+ }
1086
+
1087
+ /**
1088
+ * Unicode version provider (xterm.js compatibility)
1089
+ */
1090
+ export declare interface IUnicodeVersionProvider {
1091
+ readonly activeVersion: string;
1092
+ }
1093
+
1094
+ /**
1095
+ * Physical key codes matching Ghostty's internal Key enum.
1096
+ * These values are used by Ghostty's key encoder to produce correct escape sequences.
1097
+ * Reference: ghostty/src/input/key.zig
1098
+ */
1099
+ export declare enum Key {
1100
+ UNIDENTIFIED = 0,
1101
+ GRAVE = 1,// ` and ~
1102
+ BACKSLASH = 2,// \ and |
1103
+ BRACKET_LEFT = 3,// [ and {
1104
+ BRACKET_RIGHT = 4,// ] and }
1105
+ COMMA = 5,// , and <
1106
+ ZERO = 6,
1107
+ ONE = 7,
1108
+ TWO = 8,
1109
+ THREE = 9,
1110
+ FOUR = 10,
1111
+ FIVE = 11,
1112
+ SIX = 12,
1113
+ SEVEN = 13,
1114
+ EIGHT = 14,
1115
+ NINE = 15,
1116
+ EQUAL = 16,// = and +
1117
+ INTL_BACKSLASH = 17,
1118
+ INTL_RO = 18,
1119
+ INTL_YEN = 19,
1120
+ A = 20,
1121
+ B = 21,
1122
+ C = 22,
1123
+ D = 23,
1124
+ E = 24,
1125
+ F = 25,
1126
+ G = 26,
1127
+ H = 27,
1128
+ I = 28,
1129
+ J = 29,
1130
+ K = 30,
1131
+ L = 31,
1132
+ M = 32,
1133
+ N = 33,
1134
+ O = 34,
1135
+ P = 35,
1136
+ Q = 36,
1137
+ R = 37,
1138
+ S = 38,
1139
+ T = 39,
1140
+ U = 40,
1141
+ V = 41,
1142
+ W = 42,
1143
+ X = 43,
1144
+ Y = 44,
1145
+ Z = 45,
1146
+ MINUS = 46,// - and _
1147
+ PERIOD = 47,// . and >
1148
+ QUOTE = 48,// ' and "
1149
+ SEMICOLON = 49,// ; and :
1150
+ SLASH = 50,// / and ?
1151
+ ALT_LEFT = 51,
1152
+ ALT_RIGHT = 52,
1153
+ BACKSPACE = 53,
1154
+ CAPS_LOCK = 54,
1155
+ CONTEXT_MENU = 55,
1156
+ CONTROL_LEFT = 56,
1157
+ CONTROL_RIGHT = 57,
1158
+ ENTER = 58,
1159
+ META_LEFT = 59,
1160
+ META_RIGHT = 60,
1161
+ SHIFT_LEFT = 61,
1162
+ SHIFT_RIGHT = 62,
1163
+ SPACE = 63,
1164
+ TAB = 64,
1165
+ CONVERT = 65,
1166
+ KANA_MODE = 66,
1167
+ NON_CONVERT = 67,
1168
+ DELETE = 68,
1169
+ END = 69,
1170
+ HELP = 70,
1171
+ HOME = 71,
1172
+ INSERT = 72,
1173
+ PAGE_DOWN = 73,
1174
+ PAGE_UP = 74,
1175
+ DOWN = 75,
1176
+ LEFT = 76,
1177
+ RIGHT = 77,
1178
+ UP = 78,
1179
+ NUM_LOCK = 79,
1180
+ KP_0 = 80,
1181
+ KP_1 = 81,
1182
+ KP_2 = 82,
1183
+ KP_3 = 83,
1184
+ KP_4 = 84,
1185
+ KP_5 = 85,
1186
+ KP_6 = 86,
1187
+ KP_7 = 87,
1188
+ KP_8 = 88,
1189
+ KP_9 = 89,
1190
+ KP_PLUS = 90,// Keypad +
1191
+ KP_BACKSPACE = 91,
1192
+ KP_CLEAR = 92,
1193
+ KP_CLEAR_ENTRY = 93,
1194
+ KP_COMMA = 94,
1195
+ KP_PERIOD = 95,// Keypad .
1196
+ KP_DIVIDE = 96,// Keypad /
1197
+ KP_ENTER = 97,// Keypad Enter
1198
+ KP_EQUAL = 98,
1199
+ KP_MEMORY_ADD = 99,
1200
+ KP_MEMORY_CLEAR = 100,
1201
+ KP_MEMORY_RECALL = 101,
1202
+ KP_MEMORY_STORE = 102,
1203
+ KP_MEMORY_SUBTRACT = 103,
1204
+ KP_MULTIPLY = 104,// Keypad *
1205
+ KP_PAREN_LEFT = 105,
1206
+ KP_PAREN_RIGHT = 106,
1207
+ KP_MINUS = 107,// Keypad -
1208
+ KP_SEPARATOR = 108,
1209
+ NUMPAD_UP = 109,
1210
+ NUMPAD_DOWN = 110,
1211
+ NUMPAD_RIGHT = 111,
1212
+ NUMPAD_LEFT = 112,
1213
+ NUMPAD_BEGIN = 113,
1214
+ NUMPAD_HOME = 114,
1215
+ NUMPAD_END = 115,
1216
+ NUMPAD_INSERT = 116,
1217
+ NUMPAD_DELETE = 117,
1218
+ NUMPAD_PAGE_UP = 118,
1219
+ NUMPAD_PAGE_DOWN = 119,
1220
+ ESCAPE = 120,
1221
+ F1 = 121,
1222
+ F2 = 122,
1223
+ F3 = 123,
1224
+ F4 = 124,
1225
+ F5 = 125,
1226
+ F6 = 126,
1227
+ F7 = 127,
1228
+ F8 = 128,
1229
+ F9 = 129,
1230
+ F10 = 130,
1231
+ F11 = 131,
1232
+ F12 = 132,
1233
+ F13 = 133,
1234
+ F14 = 134,
1235
+ F15 = 135,
1236
+ F16 = 136,
1237
+ F17 = 137,
1238
+ F18 = 138,
1239
+ F19 = 139,
1240
+ F20 = 140,
1241
+ F21 = 141,
1242
+ F22 = 142,
1243
+ F23 = 143,
1244
+ F24 = 144,
1245
+ F25 = 145,
1246
+ FN_LOCK = 146,
1247
+ PRINT_SCREEN = 147,
1248
+ SCROLL_LOCK = 148,
1249
+ PAUSE = 149,
1250
+ BROWSER_BACK = 150,
1251
+ BROWSER_FAVORITES = 151,
1252
+ BROWSER_FORWARD = 152,
1253
+ BROWSER_HOME = 153,
1254
+ BROWSER_REFRESH = 154,
1255
+ BROWSER_SEARCH = 155,
1256
+ BROWSER_STOP = 156,
1257
+ EJECT = 157,
1258
+ LAUNCH_APP_1 = 158,
1259
+ LAUNCH_APP_2 = 159,
1260
+ LAUNCH_MAIL = 160,
1261
+ MEDIA_PLAY_PAUSE = 161,
1262
+ MEDIA_SELECT = 162,
1263
+ MEDIA_STOP = 163,
1264
+ MEDIA_TRACK_NEXT = 164,
1265
+ MEDIA_TRACK_PREVIOUS = 165,
1266
+ POWER = 166,
1267
+ SLEEP = 167,
1268
+ AUDIO_VOLUME_DOWN = 168,
1269
+ AUDIO_VOLUME_MUTE = 169,
1270
+ AUDIO_VOLUME_UP = 170,
1271
+ WAKE_UP = 171,
1272
+ COPY = 172,
1273
+ CUT = 173,
1274
+ PASTE = 174
1275
+ }
1276
+
1277
+ /**
1278
+ * Key action
1279
+ */
1280
+ export declare enum KeyAction {
1281
+ RELEASE = 0,
1282
+ PRESS = 1,
1283
+ REPEAT = 2
1284
+ }
1285
+
1286
+ /**
1287
+ * Key Encoder - converts keyboard events into terminal escape sequences
1288
+ */
1289
+ export declare class KeyEncoder {
1290
+ private exports;
1291
+ private encoder;
1292
+ constructor(exports: GhosttyWasmExports);
1293
+ setOption(option: KeyEncoderOption, value: boolean | number): void;
1294
+ setKittyFlags(flags: KittyKeyFlags): void;
1295
+ encode(event: KeyEvent): Uint8Array;
1296
+ dispose(): void;
1297
+ }
1298
+
1299
+ /**
1300
+ * Key encoder options
1301
+ */
1302
+ export declare enum KeyEncoderOption {
1303
+ CURSOR_KEY_APPLICATION = 0,// DEC mode 1
1304
+ KEYPAD_KEY_APPLICATION = 1,// DEC mode 66
1305
+ IGNORE_KEYPAD_WITH_NUMLOCK = 2,// DEC mode 1035
1306
+ ALT_ESC_PREFIX = 3,// DEC mode 1036
1307
+ MODIFY_OTHER_KEYS_STATE_2 = 4,// xterm modifyOtherKeys
1308
+ KITTY_KEYBOARD_FLAGS = 5
1309
+ }
1310
+
1311
+ /**
1312
+ * Key event structure
1313
+ */
1314
+ export declare interface KeyEvent {
1315
+ action: KeyAction;
1316
+ key: Key;
1317
+ mods: Mods;
1318
+ consumedMods?: Mods;
1319
+ composing?: boolean;
1320
+ utf8?: string;
1321
+ unshiftedCodepoint?: number;
1322
+ }
1323
+
1324
+ /**
1325
+ * Kitty keyboard protocol flags
1326
+ * From include/ghostty/vt/key/encoder.h
1327
+ */
1328
+ declare enum KittyKeyFlags {
1329
+ DISABLED = 0,
1330
+ DISAMBIGUATE = 1,// Disambiguate escape codes
1331
+ REPORT_EVENTS = 2,// Report press and release
1332
+ REPORT_ALTERNATES = 4,// Report alternate key codes
1333
+ REPORT_ALL = 8,// Report all events
1334
+ REPORT_ASSOCIATED = 16,// Report associated text
1335
+ ALL = 31
1336
+ }
1337
+
1338
+ /**
1339
+ * Manages link detection across multiple providers with intelligent caching
1340
+ */
1341
+ export declare class LinkDetector {
1342
+ private terminal;
1343
+ private providers;
1344
+ private linkCache;
1345
+ private scannedRows;
1346
+ constructor(terminal: ITerminalForLinkDetector);
1347
+ /**
1348
+ * Register a link provider
1349
+ */
1350
+ registerProvider(provider: ILinkProvider): void;
1351
+ /**
1352
+ * Get link at the specified buffer position
1353
+ * @param col Column (0-based)
1354
+ * @param row Absolute row in buffer (0-based)
1355
+ * @returns Link at position, or undefined if none
1356
+ */
1357
+ getLinkAt(col: number, row: number): Promise<ILink | undefined>;
1358
+ /**
1359
+ * Scan a row for links using all registered providers
1360
+ */
1361
+ private scanRow;
1362
+ /**
1363
+ * Cache a link for fast lookup
1364
+ *
1365
+ * Note: We cache by position range, not hyperlink_id, because the WASM
1366
+ * returns hyperlink_id as a boolean (0 or 1), not a unique identifier.
1367
+ * The actual unique identifier is the URI which is retrieved separately.
1368
+ */
1369
+ private cacheLink;
1370
+ /**
1371
+ * Check if a position is within a link's range
1372
+ */
1373
+ private isPositionInLink;
1374
+ /**
1375
+ * Invalidate cache when terminal content changes
1376
+ * Should be called on terminal write, resize, or clear
1377
+ */
1378
+ invalidateCache(): void;
1379
+ /**
1380
+ * Invalidate cache for specific rows
1381
+ * Used when only part of the terminal changed
1382
+ */
1383
+ invalidateRows(startRow: number, endRow: number): void;
1384
+ /**
1385
+ * Dispose and cleanup
1386
+ */
1387
+ dispose(): void;
1388
+ }
1389
+
1390
+ /**
1391
+ * Modifier keys
1392
+ */
1393
+ export declare enum Mods {
1394
+ NONE = 0,
1395
+ SHIFT = 1,
1396
+ CTRL = 2,
1397
+ ALT = 4,
1398
+ SUPER = 8,// Windows/Command key
1399
+ CAPSLOCK = 16,
1400
+ NUMLOCK = 32
1401
+ }
1402
+
1403
+ /**
1404
+ * InputHandler class
1405
+ * Attaches keyboard event listeners to a container and converts
1406
+ * keyboard events to terminal input data
1407
+ */
1408
+ /**
1409
+ * Mouse tracking configuration
1410
+ */
1411
+ declare interface MouseTrackingConfig {
1412
+ /** Check if any mouse tracking mode is enabled */
1413
+ hasMouseTracking: () => boolean;
1414
+ /** Check if SGR extended mouse mode is enabled (mode 1006) */
1415
+ hasSgrMouseMode: () => boolean;
1416
+ /** Get cell dimensions for pixel to cell conversion */
1417
+ getCellDimensions: () => {
1418
+ width: number;
1419
+ height: number;
1420
+ };
1421
+ /** Get canvas/container offset for accurate position calculation */
1422
+ getCanvasOffset: () => {
1423
+ left: number;
1424
+ top: number;
1425
+ };
1426
+ }
1427
+
1428
+ /**
1429
+ * OSC 8 Hyperlink Provider
1430
+ *
1431
+ * Detects OSC 8 hyperlinks by scanning for hyperlink_id in cells.
1432
+ * Automatically handles multi-line links since Ghostty WASM preserves
1433
+ * hyperlink_id across wrapped lines.
1434
+ */
1435
+ export declare class OSC8LinkProvider implements ILinkProvider {
1436
+ private terminal;
1437
+ constructor(terminal: ITerminalForOSC8Provider);
1438
+ /**
1439
+ * Provide all OSC 8 links on the given row
1440
+ * Note: This may return links that span multiple rows
1441
+ */
1442
+ provideLinks(y: number, callback: (links: ILink[] | undefined) => void): void;
1443
+ /**
1444
+ * Find the full extent of a link by scanning for contiguous cells
1445
+ * with the same hyperlink_id. Handles multi-line links.
1446
+ */
1447
+ private findLinkRange;
1448
+ dispose(): void;
1449
+ }
1450
+
1451
+ export declare interface RendererOptions {
1452
+ fontSize?: number;
1453
+ fontFamily?: string;
1454
+ cursorStyle?: 'block' | 'underline' | 'bar';
1455
+ cursorBlink?: boolean;
1456
+ theme?: ITheme;
1457
+ devicePixelRatio?: number;
1458
+ }
1459
+
1460
+ /**
1461
+ * Colors from RenderState (12 bytes packed)
1462
+ */
1463
+ declare interface RenderStateColors {
1464
+ background: RGB;
1465
+ foreground: RGB;
1466
+ cursor: RGB | null;
1467
+ }
1468
+
1469
+ /**
1470
+ * Cursor state from RenderState (8 bytes packed)
1471
+ * Layout: x(u16) + y(u16) + viewport_x(i16) + viewport_y(i16) + visible(bool) + blinking(bool) + style(u8) + _pad(u8)
1472
+ */
1473
+ declare interface RenderStateCursor {
1474
+ x: number;
1475
+ y: number;
1476
+ viewportX: number;
1477
+ viewportY: number;
1478
+ visible: boolean;
1479
+ blinking: boolean;
1480
+ style: 'block' | 'underline' | 'bar';
1481
+ }
1482
+
1483
+ /**
1484
+ * RGB color
1485
+ */
1486
+ export declare interface RGB {
1487
+ r: number;
1488
+ g: number;
1489
+ b: number;
1490
+ }
1491
+
1492
+ export declare interface SelectionCoordinates {
1493
+ startCol: number;
1494
+ startRow: number;
1495
+ endCol: number;
1496
+ endRow: number;
1497
+ }
1498
+
1499
+ export declare class SelectionManager {
1500
+ private terminal;
1501
+ private renderer;
1502
+ private wasmTerm;
1503
+ private textarea;
1504
+ private selectionStart;
1505
+ private selectionEnd;
1506
+ private isSelecting;
1507
+ private mouseDownX;
1508
+ private mouseDownY;
1509
+ private dragThresholdMet;
1510
+ private mouseDownTarget;
1511
+ private dirtySelectionRows;
1512
+ private selectionChangedEmitter;
1513
+ private boundMouseUpHandler;
1514
+ private boundContextMenuHandler;
1515
+ private boundClickHandler;
1516
+ private boundDocumentMouseMoveHandler;
1517
+ private autoScrollInterval;
1518
+ private autoScrollDirection;
1519
+ private static readonly AUTO_SCROLL_EDGE_SIZE;
1520
+ /**
1521
+ * Get current viewport Y position (how many lines scrolled into history)
1522
+ */
1523
+ private getViewportY;
1524
+ /**
1525
+ * Convert viewport row to absolute buffer row
1526
+ * Absolute row is an index into combined buffer: scrollback (0 to len-1) + screen (len to len+rows-1)
1527
+ */
1528
+ private viewportRowToAbsolute;
1529
+ /**
1530
+ * Convert absolute buffer row to viewport row (may be outside visible range)
1531
+ */
1532
+ private absoluteRowToViewport;
1533
+ private static readonly AUTO_SCROLL_SPEED;
1534
+ private static readonly AUTO_SCROLL_INTERVAL;
1535
+ constructor(terminal: Terminal, renderer: CanvasRenderer, wasmTerm: GhosttyTerminal, textarea: HTMLTextAreaElement);
1536
+ /**
1537
+ * Get the selected text as a string
1538
+ */
1539
+ getSelection(): string;
1540
+ /**
1541
+ * Check if there's an active selection
1542
+ */
1543
+ hasSelection(): boolean;
1544
+ /**
1545
+ * Copy the current selection to clipboard
1546
+ * @returns true if there was text to copy, false otherwise
1547
+ */
1548
+ copySelection(): boolean;
1549
+ /**
1550
+ * Clear the selection
1551
+ */
1552
+ clearSelection(): void;
1553
+ /**
1554
+ * Select all text in the terminal
1555
+ */
1556
+ selectAll(): void;
1557
+ /**
1558
+ * Select text at specific column and row with length
1559
+ * xterm.js compatible API
1560
+ */
1561
+ select(column: number, row: number, length: number): void;
1562
+ /**
1563
+ * Select entire lines from start to end
1564
+ * xterm.js compatible API
1565
+ */
1566
+ selectLines(start: number, end: number): void;
1567
+ /**
1568
+ * Get selection position as buffer range
1569
+ * xterm.js compatible API
1570
+ */
1571
+ getSelectionPosition(): {
1572
+ start: {
1573
+ x: number;
1574
+ y: number;
1575
+ };
1576
+ end: {
1577
+ x: number;
1578
+ y: number;
1579
+ };
1580
+ } | undefined;
1581
+ /**
1582
+ * Deselect all text
1583
+ * xterm.js compatible API
1584
+ */
1585
+ deselect(): void;
1586
+ /**
1587
+ * Focus the terminal (make it receive keyboard input)
1588
+ */
1589
+ focus(): void;
1590
+ /**
1591
+ * Get current selection coordinates (for rendering)
1592
+ */
1593
+ getSelectionCoords(): SelectionCoordinates | null;
1594
+ /**
1595
+ * Get dirty selection rows that need redraw (for clearing old highlight)
1596
+ */
1597
+ getDirtySelectionRows(): Set<number>;
1598
+ /**
1599
+ * Clear the dirty selection rows tracking (after redraw)
1600
+ */
1601
+ clearDirtySelectionRows(): void;
1602
+ /**
1603
+ * Get selection change event accessor
1604
+ */
1605
+ get onSelectionChange(): IEvent<void>;
1606
+ /**
1607
+ * Cleanup resources
1608
+ */
1609
+ dispose(): void;
1610
+ /**
1611
+ * Attach mouse event listeners to canvas
1612
+ */
1613
+ private attachEventListeners;
1614
+ /**
1615
+ * Mark current selection rows as dirty for redraw
1616
+ */
1617
+ private markCurrentSelectionDirty;
1618
+ /**
1619
+ * Update auto-scroll based on mouse Y position within canvas
1620
+ */
1621
+ private updateAutoScroll;
1622
+ /**
1623
+ * Start auto-scrolling in the given direction
1624
+ */
1625
+ private startAutoScroll;
1626
+ /**
1627
+ * Stop auto-scrolling
1628
+ */
1629
+ private stopAutoScroll;
1630
+ /**
1631
+ * Convert pixel coordinates to terminal cell coordinates
1632
+ */
1633
+ private pixelToCell;
1634
+ /**
1635
+ * Normalize selection coordinates (handle backward selection)
1636
+ * Returns coordinates in VIEWPORT space for rendering, clamped to visible area
1637
+ */
1638
+ private normalizeSelection;
1639
+ /**
1640
+ * Get word boundaries at a cell position
1641
+ */
1642
+ private getWordAtCell;
1643
+ /**
1644
+ * Copy text to clipboard
1645
+ *
1646
+ * Strategy (modern APIs first):
1647
+ * 1. Try ClipboardItem API (works in Safari and modern browsers)
1648
+ * - Safari requires the ClipboardItem to be created synchronously within user gesture
1649
+ * 2. Try navigator.clipboard.writeText (modern async API, may fail in Safari)
1650
+ * 3. Fall back to execCommand (legacy, for older browsers)
1651
+ */
1652
+ private copyToClipboard;
1653
+ /**
1654
+ * Copy using navigator.clipboard.writeText
1655
+ */
1656
+ private copyWithWriteText;
1657
+ /**
1658
+ * Copy using legacy execCommand (fallback for older browsers)
1659
+ */
1660
+ private copyWithExecCommand;
1661
+ /**
1662
+ * Request a render update (triggers selection overlay redraw)
1663
+ */
1664
+ private requestRender;
1665
+ }
1666
+
1667
+ export declare class Terminal implements ITerminalCore {
1668
+ cols: number;
1669
+ rows: number;
1670
+ element?: HTMLElement;
1671
+ textarea?: HTMLTextAreaElement;
1672
+ readonly buffer: IBufferNamespace;
1673
+ readonly unicode: IUnicodeVersionProvider;
1674
+ readonly options: Required<ITerminalOptions>;
1675
+ private ghostty?;
1676
+ wasmTerm?: GhosttyTerminal;
1677
+ renderer?: CanvasRenderer;
1678
+ private inputHandler?;
1679
+ private selectionManager?;
1680
+ private canvas?;
1681
+ private linkDetector?;
1682
+ private currentHoveredLink?;
1683
+ private mouseMoveThrottleTimeout?;
1684
+ private pendingMouseMove?;
1685
+ private dataEmitter;
1686
+ private resizeEmitter;
1687
+ private bellEmitter;
1688
+ private selectionChangeEmitter;
1689
+ private keyEmitter;
1690
+ private titleChangeEmitter;
1691
+ private scrollEmitter;
1692
+ private renderEmitter;
1693
+ private cursorMoveEmitter;
1694
+ readonly onData: IEvent<string>;
1695
+ readonly onResize: IEvent<{
1696
+ cols: number;
1697
+ rows: number;
1698
+ }>;
1699
+ readonly onBell: IEvent<void>;
1700
+ readonly onSelectionChange: IEvent<void>;
1701
+ readonly onKey: IEvent<IKeyEvent>;
1702
+ readonly onTitleChange: IEvent<string>;
1703
+ readonly onScroll: IEvent<number>;
1704
+ readonly onRender: IEvent<{
1705
+ start: number;
1706
+ end: number;
1707
+ }>;
1708
+ readonly onCursorMove: IEvent<void>;
1709
+ private isOpen;
1710
+ private isDisposed;
1711
+ private animationFrameId?;
1712
+ private writeQueue;
1713
+ private addons;
1714
+ private customKeyEventHandler?;
1715
+ private currentTitle;
1716
+ viewportY: number;
1717
+ private targetViewportY;
1718
+ private scrollAnimationStartTime?;
1719
+ private scrollAnimationStartY?;
1720
+ private scrollAnimationFrame?;
1721
+ private customWheelEventHandler?;
1722
+ private lastCursorY;
1723
+ private isDraggingScrollbar;
1724
+ private scrollbarDragStart;
1725
+ private scrollbarDragStartViewportY;
1726
+ private scrollbarVisible;
1727
+ private scrollbarOpacity;
1728
+ private scrollbarHideTimeout?;
1729
+ private readonly SCROLLBAR_HIDE_DELAY_MS;
1730
+ private readonly SCROLLBAR_FADE_DURATION_MS;
1731
+ constructor(options?: ITerminalOptions);
1732
+ /**
1733
+ * Handle runtime option changes (called when options are modified after terminal is open)
1734
+ * This enables xterm.js compatibility where options can be changed at runtime
1735
+ */
1736
+ private handleOptionChange;
1737
+ /**
1738
+ * Handle font changes (fontSize or fontFamily)
1739
+ * Updates canvas size to match new font metrics and forces a full re-render
1740
+ */
1741
+ private handleFontChange;
1742
+ /**
1743
+ * Parse a CSS color string to 0xRRGGBB format.
1744
+ * Returns 0 if the color is undefined or invalid.
1745
+ */
1746
+ private parseColorToHex;
1747
+ /**
1748
+ * Convert terminal options to WASM terminal config.
1749
+ */
1750
+ private buildWasmConfig;
1751
+ /**
1752
+ * Open terminal in a parent element
1753
+ *
1754
+ * Initializes all components and starts rendering.
1755
+ * Requires a pre-loaded Ghostty instance passed to the constructor.
1756
+ */
1757
+ open(parent: HTMLElement): void;
1758
+ /**
1759
+ * Write data to terminal
1760
+ */
1761
+ write(data: string | Uint8Array, callback?: () => void): void;
1762
+ /**
1763
+ * Internal write implementation (extracted from write())
1764
+ */
1765
+ private writeInternal;
1766
+ /**
1767
+ * Write data with newline
1768
+ */
1769
+ writeln(data: string | Uint8Array, callback?: () => void): void;
1770
+ /**
1771
+ * Paste text into terminal (triggers bracketed paste if supported)
1772
+ */
1773
+ paste(data: string): void;
1774
+ /**
1775
+ * Input data into terminal (as if typed by user)
1776
+ *
1777
+ * @param data - Data to input
1778
+ * @param wasUserInput - If true, triggers onData event (default: false for compat with some apps)
1779
+ */
1780
+ input(data: string, wasUserInput?: boolean): void;
1781
+ /**
1782
+ * Resize terminal
1783
+ */
1784
+ resize(cols: number, rows: number): void;
1785
+ /**
1786
+ * Clear terminal screen
1787
+ */
1788
+ clear(): void;
1789
+ /**
1790
+ * Reset terminal state
1791
+ */
1792
+ reset(): void;
1793
+ /**
1794
+ * Focus terminal input
1795
+ */
1796
+ focus(): void;
1797
+ /**
1798
+ * Blur terminal (remove focus)
1799
+ */
1800
+ blur(): void;
1801
+ /**
1802
+ * Load an addon
1803
+ */
1804
+ loadAddon(addon: ITerminalAddon): void;
1805
+ /**
1806
+ * Get the selected text as a string
1807
+ */
1808
+ getSelection(): string;
1809
+ /**
1810
+ * Check if there's an active selection
1811
+ */
1812
+ hasSelection(): boolean;
1813
+ /**
1814
+ * Clear the current selection
1815
+ */
1816
+ clearSelection(): void;
1817
+ /**
1818
+ * Copy the current selection to clipboard
1819
+ * @returns true if there was text to copy, false otherwise
1820
+ */
1821
+ copySelection(): boolean;
1822
+ /**
1823
+ * Select all text in the terminal
1824
+ */
1825
+ selectAll(): void;
1826
+ /**
1827
+ * Select text at specific column and row with length
1828
+ */
1829
+ select(column: number, row: number, length: number): void;
1830
+ /**
1831
+ * Select entire lines from start to end
1832
+ */
1833
+ selectLines(start: number, end: number): void;
1834
+ /**
1835
+ * Get selection position as buffer range
1836
+ */
1837
+ /**
1838
+ * Get the current viewport Y position.
1839
+ *
1840
+ * This is the number of lines scrolled back from the bottom of the
1841
+ * scrollback buffer. It may be fractional during smooth scrolling.
1842
+ */
1843
+ getViewportY(): number;
1844
+ getSelectionPosition(): IBufferRange | undefined;
1845
+ /**
1846
+ * Attach a custom keyboard event handler
1847
+ * Returns true to prevent default handling
1848
+ */
1849
+ attachCustomKeyEventHandler(customKeyEventHandler: (event: KeyboardEvent) => boolean): void;
1850
+ /**
1851
+ * Attach a custom wheel event handler (Phase 2)
1852
+ * Returns true to prevent default handling
1853
+ */
1854
+ attachCustomWheelEventHandler(customWheelEventHandler?: (event: WheelEvent) => boolean): void;
1855
+ /**
1856
+ * Register a custom link provider
1857
+ * Multiple providers can be registered to detect different types of links
1858
+ *
1859
+ * @example
1860
+ * ```typescript
1861
+ * term.registerLinkProvider({
1862
+ * provideLinks(y, callback) {
1863
+ * // Detect URLs, file paths, etc.
1864
+ * callback(detectedLinks);
1865
+ * }
1866
+ * });
1867
+ * ```
1868
+ */
1869
+ registerLinkProvider(provider: ILinkProvider): void;
1870
+ /**
1871
+ * Scroll viewport by a number of lines
1872
+ * @param amount Number of lines to scroll (positive = down, negative = up)
1873
+ */
1874
+ scrollLines(amount: number): void;
1875
+ /**
1876
+ * Scroll viewport by a number of pages
1877
+ * @param amount Number of pages to scroll (positive = down, negative = up)
1878
+ */
1879
+ scrollPages(amount: number): void;
1880
+ /**
1881
+ * Scroll viewport to the top of the scrollback buffer
1882
+ */
1883
+ scrollToTop(): void;
1884
+ /**
1885
+ * Scroll viewport to the bottom (current output)
1886
+ */
1887
+ scrollToBottom(): void;
1888
+ /**
1889
+ * Scroll viewport to a specific line in the buffer
1890
+ * @param line Line number (0 = top of scrollback, scrollbackLength = bottom)
1891
+ */
1892
+ scrollToLine(line: number): void;
1893
+ /**
1894
+ * Smoothly scroll to a target viewport position
1895
+ * @param targetY Target viewport Y position (in lines, can be fractional)
1896
+ */
1897
+ private smoothScrollTo;
1898
+ /**
1899
+ * Animation loop for smooth scrolling
1900
+ * Uses asymptotic approach - moves a fraction of remaining distance each frame
1901
+ */
1902
+ private animateScroll;
1903
+ /**
1904
+ * Dispose terminal and clean up resources
1905
+ */
1906
+ dispose(): void;
1907
+ /**
1908
+ * Cancel the render loop
1909
+ */
1910
+ private cancelRenderLoop;
1911
+ /**
1912
+ * Flush any writes that were queued during resize
1913
+ */
1914
+ private flushWriteQueue;
1915
+ /**
1916
+ * Start the render loop
1917
+ */
1918
+ private startRenderLoop;
1919
+ /**
1920
+ * Get a line from native WASM scrollback buffer
1921
+ * Implements IScrollbackProvider
1922
+ */
1923
+ getScrollbackLine(offset: number): GhosttyCell[] | null;
1924
+ /**
1925
+ * Get scrollback length from native WASM
1926
+ * Implements IScrollbackProvider
1927
+ */
1928
+ getScrollbackLength(): number;
1929
+ /**
1930
+ * Clean up components (called on dispose or error)
1931
+ */
1932
+ private cleanupComponents;
1933
+ /**
1934
+ * Assert terminal is open (throw if not)
1935
+ */
1936
+ private assertOpen;
1937
+ /**
1938
+ * Handle mouse move for link hover detection and scrollbar dragging
1939
+ * Throttled to avoid blocking scroll events (except when dragging scrollbar)
1940
+ */
1941
+ private handleMouseMove;
1942
+ /**
1943
+ * Process mouse move for link detection (internal, called by throttled handler)
1944
+ */
1945
+ private processMouseMove;
1946
+ /**
1947
+ * Handle mouse leave to clear link hover
1948
+ */
1949
+ private handleMouseLeave;
1950
+ /**
1951
+ * Handle mouse click for link activation
1952
+ */
1953
+ private handleClick;
1954
+ /**
1955
+ * Handle wheel events for scrolling (Phase 2)
1956
+ */
1957
+ private handleWheel;
1958
+ /**
1959
+ * Handle mouse down for scrollbar interaction
1960
+ */
1961
+ private handleMouseDown;
1962
+ /**
1963
+ * Handle mouse up for scrollbar drag
1964
+ */
1965
+ private handleMouseUp;
1966
+ /**
1967
+ * Process scrollbar drag movement
1968
+ */
1969
+ private processScrollbarDrag;
1970
+ /**
1971
+ * Show scrollbar with fade-in and schedule auto-hide
1972
+ */
1973
+ private showScrollbar;
1974
+ /**
1975
+ * Hide scrollbar with fade-out
1976
+ */
1977
+ private hideScrollbar;
1978
+ /**
1979
+ * Fade in scrollbar
1980
+ */
1981
+ private fadeInScrollbar;
1982
+ /**
1983
+ * Fade out scrollbar
1984
+ */
1985
+ private fadeOutScrollbar;
1986
+ /**
1987
+ * Process any pending terminal responses and emit them via onData.
1988
+ *
1989
+ * This handles escape sequences that require the terminal to send a response
1990
+ * back to the PTY, such as:
1991
+ * - DSR 6 (cursor position): Shell sends \x1b[6n, terminal responds with \x1b[row;colR
1992
+ * - DSR 5 (operating status): Shell sends \x1b[5n, terminal responds with \x1b[0n
1993
+ *
1994
+ * Without this, shells like nushell that rely on cursor position queries
1995
+ * will hang waiting for a response that never comes.
1996
+ *
1997
+ * Note: We loop to read all pending responses, not just one. This is important
1998
+ * when multiple queries are processed in a single write() call (e.g., when
1999
+ * buffered data is written all at once during terminal initialization).
2000
+ */
2001
+ private processTerminalResponses;
2002
+ /**
2003
+ * Check for title changes in written data (OSC sequences)
2004
+ * Simplified implementation - looks for OSC 0, 1, 2
2005
+ */
2006
+ private checkForTitleChange;
2007
+ /**
2008
+ * Query terminal mode state
2009
+ *
2010
+ * @param mode Mode number (e.g., 2004 for bracketed paste)
2011
+ * @param isAnsi True for ANSI modes, false for DEC modes (default: false)
2012
+ * @returns true if mode is enabled
2013
+ */
2014
+ getMode(mode: number, isAnsi?: boolean): boolean;
2015
+ /**
2016
+ * Check if bracketed paste mode is enabled
2017
+ */
2018
+ hasBracketedPaste(): boolean;
2019
+ /**
2020
+ * Check if focus event reporting is enabled
2021
+ */
2022
+ hasFocusEvents(): boolean;
2023
+ /**
2024
+ * Check if mouse tracking is enabled
2025
+ */
2026
+ hasMouseTracking(): boolean;
2027
+ }
2028
+
2029
+ /**
2030
+ * Opaque terminal pointer (WASM memory address)
2031
+ */
2032
+ export declare type TerminalHandle = number;
2033
+
2034
+ /**
2035
+ * URL Regex Provider
2036
+ *
2037
+ * Detects plain text URLs on a single line using regex.
2038
+ * Does not support multi-line URLs or file paths.
2039
+ *
2040
+ * Supported protocols:
2041
+ * - https://, http://
2042
+ * - mailto:
2043
+ * - ftp://, ssh://, git://
2044
+ * - tel:, magnet:
2045
+ * - gemini://, gopher://, news:
2046
+ */
2047
+ export declare class UrlRegexProvider implements ILinkProvider {
2048
+ private terminal;
2049
+ /**
2050
+ * URL regex pattern
2051
+ * Matches common protocols followed by valid URL characters
2052
+ * Excludes file paths (no ./ or ../ or bare /)
2053
+ */
2054
+ private static readonly URL_REGEX;
2055
+ /**
2056
+ * Characters to strip from end of URLs
2057
+ * Common punctuation that's unlikely to be part of the URL
2058
+ */
2059
+ private static readonly TRAILING_PUNCTUATION;
2060
+ constructor(terminal: ITerminalForUrlProvider);
2061
+ /**
2062
+ * Provide all regex-detected URLs on the given row
2063
+ */
2064
+ provideLinks(y: number, callback: (links: ILink[] | undefined) => void): void;
2065
+ /**
2066
+ * Convert a buffer line to plain text string
2067
+ */
2068
+ private lineToText;
2069
+ dispose(): void;
2070
+ }
2071
+
2072
+ export { }