ghostty_dart_xterm 0.1.0
ghostty_dart_xterm: ^0.1.0 copied to clipboard
API-compatible adapter for package:xterm 4.0.0 on top of ghostty_dart and ghostty_dart_flutter (libghostty-vt): same Terminal and TerminalView API.
ghostty_dart_xterm #
English | Español
The public API of xterm 4.0.0
(Terminal, TerminalView, TerminalController, themes, key and mouse
handlers) on top of
ghostty_dart_flutter
and ghostty_dart, which run
libghostty-vt 1.x, the terminal emulation
engine of Ghostty. Most apps move from xterm by
changing their import.
Note
Unofficial. This is an independent project. It is not affiliated
with, endorsed by or sponsored by the Ghostty project or Hack Club, nor
by the authors of xterm. "Ghostty" is a trademark of its respective
owners and is used here only to describe what this package builds on.
Important
Not a drop-in replacement. Every xterm 4.0.0 member and its
status (same, differs, planned, won't support) is listed in the generated
COMPATIBILITY.md,
and what the differences mean for an app is in the
migration guide.

There is no live web demo yet: it waits for the web (wasm) backend of
ghostty_dart.
- xterm's API, checked by machine. The same class, member and parameter
names as
xterm4.0.0. An analyzer pass compares both APIs on every CI run; xterm's own tests are ported and run against this package, and itsflutter_ptyanddartssh2examples compile with only the import changed. - Ghostty's engine. Parsing, the screen, scrollback, reflow, key encoding (including the Kitty keyboard protocol) and mouse reports come from libghostty-vt 1.0 instead of a Dart emulator.
ghostty_dart_flutter's renderer.TerminalViewis aVtTerminalView: only the rows that changed are redrawn, from a glyph atlas, with IME and soft keyboards built in.
Platforms #
| Platform | Status | Tested |
|---|---|---|
| Linux, macOS, Windows | ✅ | Tests in CI on all three |
| Android, iOS | ⚠️ | Not yet tried on a device |
| Web | — | Planned: needs a wasm backend in ghostty_dart |
Quick start #
Swap the dependency and the import:
dependencies:
# xterm: ^4.0.0
ghostty_dart_xterm: ^0.1.0
// import 'package:xterm/xterm.dart';
import 'package:ghostty_dart_xterm/xterm.dart';
final terminal = Terminal(maxLines: 10000);
terminal.onOutput = (data) => pty.write(utf8.encode(data)); // keys, pastes, replies
terminal.write('Hello, world!\r\n');
// In build():
TerminalView(terminal, autofocus: true);
// When done (not in xterm: the terminal holds native memory):
terminal.dispose();
example/lib/main.dart
is xterm's mock-shell example, ported: a complete app that runs without a
pty.
Migrating from xterm #
For a typical app (a flutter_pty shell, a dartssh2 session, a virtual
keyboard as a custom inputHandler), the import change is the whole
migration, plus terminal.dispose(). What you may notice:
- Keys typed into
TerminalVieware encoded by libghostty-vt, so a few byte sequences differ from xterm's keytab (Kitty keyboard protocol when the program asks for it, for example). A custominputHandlerstill gets every key, as in xterm. - Mouse reports use the correct row (xterm 4.0.0 sends one row too low).
- The screen that is not active (the main screen while a full-screen program runs) reads as blank lines.
maxLinesis approximate: scrollback is dropped in whole pages, so a bit more is kept.- One
TerminalViewperTerminal, and no web yet.
The migration guide covers each difference with code.
Benchmarks #
This package has not been benchmarked on its own yet. What it is built on
has been, against xterm 4.0.0 on the same byte streams:
- Parsing:
ghostty_dartconsumed pty output 3.3–7.6× faster than the faster ofxterm4.0.0 andxterm2_core(parser benchmark).Terminal.writegoes through the same parser, plus a listener notification per chunk. - Frames:
ghostty_dart_flutter's view, whichTerminalViewwraps, spent about 23× less UI time per frame thanxterm4.0.0's when a few rows change, and 3.5× less on a full screen of new text (frame benchmark). The adapter's own work per frame (its key, text and mouse hooks) is not measured there. - Slower: reading
terminal.buffer.linesbuilds each line from the engine on first access (about 50 µs per 80-column line in a debug build), where xterm keeps the lines in Dart. Fine for copying a selection or a search; avoid walking the whole scrollback every frame.
How it compares #
Facts as of 2026-11-12. xterm is the mature, widely used choice today,
and this package exists to keep its API.
ghostty_dart_xterm 0.1.0 |
xterm 4.0.0 |
|
|---|---|---|
| Engine | libghostty-vt 1.0.0, FFI | Pure Dart |
| Web | No (planned) | Yes |
| API | xterm 4.0.0's, with the differences in COMPATIBILITY.md |
It is the API |
Escape parser in Dart (EscapeParser, EscapeHandler) |
No: parsing is native | Yes |
ZModem (zmodem.dart) |
Not yet | Yes |
Debugger (utils.dart) |
No | Yes |
If you need the web, ZModem or xterm's Dart parser today, use xterm.
Supply chain #
- Dependencies besides Flutter:
ghostty_dart_flutterandghostty_dart, from the same repository.ghostty_dart's build hook downloads a prebuilt libghostty-vt for your target, checks it against a sha256 pinned in its source, fails the build on a mismatch, and never runs downloaded code. The binaries are built in this repository's CI from the signed upstream source, with provenance attestations. - No build-time code of its own. No build hook, no native code. Parts
are ported from
xterm4.0.0 (MIT), each file marked. - The repository commits its lockfiles, pins its GitHub Actions by commit, and does not adopt any dependency version younger than 3 days. Details are in the security policy.
Documentation #
- Migration guide
and
COMPATIBILITY.md ghostty_dart_flutter, for the widget underneath- Design decision (ADR 0013)
- Changelog
- Contributing and issues
License #
MIT (see
LICENSE).
Parts are ported from xterm 4.0.0, also MIT; see
LICENSE.xterm.
libghostty-vt is MIT licensed too (Copyright (c) 2024 Mitchell Hashimoto,
Ghostty contributors); apps that ship it must include its notice.
