-
Notifications
You must be signed in to change notification settings - Fork 155
Expand file tree
/
Copy pathterminal-core.ts
More file actions
70 lines (60 loc) · 1.76 KB
/
Copy pathterminal-core.ts
File metadata and controls
70 lines (60 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
export interface CellData {
char: number;
fg: number;
bg: number;
flags: number;
/** Display width: 1 = narrow, 2 = wide leading cell, 0 = wide continuation cell. */
width?: number;
/** Resolved 24-bit foreground color (0xRRGGBB). Present when the core provides true color. */
fgRgb?: number;
/** Resolved 24-bit background color (0xRRGGBB). Present when the core provides true color. */
bgRgb?: number;
}
export interface CursorState {
row: number;
col: number;
visible: boolean;
}
export interface UnhandledSequence {
final: string;
private: string;
paramCount: number;
params: number[];
}
/**
* Abstract terminal emulation core. Both the built-in Zig WASM core
* (`WasmBridge`) and alternative backends (e.g. `@wterm/ghostty`) implement
* this interface so that `@wterm/dom` can render any core interchangeably.
*/
export interface TerminalCore {
// -- Lifecycle --
init(cols: number, rows: number): void;
resize(cols: number, rows: number): void;
// -- I/O --
writeString(str: string): void;
writeRaw(data: Uint8Array): void;
// -- Grid --
getCell(row: number, col: number): CellData;
isDirtyRow(row: number): boolean;
clearDirty(): void;
getCols(): number;
getRows(): number;
// -- Cursor --
getCursor(): CursorState;
// -- Modes --
cursorKeysApp(): boolean;
bracketedPaste(): boolean;
usingAltScreen(): boolean;
mouseTracking?(): 0 | 1000 | 1002;
mouseSgr?(): boolean;
focusEvents?(): boolean;
// -- Side outputs --
getTitle(): string | null;
getResponse(): string | null;
// -- Scrollback --
getScrollbackCount(): number;
getScrollbackCell(offset: number, col: number): CellData;
getScrollbackLineLen(offset: number): number;
// -- Debug --
getUnhandledSequences(): UnhandledSequence[];
}