Back to Home

Ghostling: terminal on libghostty C API

Ghostling — demo project of a minimal terminal based on libghostty-vt and Raylib. Supports VT emulation, Unicode, mouse/keyboard protocols without dependencies. Useful for studying C API of embeddable terminals.

Minimal Ghostling terminal on libghostty
Advertisement 728x90

Ghostling: Minimal Terminal Using libghostty to Demonstrate the C API

The Ghostty team has released an open-source demo project called Ghostling—a single-threaded terminal in a single C file that uses libghostty-vt for VT emulation and Raylib for rendering. The project demonstrates library integration without GPU acceleration, focusing on parsing sequences, state management, and basic input/output.

Architecture and Key Components

Ghostling is built on libghostty-vt—a library with no external dependencies, including libc. It handles parsing VT sequences, cursor positioning, applying styles, text reflow, scrolling, and renderer management. Rendering and the window loop are implemented via Raylib with a 2D renderer, which simplifies the demo and highlights libghostty's portability.

The project inherits optimizations from Ghostty: SIMD parsing, Unicode support, and efficient memory usage. Libghostty provides C and Zig APIs for embedding into any application, separating emulation from the UI.

Google AdInline article slot

Important Warning: Ghostling is not a production terminal. It's a minimal viable example without a thorough code audit, intended for studying the API.

Supported Features

The project implements core terminal emulator functionality:

  • Window resizing with text reflow;
  • 24-bit color and 256-color palette;
  • Text styles (bold, italic, underline);
  • Unicode and multi-codepoint grapheme clusters without artifacts;
  • Keyboard input with modifiers (Shift, Ctrl, Alt, Super);
  • Kitty keyboard protocol;
  • Mouse tracking (X10, normal, button, any event modes);
  • Mouse report formats (SGR, URxvt, UTF8, X10);
  • Mouse wheel for scrolling or passing to app;
  • Scrollbar with drag-to-scroll.

These features cover typical shell app scenarios, demonstrating the robustness of libghostty-vt in decoupled mode.

Google AdInline article slot

Differences from Main Ghostty

Ghostty uses GPU rendering and multithreading for high performance. Ghostling is simplified: single-threaded with CPU 2D rendering. This allows testing libghostty in embedded scenarios where GPU is unavailable or overhead is undesirable. Raylib provides cross-platform support without complex windowing libraries.

For mid/senior developers, the project serves as a starting point for custom terminals: add your own renderer (Vulkan, SDL, custom canvas) on top of libghostty-vt.

Key Takeaways

  • Libghostty-vt is a standalone VT engine without rendering, ideal for embedding;
  • Ghostling shows single-file integration of the C API with Raylib;
  • Full VT compatibility: colors, Unicode, mouse, keyboard protocols;
  • No dependencies, SIMD optimizations, low memory footprint;
  • Demo for prototyping, not for daily driver.

Development Plans

Developers announced a roadmap:

Google AdInline article slot
  • Kitty graphics protocol for images;
  • OSC clipboard support;
  • OSC window title configuration.

This will expand utility for GUI apps with terminal output, such as IDE plugins or remote desktop clients.

— Editorial Team

Advertisement 728x90

Read Next