@crunchloop/ghostty-web 0.4.1
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/LICENSE +21 -0
- package/README.md +314 -0
- package/dist/__vite-browser-external-2447137e.js +4 -0
- package/dist/__vite-browser-external-b3701507.cjs +1 -0
- package/dist/ghostty-vt.wasm +0 -0
- package/dist/ghostty-web.cjs.js +15 -0
- package/dist/ghostty-web.d.ts +2445 -0
- package/dist/ghostty-web.es.js +3389 -0
- package/dist/headless.cjs.js +5 -0
- package/dist/headless.d.ts +1271 -0
- package/dist/headless.es.js +34 -0
- package/dist/terminal-core-0895062a.cjs +5 -0
- package/dist/terminal-core-b557858d.js +4708 -0
- package/ghostty-vt.wasm +0 -0
- package/package.json +97 -0
|
@@ -0,0 +1,1271 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cell style flags (bitfield)
|
|
3
|
+
*/
|
|
4
|
+
export declare enum CellFlags {
|
|
5
|
+
BOLD = 1,
|
|
6
|
+
ITALIC = 2,
|
|
7
|
+
UNDERLINE = 4,
|
|
8
|
+
STRIKETHROUGH = 8,
|
|
9
|
+
INVERSE = 16,
|
|
10
|
+
INVISIBLE = 32,
|
|
11
|
+
BLINK = 64,
|
|
12
|
+
FAINT = 128
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Cursor position and visibility
|
|
17
|
+
*/
|
|
18
|
+
export declare interface Cursor {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
visible: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Dirty state from RenderState. Mirrors GhosttyRenderStateDirty.
|
|
26
|
+
*/
|
|
27
|
+
declare enum DirtyState {
|
|
28
|
+
NONE = 0,
|
|
29
|
+
PARTIAL = 1,
|
|
30
|
+
FULL = 2
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
declare class EventEmitter<T> {
|
|
34
|
+
private listeners;
|
|
35
|
+
fire(arg: T): void;
|
|
36
|
+
event: IEvent<T>;
|
|
37
|
+
dispose(): void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* Excluded from this release type: getGhostty */
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Main Ghostty WASM wrapper class
|
|
44
|
+
*/
|
|
45
|
+
export declare class Ghostty {
|
|
46
|
+
private exports;
|
|
47
|
+
private memory;
|
|
48
|
+
constructor(wasmInstance: WebAssembly.Instance);
|
|
49
|
+
createKeyEncoder(): KeyEncoder;
|
|
50
|
+
createTerminal(cols?: number, rows?: number, config?: GhosttyTerminalConfig): GhosttyTerminal;
|
|
51
|
+
static load(wasmPath?: string): Promise<Ghostty>;
|
|
52
|
+
private static loadFromPath;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Cell structure matching ghostty_cell_t in C (16 bytes)
|
|
57
|
+
*/
|
|
58
|
+
export declare interface GhosttyCell {
|
|
59
|
+
codepoint: number;
|
|
60
|
+
fg_r: number;
|
|
61
|
+
fg_g: number;
|
|
62
|
+
fg_b: number;
|
|
63
|
+
bg_r: number;
|
|
64
|
+
bg_g: number;
|
|
65
|
+
bg_b: number;
|
|
66
|
+
fgIsDefault: boolean;
|
|
67
|
+
bgIsDefault: boolean;
|
|
68
|
+
flags: number;
|
|
69
|
+
width: number;
|
|
70
|
+
hyperlink_id: number;
|
|
71
|
+
grapheme_len: number;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* GhosttyTerminal - High-performance terminal emulator
|
|
76
|
+
*
|
|
77
|
+
* Uses Ghostty's native RenderState for optimal performance:
|
|
78
|
+
* - ONE call to update all state (renderStateUpdate)
|
|
79
|
+
* - ONE call to get all cells (getViewport)
|
|
80
|
+
* - No per-row WASM boundary crossings!
|
|
81
|
+
*/
|
|
82
|
+
declare class GhosttyTerminal {
|
|
83
|
+
private exports;
|
|
84
|
+
private memory;
|
|
85
|
+
private handle;
|
|
86
|
+
private renderHandle;
|
|
87
|
+
private rowIter;
|
|
88
|
+
private rowCells;
|
|
89
|
+
private _cols;
|
|
90
|
+
private _rows;
|
|
91
|
+
/** Cell pool for zero-allocation rendering */
|
|
92
|
+
private cellPool;
|
|
93
|
+
/**
|
|
94
|
+
* Cell pixel dimensions last pushed to the WASM terminal via
|
|
95
|
+
* ghostty_terminal_resize. Zero means "unknown / disabled" — kitty
|
|
96
|
+
* graphics image sizing and CSI 14/16/18 t in-band size reports will
|
|
97
|
+
* return zero/no-op until setCellPixelSize() is called with real values.
|
|
98
|
+
*/
|
|
99
|
+
private cellWidthPx;
|
|
100
|
+
private cellHeightPx;
|
|
101
|
+
/**
|
|
102
|
+
* Per-row dirty state for the current render-state snapshot. Cleared on
|
|
103
|
+
* update() and populated lazily by isRowDirty() (or as a side effect of
|
|
104
|
+
* getViewport, which iterates rows anyway).
|
|
105
|
+
*/
|
|
106
|
+
private rowDirtyCache;
|
|
107
|
+
/**
|
|
108
|
+
* Per-row soft-wrap state for the current render-state snapshot. Same
|
|
109
|
+
* lifecycle as rowDirtyCache; the two caches are filled in lockstep.
|
|
110
|
+
*/
|
|
111
|
+
private rowWrapCache;
|
|
112
|
+
/**
|
|
113
|
+
* Whether cellPool currently holds a valid built viewport.
|
|
114
|
+
*
|
|
115
|
+
* The visible-screen content is a pure function of the WASM terminal state,
|
|
116
|
+
* which only changes via write() (all VT sequences — text, scroll, clear,
|
|
117
|
+
* alt-screen switch) or resize(). So once getViewport() has walked the grid
|
|
118
|
+
* and populated cellPool, the result stays valid until the next write/resize
|
|
119
|
+
* — letting repeated getViewport()/getLine() calls within (and across, when
|
|
120
|
+
* idle) a render pass reuse the pool instead of re-walking it (~3-4 WASM
|
|
121
|
+
* crossings per cell). Cursor blink, selection overlays and scrollback
|
|
122
|
+
* paging don't read cellPool, so they don't invalidate it.
|
|
123
|
+
*/
|
|
124
|
+
private viewportValid;
|
|
125
|
+
/**
|
|
126
|
+
* Bytes the terminal would have written back to a real PTY in response
|
|
127
|
+
* to query sequences (DSR, XTVERSION, in-band size reports, ...).
|
|
128
|
+
* Captured by the WRITE_PTY callback installed in the constructor and
|
|
129
|
+
* drained by readResponse(). Each slot is one callback invocation, so
|
|
130
|
+
* a single response sequence may span multiple slots.
|
|
131
|
+
*/
|
|
132
|
+
private pendingResponses;
|
|
133
|
+
/**
|
|
134
|
+
* Per-table registry for callback trampolines. Keyed on the WASM
|
|
135
|
+
* module's __indirect_function_table so that multiple Ghostty.load()
|
|
136
|
+
* instances each get their own trampoline slots and routing map —
|
|
137
|
+
* terminal handles are only unique within a single WASM instance, and
|
|
138
|
+
* indices into one module's table are meaningless in another.
|
|
139
|
+
*
|
|
140
|
+
* One trampoline pair (write_pty + size) is installed per table; their
|
|
141
|
+
* slot indices live here alongside the routing map. The dispatchers
|
|
142
|
+
* close over the same instancesByHandle so any GhosttyTerminal coming
|
|
143
|
+
* from this WASM module routes correctly.
|
|
144
|
+
*/
|
|
145
|
+
private static callbackRegistries;
|
|
146
|
+
/**
|
|
147
|
+
* Cached pointer to this terminal's registry. We only need it to
|
|
148
|
+
* deregister cleanly in free() / cleanupOnConstructorFailure().
|
|
149
|
+
*/
|
|
150
|
+
private callbackRegistry?;
|
|
151
|
+
constructor(exports: GhosttyWasmExports, memory: WebAssembly.Memory, cols?: number, rows?: number, config?: GhosttyTerminalConfig);
|
|
152
|
+
/**
|
|
153
|
+
* Allocate an opaque handle through one of the new(allocator, *outHandle)
|
|
154
|
+
* factory functions. Wraps the boilerplate of: alloc out-pointer, call
|
|
155
|
+
* factory, check Result, read the handle, free out-pointer.
|
|
156
|
+
*
|
|
157
|
+
* If the factory call fails, frees any already-acquired terminal/render
|
|
158
|
+
* resources so the caller-throwing flow doesn't leak across the partially
|
|
159
|
+
* constructed object.
|
|
160
|
+
*/
|
|
161
|
+
private allocOpaqueOrFail;
|
|
162
|
+
/**
|
|
163
|
+
* Apply user-supplied colors + palette overrides to the freshly-created
|
|
164
|
+
* terminal via ghostty_terminal_set(COLOR_*).
|
|
165
|
+
*
|
|
166
|
+
* For the palette: the new C ABI takes a full 256-entry array, but coder's
|
|
167
|
+
* config carries only the legacy 16 ANSI entries (each as a 0xRRGGBB int,
|
|
168
|
+
* 0 meaning "use default"). To preserve indices ≥16 we read the existing
|
|
169
|
+
* default palette first, overlay the non-zero entries from config, and
|
|
170
|
+
* write the merged 768-byte buffer back.
|
|
171
|
+
*/
|
|
172
|
+
private applyConfig;
|
|
173
|
+
private setColorOption;
|
|
174
|
+
/**
|
|
175
|
+
* Release any resources that have been allocated by the constructor up to
|
|
176
|
+
* this point. Called when a subsequent step fails so we don't leak handles
|
|
177
|
+
* before the throw propagates.
|
|
178
|
+
*/
|
|
179
|
+
private cleanupOnConstructorFailure;
|
|
180
|
+
private rsGetU8;
|
|
181
|
+
private rsGetU16;
|
|
182
|
+
private rsGetU32;
|
|
183
|
+
private rsGetRgb;
|
|
184
|
+
private tGetU8;
|
|
185
|
+
private tGetU32;
|
|
186
|
+
get cols(): number;
|
|
187
|
+
get rows(): number;
|
|
188
|
+
write(data: string | Uint8Array): void;
|
|
189
|
+
resize(cols: number, rows: number): void;
|
|
190
|
+
/**
|
|
191
|
+
* Set the maximum bytes of image data the terminal will retain across
|
|
192
|
+
* all kitty graphics images. Zero disables kitty graphics entirely
|
|
193
|
+
* (transmissions will be parsed and dropped). Set this BEFORE any
|
|
194
|
+
* image-bearing data is written to the terminal — there's no
|
|
195
|
+
* retroactive recovery of dropped images.
|
|
196
|
+
*
|
|
197
|
+
* Input is uint64_t* on the C side, so we use a u32-pair little-endian
|
|
198
|
+
* write to keep the byte count exact even past 4GB (probably overkill
|
|
199
|
+
* but free).
|
|
200
|
+
*/
|
|
201
|
+
setKittyImageStorageLimit(bytes: number): void;
|
|
202
|
+
/**
|
|
203
|
+
* Get the kitty graphics storage handle for the active screen, or null
|
|
204
|
+
* if storage is disabled or no images are stored. Cheap to call; returns
|
|
205
|
+
* a borrowed pointer.
|
|
206
|
+
*/
|
|
207
|
+
getKittyGraphics(): number | null;
|
|
208
|
+
/**
|
|
209
|
+
* Iterate placements in the active screen, yielding render-ready info
|
|
210
|
+
* for each. The optional `onlyVisible` flag (default true) drops
|
|
211
|
+
* placements that don't intersect the viewport — most renderers want
|
|
212
|
+
* this. Use `false` if you need to track invalidated regions for
|
|
213
|
+
* partial damage.
|
|
214
|
+
*
|
|
215
|
+
* Internally this uses the upstream placement iterator + the one-shot
|
|
216
|
+
* placement_render_info call (fills 12 fields in one WASM crossing
|
|
217
|
+
* instead of 5 separate getters).
|
|
218
|
+
*/
|
|
219
|
+
iterPlacements(graphics: number, onlyVisible?: boolean): Generator<KittyPlacementInfo>;
|
|
220
|
+
/**
|
|
221
|
+
* Get the pixel data + metadata for an image by id. Returns null if the
|
|
222
|
+
* image isn't stored or isn't in a format we can hand the renderer
|
|
223
|
+
* directly (RGB / RGBA / GRAY / GRAY_ALPHA).
|
|
224
|
+
*
|
|
225
|
+
* The returned `data` is a borrowed view into WASM memory — copy before
|
|
226
|
+
* the next vt_write if you need to retain. Most callers will turn this
|
|
227
|
+
* into an ImageData / canvas immediately and discard the view.
|
|
228
|
+
*/
|
|
229
|
+
getKittyImagePixels(graphics: number, imageId: number): KittyImagePixels | null;
|
|
230
|
+
/**
|
|
231
|
+
* Push the renderer's per-cell pixel size into the WASM terminal.
|
|
232
|
+
*
|
|
233
|
+
* The new C ABI doesn't expose a separate "set pixel size" call —
|
|
234
|
+
* dimensions only flow through ghostty_terminal_resize, which takes
|
|
235
|
+
* (cols, rows, cell_width_px, cell_height_px). We cache the cell pixel
|
|
236
|
+
* dims on the instance so subsequent resize() calls keep the values
|
|
237
|
+
* stable, and short-circuit when nothing has changed.
|
|
238
|
+
*
|
|
239
|
+
* The width/height arguments are PER-CELL CSS pixels — matches what
|
|
240
|
+
* the renderer reports via getMetrics(). Coder's old setPixelSize
|
|
241
|
+
* took TOTAL screen pixels (cell_width * cols, cell_height * rows);
|
|
242
|
+
* we renamed to avoid silent value mis-passing.
|
|
243
|
+
*
|
|
244
|
+
* Affects in-band size reports (CSI 14/16/18 t) and kitty graphics
|
|
245
|
+
* placement sizing. Until called, those query paths return zero.
|
|
246
|
+
*/
|
|
247
|
+
setCellPixelSize(cellWidthPx: number, cellHeightPx: number): void;
|
|
248
|
+
free(): void;
|
|
249
|
+
/**
|
|
250
|
+
* Update terminal colors at runtime. All color values are applied directly
|
|
251
|
+
* (no sentinel — 0x000000 is valid black). Forces a full redraw on next render.
|
|
252
|
+
*
|
|
253
|
+
* Uses the same ghostty_terminal_set(COLOR_*) path as applyConfig; this
|
|
254
|
+
* is the runtime variant called by Terminal.setTheme().
|
|
255
|
+
*/
|
|
256
|
+
setColors(config: GhosttyTerminalConfig): void;
|
|
257
|
+
/**
|
|
258
|
+
* Update render state from terminal.
|
|
259
|
+
*
|
|
260
|
+
* This syncs the RenderState with the current Terminal state.
|
|
261
|
+
* The dirty state (full/partial/none) is stored in the WASM RenderState
|
|
262
|
+
* and can be queried via isRowDirty(). When dirty==full, isRowDirty()
|
|
263
|
+
* returns true for ALL rows.
|
|
264
|
+
*
|
|
265
|
+
* The WASM layer automatically detects screen switches (normal <-> alternate)
|
|
266
|
+
* and returns FULL dirty state when switching screens (e.g., vim exit).
|
|
267
|
+
*
|
|
268
|
+
* Safe to call multiple times - dirty state persists until markClean().
|
|
269
|
+
*/
|
|
270
|
+
update(): DirtyState;
|
|
271
|
+
/**
|
|
272
|
+
* Get cursor state from render state.
|
|
273
|
+
* Calls update() first; safe to call repeatedly within a frame.
|
|
274
|
+
*/
|
|
275
|
+
getCursor(): RenderStateCursor;
|
|
276
|
+
/**
|
|
277
|
+
* Get default fg/bg/cursor colors from render state.
|
|
278
|
+
*/
|
|
279
|
+
getColors(): RenderStateColors;
|
|
280
|
+
/**
|
|
281
|
+
* Check if a specific row is dirty.
|
|
282
|
+
*
|
|
283
|
+
* Backed by a per-row cache populated lazily — first call after update()
|
|
284
|
+
* walks the iterator once and reads the dirty flag for each row, then
|
|
285
|
+
* subsequent calls are O(1). getViewport() also populates the cache as a
|
|
286
|
+
* side effect so a typical "update → for-each-row isRowDirty → getViewport"
|
|
287
|
+
* render loop only iterates rows once.
|
|
288
|
+
*/
|
|
289
|
+
isRowDirty(y: number): boolean;
|
|
290
|
+
/**
|
|
291
|
+
* Check if a row is soft-wrapped (continues onto the next row).
|
|
292
|
+
*
|
|
293
|
+
* Same cache discipline as isRowDirty: lazy-populated on first call after
|
|
294
|
+
* update(), or as a side effect of getViewport.
|
|
295
|
+
*/
|
|
296
|
+
isRowWrapped(y: number): boolean;
|
|
297
|
+
/**
|
|
298
|
+
* Walk the row iterator once and capture per-row dirty + wrap flags.
|
|
299
|
+
*
|
|
300
|
+
* Calls update() first since callers (isRowDirty / isRowWrapped) typically
|
|
301
|
+
* query right after a terminal write, before any explicit render-state
|
|
302
|
+
* refresh has happened. Same idempotency guarantee as getCursor/getColors:
|
|
303
|
+
* if no terminal change occurred since the last update, this is cheap.
|
|
304
|
+
*
|
|
305
|
+
* Reads ROW_DATA_DIRTY directly from the iterator, then ROW_DATA_RAW to
|
|
306
|
+
* obtain the GhosttyRow (u64) needed to call ghostty_row_get(WRAP_*). The
|
|
307
|
+
* row value is only valid for the current iterator position; we read it
|
|
308
|
+
* inline before advancing.
|
|
309
|
+
*/
|
|
310
|
+
private refreshRowMetaCache;
|
|
311
|
+
/**
|
|
312
|
+
* Mark render state as clean — clears both global and per-row dirty.
|
|
313
|
+
*
|
|
314
|
+
* Per the upstream contract, "setting one dirty state doesn't unset the
|
|
315
|
+
* other." Global dirty is cleared via _set(OPTION_DIRTY, FALSE); per-row
|
|
316
|
+
* dirty is cleared by walking the row iterator and calling _row_set on
|
|
317
|
+
* each. Without the per-row pass, the next update() would still report
|
|
318
|
+
* the old per-row flags as dirty even though the terminal hasn't changed.
|
|
319
|
+
*/
|
|
320
|
+
markClean(): void;
|
|
321
|
+
/**
|
|
322
|
+
* Populate the cellPool from the current render state and return it.
|
|
323
|
+
*
|
|
324
|
+
* The new C ABI replaces coder's single ghostty_render_state_get_viewport()
|
|
325
|
+
* buffer-fill with a row iterator + per-row cells iterator. We allocate
|
|
326
|
+
* both iterators once at construction time and re-populate them per call:
|
|
327
|
+
*
|
|
328
|
+
* _get(state, ROW_ITERATOR, &rowIter)
|
|
329
|
+
* while (row_iterator_next(rowIter)) {
|
|
330
|
+
* _row_get(rowIter, ROW_DATA_CELLS, &rowCells)
|
|
331
|
+
* while (row_cells_next(rowCells)) {
|
|
332
|
+
* _row_cells_get(rowCells, GRAPHEMES_LEN, &len)
|
|
333
|
+
* _row_cells_get(rowCells, GRAPHEMES_BUF, &codepoint) // if len > 0
|
|
334
|
+
* _row_cells_get(rowCells, FG_COLOR/BG_COLOR, &rgb) // INVALID_VALUE if unset
|
|
335
|
+
* }
|
|
336
|
+
* }
|
|
337
|
+
*
|
|
338
|
+
* This is intentionally minimal: we capture codepoint + fg/bg only.
|
|
339
|
+
* Style flags, cell width (double-width), and hyperlink IDs are deferred
|
|
340
|
+
* — they require parsing the GhosttyStyle sized struct and the per-cell
|
|
341
|
+
* ghostty_cell_get(WIDE)/HAS_HYPERLINK paths. The cellPool fields keep
|
|
342
|
+
* placeholder defaults (flags=0, width=1, hyperlink_id=0).
|
|
343
|
+
*
|
|
344
|
+
* Performance: ~3-4 WASM crossings per visible cell. For an 80x24 viewport
|
|
345
|
+
* that's ~6k crossings per frame. Profile before optimizing — likely
|
|
346
|
+
* candidates are _row_cells_get_multi for batched reads, or RAW + a
|
|
347
|
+
* cached layout map for direct memory access.
|
|
348
|
+
*/
|
|
349
|
+
getViewport(): GhosttyCell[];
|
|
350
|
+
/**
|
|
351
|
+
* Helper for the in/out pointer pattern used by ROW_ITERATOR / ROW_DATA_CELLS:
|
|
352
|
+
* write a handle into a 4-byte slot, hand the slot to a populator, then
|
|
353
|
+
* free the slot. The handle value itself is unchanged; the populator uses
|
|
354
|
+
* it to find and rebind the iterator's internal data.
|
|
355
|
+
*/
|
|
356
|
+
private populateHandle;
|
|
357
|
+
/**
|
|
358
|
+
* Reset every cell in the pool to "empty" so cells we don't visit during
|
|
359
|
+
* iteration (e.g. iterator stopped early, or grid resized down) don't
|
|
360
|
+
* carry stale values from a previous frame.
|
|
361
|
+
*/
|
|
362
|
+
private zeroCellPool;
|
|
363
|
+
/**
|
|
364
|
+
* Get line - for compatibility, extracts from viewport.
|
|
365
|
+
* Ensures render state is fresh by calling update().
|
|
366
|
+
* Returns a COPY of the cells to avoid pool reference issues.
|
|
367
|
+
*/
|
|
368
|
+
getLine(y: number): GhosttyCell[] | null;
|
|
369
|
+
/** For compatibility with old API */
|
|
370
|
+
isDirty(): boolean;
|
|
371
|
+
/**
|
|
372
|
+
* Check if a full redraw is needed (screen change, resize, etc.)
|
|
373
|
+
* Note: This calls update() to ensure fresh state. Safe to call multiple times.
|
|
374
|
+
*/
|
|
375
|
+
needsFullRedraw(): boolean;
|
|
376
|
+
/** Mark render state as clean after rendering */
|
|
377
|
+
clearDirty(): void;
|
|
378
|
+
isAlternateScreen(): boolean;
|
|
379
|
+
hasBracketedPaste(): boolean;
|
|
380
|
+
hasFocusEvents(): boolean;
|
|
381
|
+
hasMouseTracking(): boolean;
|
|
382
|
+
/** Get dimensions - for compatibility */
|
|
383
|
+
getDimensions(): {
|
|
384
|
+
cols: number;
|
|
385
|
+
rows: number;
|
|
386
|
+
};
|
|
387
|
+
/** Get number of scrollback lines (history, not including active screen) */
|
|
388
|
+
getScrollbackLength(): number;
|
|
389
|
+
/**
|
|
390
|
+
* Get a line from the scrollback buffer.
|
|
391
|
+
* @param offset 0 = oldest scrollback line, (scrollbackLength-1) = most
|
|
392
|
+
* recent scrollback line.
|
|
393
|
+
*
|
|
394
|
+
* Uses ghostty_terminal_grid_ref with POINT_TAG_HISTORY to address rows
|
|
395
|
+
* outside the active viewport. The render-state row iterator only walks
|
|
396
|
+
* the viewport, so scrollback access has to go through grid_ref.
|
|
397
|
+
*
|
|
398
|
+
* Cell content is currently codepoint-only; fg/bg colors, style flags,
|
|
399
|
+
* and hyperlinks are deferred (defaults: 0 colors, flags=0, width=1).
|
|
400
|
+
* The text-extraction tests that drove this commit only check codepoints.
|
|
401
|
+
*/
|
|
402
|
+
getScrollbackLine(offset: number): GhosttyCell[] | null;
|
|
403
|
+
/**
|
|
404
|
+
* Get the hyperlink URI for a cell at the given position in the active
|
|
405
|
+
* viewport. Returns null when no hyperlink is attached.
|
|
406
|
+
*/
|
|
407
|
+
getHyperlinkUri(row: number, col: number): string | null;
|
|
408
|
+
/**
|
|
409
|
+
* Get the hyperlink URI for a cell in the scrollback buffer.
|
|
410
|
+
*/
|
|
411
|
+
getScrollbackHyperlinkUri(offset: number, col: number): string | null;
|
|
412
|
+
private readGridLine;
|
|
413
|
+
/**
|
|
414
|
+
* Decode a GhosttyStyleColor (16 bytes at colorPtr — tag@0:u32,
|
|
415
|
+
* value@8:union) and write the resolved RGB into the cell's fg_*
|
|
416
|
+
* or bg_* triple. Tag values: NONE=0 (leaves zeros so the renderer's
|
|
417
|
+
* theme fallback kicks in), PALETTE=1 (looks up the terminal's
|
|
418
|
+
* effective palette), RGB=2 (direct read).
|
|
419
|
+
*/
|
|
420
|
+
private resolveStyleColor;
|
|
421
|
+
private readHyperlinkUri;
|
|
422
|
+
private allocPoint;
|
|
423
|
+
private makeEmptyCell;
|
|
424
|
+
/**
|
|
425
|
+
* Whether any terminal response bytes are queued for readResponse().
|
|
426
|
+
*
|
|
427
|
+
* Responses are delivered synchronously during vt_write() by the
|
|
428
|
+
* WRITE_PTY callback (e.g. DSR replies, XTVERSION, in-band size reports).
|
|
429
|
+
* They sit in pendingResponses until drained.
|
|
430
|
+
*/
|
|
431
|
+
hasResponse(): boolean;
|
|
432
|
+
/**
|
|
433
|
+
* Drain queued response bytes, decode as UTF-8, return as a single
|
|
434
|
+
* string. Multiple callback invocations are concatenated. Returns null
|
|
435
|
+
* when nothing's pending so the demo's echo loop can short-circuit.
|
|
436
|
+
*/
|
|
437
|
+
readResponse(): string | null;
|
|
438
|
+
/**
|
|
439
|
+
* Install the WRITE_PTY and SIZE trampoline callbacks.
|
|
440
|
+
*
|
|
441
|
+
* Trampolines are shared across all terminals that come from the
|
|
442
|
+
* same WASM instance, but NOT across instances — terminal handles are
|
|
443
|
+
* only unique within their parent module, and table indices in module
|
|
444
|
+
* A are meaningless in module B's table. So we keep a per-table
|
|
445
|
+
* registry (WeakMap keyed on the indirect function table) that owns
|
|
446
|
+
* the slot indices plus the handle→instance routing map for that
|
|
447
|
+
* table.
|
|
448
|
+
*
|
|
449
|
+
* On first use for a given table we instantiate the trampolines,
|
|
450
|
+
* `table.grow(2)`, and write both into the new slots. Subsequent
|
|
451
|
+
* terminals from the same module reuse the registry and just
|
|
452
|
+
* register their handle in instancesByHandle.
|
|
453
|
+
*/
|
|
454
|
+
private installCallbacks;
|
|
455
|
+
/**
|
|
456
|
+
* Query arbitrary terminal mode by number.
|
|
457
|
+
* @param mode Mode number (e.g., 25 for cursor visibility, 2004 for bracketed paste)
|
|
458
|
+
* @param isAnsi True for ANSI modes, false for DEC modes (default: false)
|
|
459
|
+
*/
|
|
460
|
+
getMode(mode: number, isAnsi?: boolean): boolean;
|
|
461
|
+
private initCellPool;
|
|
462
|
+
/**
|
|
463
|
+
* Get all codepoints for a grapheme cluster at the given position.
|
|
464
|
+
* For most cells this returns a single codepoint, but for complex scripts
|
|
465
|
+
* (Hindi, emoji with ZWJ, etc.) it returns multiple codepoints.
|
|
466
|
+
* @returns Array of codepoints, or null on error
|
|
467
|
+
*/
|
|
468
|
+
getGrapheme(row: number, col: number): number[] | null;
|
|
469
|
+
/**
|
|
470
|
+
* Get a string representation of the grapheme at the given position.
|
|
471
|
+
* This properly handles complex scripts like Hindi, emoji with ZWJ, etc.
|
|
472
|
+
*/
|
|
473
|
+
getGraphemeString(row: number, col: number): string;
|
|
474
|
+
/**
|
|
475
|
+
* Get all codepoints for a grapheme cluster in the scrollback buffer.
|
|
476
|
+
* @param offset Scrollback line offset (0 = oldest)
|
|
477
|
+
* @param col Column index
|
|
478
|
+
* @returns Array of codepoints, or null on error
|
|
479
|
+
*/
|
|
480
|
+
getScrollbackGrapheme(offset: number, col: number): number[] | null;
|
|
481
|
+
/**
|
|
482
|
+
* Get a string representation of a grapheme in the scrollback buffer.
|
|
483
|
+
*/
|
|
484
|
+
getScrollbackGraphemeString(offset: number, col: number): string;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Terminal configuration (passed to ghostty_terminal_new_with_config)
|
|
489
|
+
* All color values use 0xRRGGBB format. A value of 0 means "use default".
|
|
490
|
+
*/
|
|
491
|
+
export declare interface GhosttyTerminalConfig {
|
|
492
|
+
/** Scrollback buffer size in bytes. Passed to Terminal.max_scrollback. */
|
|
493
|
+
scrollbackLimit?: number;
|
|
494
|
+
fgColor?: number;
|
|
495
|
+
bgColor?: number;
|
|
496
|
+
cursorColor?: number;
|
|
497
|
+
palette?: number[];
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Interface for libghostty-vt WASM exports
|
|
502
|
+
*/
|
|
503
|
+
declare interface GhosttyWasmExports extends WebAssembly.Exports {
|
|
504
|
+
memory: WebAssembly.Memory;
|
|
505
|
+
ghostty_wasm_alloc_opaque(): number;
|
|
506
|
+
ghostty_wasm_free_opaque(ptr: number): void;
|
|
507
|
+
ghostty_wasm_alloc_u8_array(len: number): number;
|
|
508
|
+
ghostty_wasm_free_u8_array(ptr: number, len: number): void;
|
|
509
|
+
ghostty_wasm_alloc_u16_array(len: number): number;
|
|
510
|
+
ghostty_wasm_free_u16_array(ptr: number, len: number): void;
|
|
511
|
+
ghostty_wasm_alloc_u8(): number;
|
|
512
|
+
ghostty_wasm_free_u8(ptr: number): void;
|
|
513
|
+
ghostty_wasm_alloc_usize(): number;
|
|
514
|
+
ghostty_wasm_free_usize(ptr: number): void;
|
|
515
|
+
ghostty_sgr_new(allocator: number, parserPtrPtr: number): number;
|
|
516
|
+
ghostty_sgr_free(parser: number): void;
|
|
517
|
+
ghostty_sgr_reset(parser: number): void;
|
|
518
|
+
ghostty_sgr_set_params(parser: number, paramsPtr: number, subsPtr: number, paramsLen: number): number;
|
|
519
|
+
ghostty_sgr_next(parser: number, attrPtr: number): boolean;
|
|
520
|
+
ghostty_sgr_attribute_tag(attrPtr: number): number;
|
|
521
|
+
ghostty_sgr_attribute_value(attrPtr: number, tagPtr: number): number;
|
|
522
|
+
ghostty_wasm_alloc_sgr_attribute(): number;
|
|
523
|
+
ghostty_wasm_free_sgr_attribute(ptr: number): void;
|
|
524
|
+
ghostty_key_encoder_new(allocator: number, encoderPtrPtr: number): number;
|
|
525
|
+
ghostty_key_encoder_free(encoder: number): void;
|
|
526
|
+
ghostty_key_encoder_setopt(encoder: number, option: number, valuePtr: number): number;
|
|
527
|
+
ghostty_key_encoder_encode(encoder: number, eventPtr: number, bufPtr: number, bufLen: number, writtenPtr: number): number;
|
|
528
|
+
ghostty_key_event_new(allocator: number, eventPtrPtr: number): number;
|
|
529
|
+
ghostty_key_event_free(event: number): void;
|
|
530
|
+
ghostty_key_event_set_action(event: number, action: number): void;
|
|
531
|
+
ghostty_key_event_set_key(event: number, key: number): void;
|
|
532
|
+
ghostty_key_event_set_mods(event: number, mods: number): void;
|
|
533
|
+
ghostty_key_event_set_utf8(event: number, ptr: number, len: number): void;
|
|
534
|
+
ghostty_terminal_new(allocatorPtr: number, terminalPtrPtr: number, optionsPtr: number): number;
|
|
535
|
+
ghostty_terminal_free(terminal: TerminalHandle): void;
|
|
536
|
+
ghostty_terminal_resize(terminal: TerminalHandle, cols: number, rows: number, cellWidthPx: number, cellHeightPx: number): number;
|
|
537
|
+
ghostty_terminal_vt_write(terminal: TerminalHandle, dataPtr: number, dataLen: number): void;
|
|
538
|
+
ghostty_render_state_new(allocatorPtr: number, statePtrPtr: number): number;
|
|
539
|
+
ghostty_render_state_free(state: number): void;
|
|
540
|
+
ghostty_render_state_update(state: number, terminal: TerminalHandle): number;
|
|
541
|
+
ghostty_render_state_get(state: number, key: number, outPtr: number): number;
|
|
542
|
+
ghostty_render_state_get_multi(state: number, count: number, keysPtr: number, valuesPtr: number, outWrittenPtr: number): number;
|
|
543
|
+
ghostty_render_state_set(state: number, option: number, valuePtr: number): number;
|
|
544
|
+
ghostty_render_state_colors_get(state: number, outColorsPtr: number): number;
|
|
545
|
+
ghostty_render_state_row_iterator_new(allocatorPtr: number, outIterPtrPtr: number): number;
|
|
546
|
+
ghostty_render_state_row_iterator_free(iter: number): void;
|
|
547
|
+
ghostty_render_state_row_iterator_next(iter: number): boolean;
|
|
548
|
+
ghostty_render_state_row_get(iter: number, key: number, outPtr: number): number;
|
|
549
|
+
ghostty_render_state_row_set(iter: number, option: number, valuePtr: number): number;
|
|
550
|
+
ghostty_render_state_row_cells_new(allocatorPtr: number, outCellsPtrPtr: number): number;
|
|
551
|
+
ghostty_render_state_row_cells_free(cells: number): void;
|
|
552
|
+
ghostty_render_state_row_cells_next(cells: number): boolean;
|
|
553
|
+
ghostty_render_state_row_cells_select(cells: number, col: number): number;
|
|
554
|
+
ghostty_render_state_row_cells_get(cells: number, key: number, outPtr: number): number;
|
|
555
|
+
ghostty_render_state_row_cells_get_multi(cells: number, count: number, keysPtr: number, valuesPtr: number, outWrittenPtr: number): number;
|
|
556
|
+
ghostty_cell_get(cell: bigint, key: number, outPtr: number): number;
|
|
557
|
+
ghostty_row_get(row: bigint, key: number, outPtr: number): number;
|
|
558
|
+
ghostty_terminal_grid_ref(terminal: TerminalHandle, pointPtr: number, outRefPtr: number): number;
|
|
559
|
+
ghostty_grid_ref_cell(refPtr: number, outCellPtr: number): number;
|
|
560
|
+
ghostty_grid_ref_row(refPtr: number, outRowPtr: number): number;
|
|
561
|
+
ghostty_grid_ref_graphemes(refPtr: number, bufPtr: number, bufLen: number, outLenPtr: number): number;
|
|
562
|
+
ghostty_grid_ref_hyperlink_uri(refPtr: number, bufPtr: number, bufLen: number, outLenPtr: number): number;
|
|
563
|
+
ghostty_grid_ref_style(refPtr: number, outStylePtr: number): number;
|
|
564
|
+
ghostty_kitty_graphics_get(graphics: number, key: number, outPtr: number): number;
|
|
565
|
+
ghostty_kitty_graphics_image(graphics: number, imageId: number): number;
|
|
566
|
+
ghostty_kitty_graphics_image_get(image: number, key: number, outPtr: number): number;
|
|
567
|
+
ghostty_kitty_graphics_image_get_multi(image: number, count: number, keysPtr: number, valuesPtr: number, outWrittenPtr: number): number;
|
|
568
|
+
ghostty_kitty_graphics_placement_iterator_new(allocatorPtr: number, outIterPtrPtr: number): number;
|
|
569
|
+
ghostty_kitty_graphics_placement_iterator_free(iter: number): void;
|
|
570
|
+
ghostty_kitty_graphics_placement_iterator_set(iter: number, option: number, valuePtr: number): number;
|
|
571
|
+
ghostty_kitty_graphics_placement_next(iter: number): boolean;
|
|
572
|
+
ghostty_kitty_graphics_placement_get(iter: number, key: number, outPtr: number): number;
|
|
573
|
+
ghostty_kitty_graphics_placement_get_multi(iter: number, count: number, keysPtr: number, valuesPtr: number, outWrittenPtr: number): number;
|
|
574
|
+
ghostty_kitty_graphics_placement_rect(iter: number, image: number, terminal: TerminalHandle, outSelectionPtr: number): number;
|
|
575
|
+
ghostty_kitty_graphics_placement_pixel_size(iter: number, image: number, terminal: TerminalHandle, outWidthPtr: number, outHeightPtr: number): number;
|
|
576
|
+
ghostty_kitty_graphics_placement_grid_size(iter: number, image: number, terminal: TerminalHandle, outColsPtr: number, outRowsPtr: number): number;
|
|
577
|
+
ghostty_kitty_graphics_placement_viewport_pos(iter: number, image: number, terminal: TerminalHandle, outColPtr: number, outRowPtr: number): number;
|
|
578
|
+
ghostty_kitty_graphics_placement_source_rect(iter: number, image: number, outX: number, outY: number, outW: number, outH: number): number;
|
|
579
|
+
ghostty_kitty_graphics_placement_render_info(iter: number, image: number, terminal: TerminalHandle, outInfoPtr: number): number;
|
|
580
|
+
ghostty_terminal_get(terminal: TerminalHandle, key: number, outPtr: number): number;
|
|
581
|
+
ghostty_terminal_get_multi(terminal: TerminalHandle, count: number, keysPtr: number, valuesPtr: number, outWrittenPtr: number): number;
|
|
582
|
+
ghostty_terminal_set(terminal: TerminalHandle, option: number, valuePtr: number): number;
|
|
583
|
+
ghostty_sys_set(option: number, valuePtr: number): number;
|
|
584
|
+
ghostty_alloc(allocatorPtr: number, len: number): number;
|
|
585
|
+
ghostty_free(allocatorPtr: number, ptr: number, len: number): void;
|
|
586
|
+
ghostty_terminal_mode_get(terminal: TerminalHandle, mode: number, outBoolPtr: number): number;
|
|
587
|
+
ghostty_terminal_mode_set(terminal: TerminalHandle, mode: number, value: boolean): number;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* A terminal buffer (normal or alternate screen)
|
|
592
|
+
*/
|
|
593
|
+
export declare interface IBuffer {
|
|
594
|
+
/** Buffer type: 'normal' or 'alternate' */
|
|
595
|
+
readonly type: 'normal' | 'alternate';
|
|
596
|
+
/** Cursor X position (0-indexed) */
|
|
597
|
+
readonly cursorX: number;
|
|
598
|
+
/** Cursor Y position (0-indexed, relative to viewport) */
|
|
599
|
+
readonly cursorY: number;
|
|
600
|
+
/** Viewport Y position (scroll offset, 0 = bottom of scrollback) */
|
|
601
|
+
readonly viewportY: number;
|
|
602
|
+
/** Base Y position (always 0 for normal buffer, may vary for alternate) */
|
|
603
|
+
readonly baseY: number;
|
|
604
|
+
/** Total buffer length (rows + scrollback for normal, just rows for alternate) */
|
|
605
|
+
readonly length: number;
|
|
606
|
+
/**
|
|
607
|
+
* Get a line from the buffer
|
|
608
|
+
* @param y Line index (0 = top of scrollback for normal buffer)
|
|
609
|
+
* @returns Line object or undefined if out of bounds
|
|
610
|
+
*/
|
|
611
|
+
getLine(y: number): IBufferLine | undefined;
|
|
612
|
+
/**
|
|
613
|
+
* Get the null cell (used for empty/uninitialized cells)
|
|
614
|
+
*/
|
|
615
|
+
getNullCell(): IBufferCell;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* A single cell in the buffer
|
|
620
|
+
*/
|
|
621
|
+
export declare interface IBufferCell {
|
|
622
|
+
/** Character(s) in this cell (may be empty, single char, or emoji) */
|
|
623
|
+
getChars(): string;
|
|
624
|
+
/** Unicode codepoint (0 for null cell) */
|
|
625
|
+
getCode(): number;
|
|
626
|
+
/** Character width (1 = normal, 2 = wide/emoji, 0 = combining) */
|
|
627
|
+
getWidth(): number;
|
|
628
|
+
/** Foreground color index (for palette colors) or -1 for RGB */
|
|
629
|
+
getFgColorMode(): number;
|
|
630
|
+
/** Background color index (for palette colors) or -1 for RGB */
|
|
631
|
+
getBgColorMode(): number;
|
|
632
|
+
/** Foreground RGB color (or 0 for default) */
|
|
633
|
+
getFgColor(): number;
|
|
634
|
+
/** Background RGB color (or 0 for default) */
|
|
635
|
+
getBgColor(): number;
|
|
636
|
+
/** Whether cell has bold style */
|
|
637
|
+
isBold(): number;
|
|
638
|
+
/** Whether cell has italic style */
|
|
639
|
+
isItalic(): number;
|
|
640
|
+
/** Whether cell has underline style */
|
|
641
|
+
isUnderline(): number;
|
|
642
|
+
/** Whether cell has strikethrough style */
|
|
643
|
+
isStrikethrough(): number;
|
|
644
|
+
/** Whether cell has blink style */
|
|
645
|
+
isBlink(): number;
|
|
646
|
+
/** Whether cell has inverse video style */
|
|
647
|
+
isInverse(): number;
|
|
648
|
+
/** Whether cell has invisible style */
|
|
649
|
+
isInvisible(): number;
|
|
650
|
+
/** Whether cell has faint/dim style */
|
|
651
|
+
isFaint(): number;
|
|
652
|
+
/** Get hyperlink ID for this cell (0 = no link) */
|
|
653
|
+
getHyperlinkId(): number;
|
|
654
|
+
/** Get the Unicode codepoint for this cell */
|
|
655
|
+
getCodepoint(): number;
|
|
656
|
+
/** Whether cell has dim/faint attribute (boolean version) */
|
|
657
|
+
isDim(): boolean;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* A single line in the buffer
|
|
662
|
+
*/
|
|
663
|
+
export declare interface IBufferLine {
|
|
664
|
+
/** Length of the line (in columns) */
|
|
665
|
+
readonly length: number;
|
|
666
|
+
/** Whether this line wraps to the next line */
|
|
667
|
+
readonly isWrapped: boolean;
|
|
668
|
+
/**
|
|
669
|
+
* Get a cell from this line
|
|
670
|
+
* @param x Column index (0-indexed)
|
|
671
|
+
* @returns Cell object or undefined if out of bounds
|
|
672
|
+
*/
|
|
673
|
+
getCell(x: number): IBufferCell | undefined;
|
|
674
|
+
/**
|
|
675
|
+
* Translate the line to a string
|
|
676
|
+
* @param trimRight Whether to trim trailing whitespace (default: false)
|
|
677
|
+
* @param startColumn Start column (default: 0)
|
|
678
|
+
* @param endColumn End column (default: length)
|
|
679
|
+
* @returns String representation of the line
|
|
680
|
+
*/
|
|
681
|
+
translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Top-level buffer API namespace
|
|
686
|
+
* Provides access to active, normal, and alternate screen buffers
|
|
687
|
+
*/
|
|
688
|
+
export declare interface IBufferNamespace {
|
|
689
|
+
/** The currently active buffer (normal or alternate) */
|
|
690
|
+
readonly active: IBuffer;
|
|
691
|
+
/** The normal buffer (primary screen) */
|
|
692
|
+
readonly normal: IBuffer;
|
|
693
|
+
/** The alternate buffer (used by full-screen apps like vim) */
|
|
694
|
+
readonly alternate: IBuffer;
|
|
695
|
+
/** Event fired when buffer changes (normal ↔ alternate) */
|
|
696
|
+
readonly onBufferChange: IEvent<IBuffer>;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* Buffer range for selection coordinates
|
|
701
|
+
*/
|
|
702
|
+
export declare interface IBufferRange {
|
|
703
|
+
start: {
|
|
704
|
+
x: number;
|
|
705
|
+
y: number;
|
|
706
|
+
};
|
|
707
|
+
end: {
|
|
708
|
+
x: number;
|
|
709
|
+
y: number;
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
export declare interface IDisposable {
|
|
714
|
+
dispose(): void;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
export declare type IEvent<T> = (listener: (arg: T) => void) => IDisposable;
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* Initialize ghostty-web headless. Must be called before creating Terminal instances.
|
|
721
|
+
*/
|
|
722
|
+
export declare function init(wasmPath?: string): Promise<void>;
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* Check if ghostty-web headless has been initialized.
|
|
726
|
+
*/
|
|
727
|
+
export declare function isInitialized(): boolean;
|
|
728
|
+
|
|
729
|
+
export declare interface ITerminalAddon {
|
|
730
|
+
activate(terminal: ITerminalCore): void;
|
|
731
|
+
dispose(): void;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
declare interface ITerminalCore {
|
|
735
|
+
cols: number;
|
|
736
|
+
rows: number;
|
|
737
|
+
element?: HTMLElement;
|
|
738
|
+
textarea?: HTMLTextAreaElement;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
export declare interface ITerminalOptions {
|
|
742
|
+
cols?: number;
|
|
743
|
+
rows?: number;
|
|
744
|
+
cursorBlink?: boolean;
|
|
745
|
+
cursorStyle?: 'block' | 'underline' | 'bar';
|
|
746
|
+
theme?: ITheme;
|
|
747
|
+
scrollback?: number;
|
|
748
|
+
fontSize?: number;
|
|
749
|
+
fontFamily?: string;
|
|
750
|
+
allowTransparency?: boolean;
|
|
751
|
+
convertEol?: boolean;
|
|
752
|
+
disableStdin?: boolean;
|
|
753
|
+
focusOnOpen?: boolean;
|
|
754
|
+
smoothScrollDuration?: number;
|
|
755
|
+
/**
|
|
756
|
+
* When true, the viewport stays locked on the same scrollback content as
|
|
757
|
+
* new output arrives — instead of auto-scrolling to the bottom. Mirrors
|
|
758
|
+
* the behaviour of modern terminals (kitty, alacritty). Default: false
|
|
759
|
+
* (preserves the xterm.js-style auto-scroll behaviour for back-compat).
|
|
760
|
+
*/
|
|
761
|
+
preserveScrollOnWrite?: boolean;
|
|
762
|
+
emitTerminalResponses?: boolean;
|
|
763
|
+
ghostty?: Ghostty;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
export declare interface ITheme {
|
|
767
|
+
foreground?: string;
|
|
768
|
+
background?: string;
|
|
769
|
+
cursor?: string;
|
|
770
|
+
cursorAccent?: string;
|
|
771
|
+
selectionBackground?: string;
|
|
772
|
+
selectionForeground?: string;
|
|
773
|
+
black?: string;
|
|
774
|
+
red?: string;
|
|
775
|
+
green?: string;
|
|
776
|
+
yellow?: string;
|
|
777
|
+
blue?: string;
|
|
778
|
+
magenta?: string;
|
|
779
|
+
cyan?: string;
|
|
780
|
+
white?: string;
|
|
781
|
+
brightBlack?: string;
|
|
782
|
+
brightRed?: string;
|
|
783
|
+
brightGreen?: string;
|
|
784
|
+
brightYellow?: string;
|
|
785
|
+
brightBlue?: string;
|
|
786
|
+
brightMagenta?: string;
|
|
787
|
+
brightCyan?: string;
|
|
788
|
+
brightWhite?: string;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* Physical key codes matching Ghostty's internal Key enum.
|
|
793
|
+
* These values are used by Ghostty's key encoder to produce correct escape sequences.
|
|
794
|
+
* Reference: ghostty/src/input/key.zig
|
|
795
|
+
*/
|
|
796
|
+
declare enum Key {
|
|
797
|
+
UNIDENTIFIED = 0,
|
|
798
|
+
GRAVE = 1,// ` and ~
|
|
799
|
+
BACKSLASH = 2,// \ and |
|
|
800
|
+
BRACKET_LEFT = 3,// [ and {
|
|
801
|
+
BRACKET_RIGHT = 4,// ] and }
|
|
802
|
+
COMMA = 5,// , and <
|
|
803
|
+
ZERO = 6,
|
|
804
|
+
ONE = 7,
|
|
805
|
+
TWO = 8,
|
|
806
|
+
THREE = 9,
|
|
807
|
+
FOUR = 10,
|
|
808
|
+
FIVE = 11,
|
|
809
|
+
SIX = 12,
|
|
810
|
+
SEVEN = 13,
|
|
811
|
+
EIGHT = 14,
|
|
812
|
+
NINE = 15,
|
|
813
|
+
EQUAL = 16,// = and +
|
|
814
|
+
INTL_BACKSLASH = 17,
|
|
815
|
+
INTL_RO = 18,
|
|
816
|
+
INTL_YEN = 19,
|
|
817
|
+
A = 20,
|
|
818
|
+
B = 21,
|
|
819
|
+
C = 22,
|
|
820
|
+
D = 23,
|
|
821
|
+
E = 24,
|
|
822
|
+
F = 25,
|
|
823
|
+
G = 26,
|
|
824
|
+
H = 27,
|
|
825
|
+
I = 28,
|
|
826
|
+
J = 29,
|
|
827
|
+
K = 30,
|
|
828
|
+
L = 31,
|
|
829
|
+
M = 32,
|
|
830
|
+
N = 33,
|
|
831
|
+
O = 34,
|
|
832
|
+
P = 35,
|
|
833
|
+
Q = 36,
|
|
834
|
+
R = 37,
|
|
835
|
+
S = 38,
|
|
836
|
+
T = 39,
|
|
837
|
+
U = 40,
|
|
838
|
+
V = 41,
|
|
839
|
+
W = 42,
|
|
840
|
+
X = 43,
|
|
841
|
+
Y = 44,
|
|
842
|
+
Z = 45,
|
|
843
|
+
MINUS = 46,// - and _
|
|
844
|
+
PERIOD = 47,// . and >
|
|
845
|
+
QUOTE = 48,// ' and "
|
|
846
|
+
SEMICOLON = 49,// ; and :
|
|
847
|
+
SLASH = 50,// / and ?
|
|
848
|
+
ALT_LEFT = 51,
|
|
849
|
+
ALT_RIGHT = 52,
|
|
850
|
+
BACKSPACE = 53,
|
|
851
|
+
CAPS_LOCK = 54,
|
|
852
|
+
CONTEXT_MENU = 55,
|
|
853
|
+
CONTROL_LEFT = 56,
|
|
854
|
+
CONTROL_RIGHT = 57,
|
|
855
|
+
ENTER = 58,
|
|
856
|
+
META_LEFT = 59,
|
|
857
|
+
META_RIGHT = 60,
|
|
858
|
+
SHIFT_LEFT = 61,
|
|
859
|
+
SHIFT_RIGHT = 62,
|
|
860
|
+
SPACE = 63,
|
|
861
|
+
TAB = 64,
|
|
862
|
+
CONVERT = 65,
|
|
863
|
+
KANA_MODE = 66,
|
|
864
|
+
NON_CONVERT = 67,
|
|
865
|
+
DELETE = 68,
|
|
866
|
+
END = 69,
|
|
867
|
+
HELP = 70,
|
|
868
|
+
HOME = 71,
|
|
869
|
+
INSERT = 72,
|
|
870
|
+
PAGE_DOWN = 73,
|
|
871
|
+
PAGE_UP = 74,
|
|
872
|
+
DOWN = 75,
|
|
873
|
+
LEFT = 76,
|
|
874
|
+
RIGHT = 77,
|
|
875
|
+
UP = 78,
|
|
876
|
+
NUM_LOCK = 79,
|
|
877
|
+
KP_0 = 80,
|
|
878
|
+
KP_1 = 81,
|
|
879
|
+
KP_2 = 82,
|
|
880
|
+
KP_3 = 83,
|
|
881
|
+
KP_4 = 84,
|
|
882
|
+
KP_5 = 85,
|
|
883
|
+
KP_6 = 86,
|
|
884
|
+
KP_7 = 87,
|
|
885
|
+
KP_8 = 88,
|
|
886
|
+
KP_9 = 89,
|
|
887
|
+
KP_PLUS = 90,// Keypad +
|
|
888
|
+
KP_BACKSPACE = 91,
|
|
889
|
+
KP_CLEAR = 92,
|
|
890
|
+
KP_CLEAR_ENTRY = 93,
|
|
891
|
+
KP_COMMA = 94,
|
|
892
|
+
KP_PERIOD = 95,// Keypad .
|
|
893
|
+
KP_DIVIDE = 96,// Keypad /
|
|
894
|
+
KP_ENTER = 97,// Keypad Enter
|
|
895
|
+
KP_EQUAL = 98,
|
|
896
|
+
KP_MEMORY_ADD = 99,
|
|
897
|
+
KP_MEMORY_CLEAR = 100,
|
|
898
|
+
KP_MEMORY_RECALL = 101,
|
|
899
|
+
KP_MEMORY_STORE = 102,
|
|
900
|
+
KP_MEMORY_SUBTRACT = 103,
|
|
901
|
+
KP_MULTIPLY = 104,// Keypad *
|
|
902
|
+
KP_PAREN_LEFT = 105,
|
|
903
|
+
KP_PAREN_RIGHT = 106,
|
|
904
|
+
KP_MINUS = 107,// Keypad -
|
|
905
|
+
KP_SEPARATOR = 108,
|
|
906
|
+
NUMPAD_UP = 109,
|
|
907
|
+
NUMPAD_DOWN = 110,
|
|
908
|
+
NUMPAD_RIGHT = 111,
|
|
909
|
+
NUMPAD_LEFT = 112,
|
|
910
|
+
NUMPAD_BEGIN = 113,
|
|
911
|
+
NUMPAD_HOME = 114,
|
|
912
|
+
NUMPAD_END = 115,
|
|
913
|
+
NUMPAD_INSERT = 116,
|
|
914
|
+
NUMPAD_DELETE = 117,
|
|
915
|
+
NUMPAD_PAGE_UP = 118,
|
|
916
|
+
NUMPAD_PAGE_DOWN = 119,
|
|
917
|
+
ESCAPE = 120,
|
|
918
|
+
F1 = 121,
|
|
919
|
+
F2 = 122,
|
|
920
|
+
F3 = 123,
|
|
921
|
+
F4 = 124,
|
|
922
|
+
F5 = 125,
|
|
923
|
+
F6 = 126,
|
|
924
|
+
F7 = 127,
|
|
925
|
+
F8 = 128,
|
|
926
|
+
F9 = 129,
|
|
927
|
+
F10 = 130,
|
|
928
|
+
F11 = 131,
|
|
929
|
+
F12 = 132,
|
|
930
|
+
F13 = 133,
|
|
931
|
+
F14 = 134,
|
|
932
|
+
F15 = 135,
|
|
933
|
+
F16 = 136,
|
|
934
|
+
F17 = 137,
|
|
935
|
+
F18 = 138,
|
|
936
|
+
F19 = 139,
|
|
937
|
+
F20 = 140,
|
|
938
|
+
F21 = 141,
|
|
939
|
+
F22 = 142,
|
|
940
|
+
F23 = 143,
|
|
941
|
+
F24 = 144,
|
|
942
|
+
F25 = 145,
|
|
943
|
+
FN_LOCK = 146,
|
|
944
|
+
PRINT_SCREEN = 147,
|
|
945
|
+
SCROLL_LOCK = 148,
|
|
946
|
+
PAUSE = 149,
|
|
947
|
+
BROWSER_BACK = 150,
|
|
948
|
+
BROWSER_FAVORITES = 151,
|
|
949
|
+
BROWSER_FORWARD = 152,
|
|
950
|
+
BROWSER_HOME = 153,
|
|
951
|
+
BROWSER_REFRESH = 154,
|
|
952
|
+
BROWSER_SEARCH = 155,
|
|
953
|
+
BROWSER_STOP = 156,
|
|
954
|
+
EJECT = 157,
|
|
955
|
+
LAUNCH_APP_1 = 158,
|
|
956
|
+
LAUNCH_APP_2 = 159,
|
|
957
|
+
LAUNCH_MAIL = 160,
|
|
958
|
+
MEDIA_PLAY_PAUSE = 161,
|
|
959
|
+
MEDIA_SELECT = 162,
|
|
960
|
+
MEDIA_STOP = 163,
|
|
961
|
+
MEDIA_TRACK_NEXT = 164,
|
|
962
|
+
MEDIA_TRACK_PREVIOUS = 165,
|
|
963
|
+
POWER = 166,
|
|
964
|
+
SLEEP = 167,
|
|
965
|
+
AUDIO_VOLUME_DOWN = 168,
|
|
966
|
+
AUDIO_VOLUME_MUTE = 169,
|
|
967
|
+
AUDIO_VOLUME_UP = 170,
|
|
968
|
+
WAKE_UP = 171,
|
|
969
|
+
COPY = 172,
|
|
970
|
+
CUT = 173,
|
|
971
|
+
PASTE = 174
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
/**
|
|
975
|
+
* Key action
|
|
976
|
+
*/
|
|
977
|
+
declare enum KeyAction {
|
|
978
|
+
RELEASE = 0,
|
|
979
|
+
PRESS = 1,
|
|
980
|
+
REPEAT = 2
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
/**
|
|
984
|
+
* Key Encoder - converts keyboard events into terminal escape sequences
|
|
985
|
+
*/
|
|
986
|
+
declare class KeyEncoder {
|
|
987
|
+
private exports;
|
|
988
|
+
private encoder;
|
|
989
|
+
constructor(exports: GhosttyWasmExports);
|
|
990
|
+
setOption(option: KeyEncoderOption, value: boolean | number): void;
|
|
991
|
+
setKittyFlags(flags: KittyKeyFlags): void;
|
|
992
|
+
encode(event: KeyEvent): Uint8Array;
|
|
993
|
+
dispose(): void;
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
/**
|
|
997
|
+
* Key encoder options
|
|
998
|
+
*/
|
|
999
|
+
declare enum KeyEncoderOption {
|
|
1000
|
+
CURSOR_KEY_APPLICATION = 0,// DEC mode 1
|
|
1001
|
+
KEYPAD_KEY_APPLICATION = 1,// DEC mode 66
|
|
1002
|
+
IGNORE_KEYPAD_WITH_NUMLOCK = 2,// DEC mode 1035
|
|
1003
|
+
ALT_ESC_PREFIX = 3,// DEC mode 1036
|
|
1004
|
+
MODIFY_OTHER_KEYS_STATE_2 = 4,// xterm modifyOtherKeys
|
|
1005
|
+
KITTY_KEYBOARD_FLAGS = 5
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
/**
|
|
1009
|
+
* Key event structure
|
|
1010
|
+
*/
|
|
1011
|
+
declare interface KeyEvent {
|
|
1012
|
+
action: KeyAction;
|
|
1013
|
+
key: Key;
|
|
1014
|
+
mods: Mods;
|
|
1015
|
+
consumedMods?: Mods;
|
|
1016
|
+
composing?: boolean;
|
|
1017
|
+
utf8?: string;
|
|
1018
|
+
unshiftedCodepoint?: number;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
/**
|
|
1022
|
+
* Pixel format of a Kitty graphics image. Mirrors GhosttyKittyImageFormat.
|
|
1023
|
+
* RGB: 24-bit, 3 bytes/px
|
|
1024
|
+
* RGBA: 32-bit, 4 bytes/px (the canvas-friendly path)
|
|
1025
|
+
* PNG: compressed; needs a JS-side decoder hooked up via
|
|
1026
|
+
* ghostty_sys_set(DECODE_PNG, fn)
|
|
1027
|
+
* GRAY_ALPHA: 16-bit, 2 bytes/px
|
|
1028
|
+
* GRAY: 8-bit, 1 byte/px
|
|
1029
|
+
*/
|
|
1030
|
+
declare enum KittyImageFormat {
|
|
1031
|
+
RGB = 0,
|
|
1032
|
+
RGBA = 1,
|
|
1033
|
+
PNG = 2,
|
|
1034
|
+
GRAY_ALPHA = 3,
|
|
1035
|
+
GRAY = 4
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
/**
|
|
1039
|
+
* Image bytes + metadata returned by GhosttyTerminal.getKittyImageRgba.
|
|
1040
|
+
* `data` is a *view* into WASM memory and is invalidated by the next
|
|
1041
|
+
* mutating terminal call — copy out before vt_write if you need to retain.
|
|
1042
|
+
*/
|
|
1043
|
+
declare interface KittyImagePixels {
|
|
1044
|
+
width: number;
|
|
1045
|
+
height: number;
|
|
1046
|
+
format: KittyImageFormat;
|
|
1047
|
+
/** Borrowed view into WASM memory; copy before vt_write to retain. */
|
|
1048
|
+
data: Uint8Array;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
/**
|
|
1052
|
+
* Kitty keyboard protocol flags
|
|
1053
|
+
* From include/ghostty/vt/key/encoder.h
|
|
1054
|
+
*/
|
|
1055
|
+
declare enum KittyKeyFlags {
|
|
1056
|
+
DISABLED = 0,
|
|
1057
|
+
DISAMBIGUATE = 1,// Disambiguate escape codes
|
|
1058
|
+
REPORT_EVENTS = 2,// Report press and release
|
|
1059
|
+
REPORT_ALTERNATES = 4,// Report alternate key codes
|
|
1060
|
+
REPORT_ALL = 8,// Report all events
|
|
1061
|
+
REPORT_ASSOCIATED = 16,// Report associated text
|
|
1062
|
+
ALL = 31
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
/**
|
|
1066
|
+
* Parsed GhosttyKittyGraphicsPlacementRenderInfo — everything the renderer
|
|
1067
|
+
* needs about a single placement to composite it on the canvas.
|
|
1068
|
+
*
|
|
1069
|
+
* Wire layout on wasm32 (48 bytes, extern struct, 4-byte aligned):
|
|
1070
|
+
* size: u32 @ 0 (sized-struct discriminator; we just write 48)
|
|
1071
|
+
* pixel_width: u32 @ 4
|
|
1072
|
+
* pixel_height: u32 @ 8
|
|
1073
|
+
* grid_cols: u32 @ 12
|
|
1074
|
+
* grid_rows: u32 @ 16
|
|
1075
|
+
* viewport_col: i32 @ 20
|
|
1076
|
+
* viewport_row: i32 @ 24
|
|
1077
|
+
* viewport_visible: bool @ 28 (1 byte + 3 bytes padding to next u32)
|
|
1078
|
+
* source_x: u32 @ 32
|
|
1079
|
+
* source_y: u32 @ 36
|
|
1080
|
+
* source_width: u32 @ 40
|
|
1081
|
+
* source_height: u32 @ 44
|
|
1082
|
+
*/
|
|
1083
|
+
declare interface KittyPlacementInfo {
|
|
1084
|
+
imageId: number;
|
|
1085
|
+
/** Destination size on the canvas, in pixels. */
|
|
1086
|
+
pixelWidth: number;
|
|
1087
|
+
pixelHeight: number;
|
|
1088
|
+
/** Destination size on the grid, in cells. */
|
|
1089
|
+
gridCols: number;
|
|
1090
|
+
gridRows: number;
|
|
1091
|
+
/** Top-left in viewport-relative cells. Negative when scrolled partway off the top. */
|
|
1092
|
+
viewportCol: number;
|
|
1093
|
+
viewportRow: number;
|
|
1094
|
+
/** Whether any part of the placement intersects the visible viewport. */
|
|
1095
|
+
viewportVisible: boolean;
|
|
1096
|
+
/** Source rect within the image, in pixels (already clamped to image bounds). */
|
|
1097
|
+
sourceX: number;
|
|
1098
|
+
sourceY: number;
|
|
1099
|
+
sourceWidth: number;
|
|
1100
|
+
sourceHeight: number;
|
|
1101
|
+
/**
|
|
1102
|
+
* Virtual placements have no fixed viewport position; their image is
|
|
1103
|
+
* drawn into U+10EEEE placeholder cells written to the grid by the
|
|
1104
|
+
* application. The renderer picks them up by image_id rather than
|
|
1105
|
+
* iterating through them for direct compositing.
|
|
1106
|
+
*/
|
|
1107
|
+
isVirtual: boolean;
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
/**
|
|
1111
|
+
* Modifier keys
|
|
1112
|
+
*/
|
|
1113
|
+
declare enum Mods {
|
|
1114
|
+
NONE = 0,
|
|
1115
|
+
SHIFT = 1,
|
|
1116
|
+
CTRL = 2,
|
|
1117
|
+
ALT = 4,
|
|
1118
|
+
SUPER = 8,// Windows/Command key
|
|
1119
|
+
CAPSLOCK = 16,
|
|
1120
|
+
NUMLOCK = 32
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
/**
|
|
1124
|
+
* Colors from RenderState (12 bytes packed)
|
|
1125
|
+
*/
|
|
1126
|
+
declare interface RenderStateColors {
|
|
1127
|
+
background: RGB;
|
|
1128
|
+
foreground: RGB;
|
|
1129
|
+
cursor: RGB | null;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
/**
|
|
1133
|
+
* Cursor state from RenderState (8 bytes packed)
|
|
1134
|
+
* Layout: x(u16) + y(u16) + viewport_x(i16) + viewport_y(i16) + visible(bool) + blinking(bool) + style(u8) + _pad(u8)
|
|
1135
|
+
*/
|
|
1136
|
+
declare interface RenderStateCursor {
|
|
1137
|
+
x: number;
|
|
1138
|
+
y: number;
|
|
1139
|
+
viewportX: number;
|
|
1140
|
+
viewportY: number;
|
|
1141
|
+
visible: boolean;
|
|
1142
|
+
blinking: boolean;
|
|
1143
|
+
style: 'block' | 'underline' | 'bar';
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
/**
|
|
1147
|
+
* RGB color
|
|
1148
|
+
*/
|
|
1149
|
+
export declare interface RGB {
|
|
1150
|
+
r: number;
|
|
1151
|
+
g: number;
|
|
1152
|
+
b: number;
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
/**
|
|
1156
|
+
* Headless Terminal — same API as @xterm/headless.
|
|
1157
|
+
*
|
|
1158
|
+
* @example
|
|
1159
|
+
* ```typescript
|
|
1160
|
+
* import { init, Terminal } from 'ghostty-web/headless';
|
|
1161
|
+
*
|
|
1162
|
+
* await init();
|
|
1163
|
+
* const term = new Terminal({ cols: 80, rows: 24, scrollback: 1000 });
|
|
1164
|
+
* term.write('\x1b[31mRed text\x1b[0m\r\n');
|
|
1165
|
+
*
|
|
1166
|
+
* const line = term.buffer.active.getLine(0);
|
|
1167
|
+
* console.log(line?.translateToString());
|
|
1168
|
+
* ```
|
|
1169
|
+
*/
|
|
1170
|
+
export declare class Terminal extends TerminalCore {
|
|
1171
|
+
constructor(options?: ITerminalOptions);
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
declare class TerminalCore implements IDisposable {
|
|
1175
|
+
cols: number;
|
|
1176
|
+
rows: number;
|
|
1177
|
+
readonly buffer: IBufferNamespace;
|
|
1178
|
+
readonly options: Required<ITerminalOptions>;
|
|
1179
|
+
protected ghostty: Ghostty;
|
|
1180
|
+
wasmTerm?: GhosttyTerminal;
|
|
1181
|
+
protected dataEmitter: EventEmitter<string>;
|
|
1182
|
+
protected resizeEmitter: EventEmitter<{
|
|
1183
|
+
cols: number;
|
|
1184
|
+
rows: number;
|
|
1185
|
+
}>;
|
|
1186
|
+
protected bellEmitter: EventEmitter<void>;
|
|
1187
|
+
protected titleChangeEmitter: EventEmitter<string>;
|
|
1188
|
+
protected scrollEmitter: EventEmitter<number>;
|
|
1189
|
+
protected cursorMoveEmitter: EventEmitter<void>;
|
|
1190
|
+
protected lineFeedEmitter: EventEmitter<void>;
|
|
1191
|
+
protected writeParsedEmitter: EventEmitter<void>;
|
|
1192
|
+
protected binaryEmitter: EventEmitter<string>;
|
|
1193
|
+
protected promptStartEmitter: EventEmitter<void>;
|
|
1194
|
+
protected commandStartEmitter: EventEmitter<void>;
|
|
1195
|
+
protected commandEndEmitter: EventEmitter<{
|
|
1196
|
+
exitCode: number | undefined;
|
|
1197
|
+
}>;
|
|
1198
|
+
readonly onData: IEvent<string>;
|
|
1199
|
+
readonly onResize: IEvent<{
|
|
1200
|
+
cols: number;
|
|
1201
|
+
rows: number;
|
|
1202
|
+
}>;
|
|
1203
|
+
readonly onBell: IEvent<void>;
|
|
1204
|
+
readonly onTitleChange: IEvent<string>;
|
|
1205
|
+
readonly onScroll: IEvent<number>;
|
|
1206
|
+
readonly onCursorMove: IEvent<void>;
|
|
1207
|
+
readonly onLineFeed: IEvent<void>;
|
|
1208
|
+
readonly onWriteParsed: IEvent<void>;
|
|
1209
|
+
readonly onBinary: IEvent<string>;
|
|
1210
|
+
/** Fires when OSC 133 A is received (shell prompt is about to be drawn). */
|
|
1211
|
+
readonly onPromptStart: IEvent<void>;
|
|
1212
|
+
/** Fires when OSC 133 C is received (user hit Enter — command is running). */
|
|
1213
|
+
readonly onCommandStart: IEvent<void>;
|
|
1214
|
+
/** Fires when OSC 133 D is received (command finished). exitCode is undefined if not reported. */
|
|
1215
|
+
readonly onCommandEnd: IEvent<{
|
|
1216
|
+
exitCode: number | undefined;
|
|
1217
|
+
}>;
|
|
1218
|
+
protected isDisposed: boolean;
|
|
1219
|
+
protected addons: ITerminalAddon[];
|
|
1220
|
+
protected currentTitle: string;
|
|
1221
|
+
protected lastCursorY: number;
|
|
1222
|
+
protected lastCursorX: number;
|
|
1223
|
+
protected _viewportY: number;
|
|
1224
|
+
protected _markers: any[];
|
|
1225
|
+
constructor(ghostty: Ghostty, options?: ITerminalOptions);
|
|
1226
|
+
get markers(): ReadonlyArray<any>;
|
|
1227
|
+
protected handleOptionChange(key: string, _newValue: any, _oldValue: any): void;
|
|
1228
|
+
write(data: string | Uint8Array, callback?: () => void): void;
|
|
1229
|
+
writeln(data: string | Uint8Array, callback?: () => void): void;
|
|
1230
|
+
input(data: string, wasUserInput?: boolean): void;
|
|
1231
|
+
resize(cols: number, rows: number): void;
|
|
1232
|
+
reset(): void;
|
|
1233
|
+
clear(): void;
|
|
1234
|
+
dispose(): void;
|
|
1235
|
+
scrollLines(amount: number): void;
|
|
1236
|
+
scrollPages(pageCount: number): void;
|
|
1237
|
+
scrollToTop(): void;
|
|
1238
|
+
scrollToBottom(): void;
|
|
1239
|
+
scrollToLine(line: number): void;
|
|
1240
|
+
registerMarker(_cursorYOffset?: number): any | undefined;
|
|
1241
|
+
loadAddon(addon: ITerminalAddon): void;
|
|
1242
|
+
getViewportY(): number;
|
|
1243
|
+
getScrollbackLength(): number;
|
|
1244
|
+
getScrollbackLine(offset: number): GhosttyCell[] | null;
|
|
1245
|
+
getMode(mode: number, isAnsi?: boolean): boolean;
|
|
1246
|
+
hasBracketedPaste(): boolean;
|
|
1247
|
+
hasFocusEvents(): boolean;
|
|
1248
|
+
hasMouseTracking(): boolean;
|
|
1249
|
+
protected parseColorToHex(color?: string): number;
|
|
1250
|
+
protected buildWasmConfig(): GhosttyTerminalConfig | undefined;
|
|
1251
|
+
protected processTerminalResponses(): void;
|
|
1252
|
+
/**
|
|
1253
|
+
* Intercept OSC 133 shell-integration markers in outgoing PTY data.
|
|
1254
|
+
*
|
|
1255
|
+
* A = prompt start B = input start (ignored here, fires with A)
|
|
1256
|
+
* C = command start D = command end (optionally with exit code)
|
|
1257
|
+
*
|
|
1258
|
+
* Sequences span a single write in practice; partial-write edge cases
|
|
1259
|
+
* are not handled — the common case is one atomic write per marker.
|
|
1260
|
+
*/
|
|
1261
|
+
protected checkForShellIntegration(data: string): void;
|
|
1262
|
+
protected checkForTitleChange(data: string): void;
|
|
1263
|
+
protected checkCursorMove(): void;
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
/**
|
|
1267
|
+
* Opaque terminal pointer (WASM memory address)
|
|
1268
|
+
*/
|
|
1269
|
+
declare type TerminalHandle = number;
|
|
1270
|
+
|
|
1271
|
+
export { }
|