Skip to content

Commit 9626fbd

Browse files
authored
refactor implementation to use more ghostty (#12)
* Phase 2: Replace TypeScript VT parser/buffer with WASM terminal - Added GhosttyTerminal class (311 lines) wrapping WASM terminal emulator - Created TerminalAdapter to bridge WASM cells to renderer format - Updated Terminal class to use WASM backend instead of ScreenBuffer + VTParser - Made CanvasRenderer duck-typed with IRenderable interface - Deleted lib/buffer.ts (840 lines) and lib/vt-parser.ts (635 lines) - Created lib/buffer-types.ts (29 lines) for minimal type compatibility - Updated WASM binary to 404 KB (includes terminal exports) - All 86 tests passing - Net: -1,475 lines (-33% codebase reduction) Benefits: - Production-tested VT100 emulation from Ghostty - Simplified codebase (1,475 fewer lines to maintain) - Maintained xterm.js-compatible API - All existing tests pass without modification * Update WASM binary with width bug fix - Cells now have correct width values (1 for normal, 2 for wide, 0 for spacers) - Fixes rendering issue where characters were not visible - Updated from phase1 commit 811a60d60
1 parent b21c6a3 commit 9626fbd

13 files changed

Lines changed: 622 additions & 3167 deletions

bun.lock

Lines changed: 28 additions & 88 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ghostty-vt.wasm

282 KB
Binary file not shown.

lib/buffer-types.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Buffer type definitions
3+
*
4+
* These types are used by the renderer for backward compatibility.
5+
* The actual terminal buffer is now implemented in WASM (GhosttyTerminal).
6+
*/
7+
8+
/** Color types for rendering */
9+
export type CellColor =
10+
| { type: 'default' }
11+
| { type: 'palette'; index: number }
12+
| { type: 'rgb'; r: number; g: number; b: number };
13+
14+
/** Cell represents a single character position for rendering */
15+
export interface Cell {
16+
char: string; // The character (may be multi-byte UTF-8)
17+
width: number; // 1 for normal, 2 for wide (CJK/emoji), 0 for combining
18+
fg: CellColor;
19+
bg: CellColor;
20+
bold: boolean;
21+
italic: boolean;
22+
underline: boolean;
23+
inverse: boolean;
24+
invisible: boolean;
25+
strikethrough: boolean;
26+
faint: boolean;
27+
blink: boolean;
28+
}

0 commit comments

Comments
 (0)