Ghostling makes terminal emulation a C library

The Ghostty project makes its terminal engine available as an embeddable library. A demo shows how little code is needed for this.

listen Print view
A woman plays the saxophone, surrounded by binary code forming ghost shapes.

(Image: heise medien)

2 min. read

With Ghostling, the Ghostty project has released a reference implementation that makes the core of the terminal emulator usable as a standalone C library. In theory, terminal emulation thus becomes a reusable component that can be embedded into different software projects. Possible uses include IDEs, developer tools, or specialized workflow applications that require an integrated terminal view without having to implement it themselves from scratch.

However, Ghostling is currently not a full-fledged terminal emulator, but an explicitly minimal demo so far. The project essentially consists of a single C file and uses the Raylib graphics library for windows and rendering. Ghostling aims to show how little code is needed to build a functional terminal emulator based on the new libghostty-vt library. Despite its small scope, Ghostling already covers essential terminal functions, including 24-bit colors, Unicode support, mouse tracking, the Kitty keyboard protocol, and scrollback with text reflow.

The innovation that will excite many developers is libghostty-vt, a library extracted from the Ghostty project without external dependencies. It handles the parsing of VT sequences, the management of the terminal state, and the management of the renderer state. GUI functions such as tabs, split panes, window management, or configuration interfaces are not part of the library. These are intended to be provided by the embedding applications themselves. Some features such as the Kitty Graphics Protocol or OSC clipboard support are not yet available via the API but are on the roadmap. Windows support is available at the library level, but has not yet been tested in Ghostling itself.

Videos by heise

The library is based on the regular Ghostty code and inherits its SIMD-optimized parsing, Unicode support, and the codebase secured by fuzzing. It offers a C API and a Zig API and, according to the project description on GitHub, can also be used in WebAssembly environments. Initial community experiments with libghostty can be found in the related discussion on Hacker News. Like Ghostty, Ghostling is open-source software. The main project is currently available in version 1.3.0.

(fo)

Don't miss any news – follow us on Facebook, LinkedIn or Mastodon.

This article was originally published in German. It was translated with technical assistance and editorially reviewed before publication.