Skip to main content

ghostty_dart_xterm 0.1.1 copy "ghostty_dart_xterm: ^0.1.1" to clipboard
ghostty_dart_xterm: ^0.1.1 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 #

pub package pub points CI License: MIT

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.

TerminalView of ghostty_dart_xterm showing an app migrated from xterm, ANSI and truecolor output, text styles and box drawing

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 xterm 4.0.0. An analyzer pass compares both APIs on every CI run; xterm's own tests are ported and run against this package, and its flutter_pty and dartssh2 examples 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. TerminalView is a VtTerminalView: 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 TerminalView are 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 custom inputHandler still 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.
  • maxLines is approximate: scrollback is dropped in whole pages, so a bit more is kept.
  • One TerminalView per Terminal, 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_dart consumed pty output 3.3–7.6× faster than the faster of xterm 4.0.0 and xterm2_core (parser benchmark). Terminal.write goes through the same parser, plus a listener notification per chunk.
  • Frames: ghostty_dart_flutter's view, which TerminalView wraps, spent about 23× less UI time per frame than xterm 4.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.lines builds 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_flutter and ghostty_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 xterm 4.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 #

License #

MIT (see LICENSE). Parts are ported from xterm 4.0.0, also MIT; see LICENSE.xterm. The libghostty-vt library underneath contains code under other licences too (libghostty-vt itself is MIT, Copyright (c) 2024 Mitchell Hashimoto, Ghostty contributors). This package's NOTICES and ghostty_dart's NOTICES hold every notice, and Flutter adds them to your app's licence page (LicenseRegistry, showLicensePage) without any extra step.

0
likes
160
points
123
downloads
screenshot

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

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.

Repository (GitHub)
View/report issues
Contributing

Topics

#terminal #terminal-emulator #xterm #widget #ghostty

License

MIT (license)

Dependencies

flutter, ghostty_dart, ghostty_dart_flutter

More

Packages that depend on ghostty_dart_xterm