Architecture

Ghostty Integration

How libghostty is embedded and driven
Properties3
Is BaseNo
Iconi-lucide-terminal
Order20

libghostty

Ghostty is built from source as an xcframework (GhosttyKit.xcframework) via:

pixi run build-ghostty
# zig build -Doptimize=ReleaseFast for arm64

The xcframework is git-ignored and must be built before the Xcode project can compile.

KytosGhosttyApp

KytosGhosttyApp is the @Observable @MainActor singleton that owns the Ghostty application handle (ghostty_app_t).

Responsibilities:

  • Loads ~/.config/ghostty/config via ghostty_config_load_default_files()
  • Owns the app tick loop
  • Registers C callbacks: wakeup, action, clipboard read/write, close surface

KytosGhosttyView

KytosGhosttyView is the NSView subclass that wraps ghostty_surface_t.

Responsibilities:

  • Hosts the Metal CAMetalLayer
  • Forwards keyboard events, mouse events, and scroll wheel input
  • Implements NSTextInputClient for IME support
  • Parses OSC escape sequences for title and working directory updates

Resource Detection

libghostty locates its resources (shell integration scripts, terminfo) via a sentinel file:

Kytos.app/Contents/Resources/terminfo/78/xterm-ghostty

When found, Ghostty sets resources_dir to Contents/Resources/ghostty, which must contain shell-integration/.

Default Config

ghostty_config_load_default_files() reads:

  • ~/.config/ghostty/config
  • XDG config paths

This is why all terminal settings go in the Ghostty config file — Kytos doesn't implement its own terminal configuration layer.