Skip to content

Conversation

@mitchellh
Copy link
Contributor

@mitchellh mitchellh commented Sep 22, 2025

This makes a ghostty-vt Zig module available from our build.zig that contains a reusable Zig API version of our core terminal emulation layer including escape sequence parsing, terminal state, and screen state. This is the groundwork for phase one of my "libghostty" vision.

With SIMD disabled, ghostty-vt has no dependencies -- not even on libc -- and can produce fully static standalone binaries. With SIMD enabled, ghostty-vt only depends on libc.

The point of this PR is primarily to get the bug fixes I found in and to get this running in CI on every commit so that we don't regress it. In the future we'll do more (see the future section below).

Warning

The API is extremely not stable and will definitely change in the future. The functionality/logic is very stable, because it's the same core logic used by Ghostty, but the API itself is not at all. For this PR, we mostly just expose everything and we'll reshape the API later.

What is libghostty-vt?

I've stated my vision for a libghostty for some time. You can find background on that. Recently, I've realized that the scope of libghostty is way too large to ship as a single unit. To that end, libghostty will be split into smaller scoped sub-libraries (that may depend on each other for higher level functionality). The exact mapping is being worked out.

The first library I'm extracting is libghostty-vt (both Zig and C, this PR starts with Zig). This will be a library focused only on core terminal emulation, terminal state, and screen state. It lacks rendering support and input handling.

But why? The core terminal emulation is the primary source of both missing functionality and bugs within terminal emulators. Look at this simple bug in jediterm that fails to parse a trivially common sequence resulting in horrendous misrenders. Jediterm is used by every JetBrains IDE! Literally the core terminal in a many-millions-of-dollars business!

libghostty-vt is a zero dependency terminal emulation layer that exposes a C API which will let any popular language build bindings so that we can stop reinventing the terminal emulation layer and get best in class (or near it) terminal emulation capabilities everywhere.

In This PR

  • ghostty-vt Zig module
  • Example usage of it in example/zig-vt
  • CI to run Zig module tests, test that our examples build, and test SIMD on/off
  • New feature build flag -Dsimd (default on) that turns SIMD on or off
  • Unexposed feature flag that allows building the core terminal logic without regex support (default on right now jus for the ghostty-vt module as I figure out what our future regex story is in a post-oni world).
  • Fixes for non-SIMD builds

Future

There's a lot to do in the future outside of this PR:

  • Define a more stable Zig API
  • Define a C API at all
  • Figure out our regex engine story
  • Documentation improvements
@mitchellh mitchellh requested a review from a team as a code owner September 22, 2025 13:56
@mitchellh mitchellh merged commit 8cb5232 into main Sep 22, 2025
82 checks passed
@mitchellh mitchellh deleted the ghostty-vt branch September 22, 2025 17:06
@github-actions github-actions bot added this to the 1.2.1 milestone Sep 22, 2025
@mitchellh mitchellh modified the milestones: 1.2.1, 1.3.0 Sep 22, 2025
@00-kat 00-kat added the vt Control sequence related label Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vt Control sequence related

3 participants