feat(core): port App/Surface and wire up the runnable ghostty binary

This is the integration step that turns the ported crates into a working
terminal: `cargo run` now opens a GTK window running the user's shell.

ghostty-core ports App.zig, Surface.zig (split into keyboard, mouse,
binding, clipboard and config submodules), surface_mouse.zig and
global.zig, and implements the runtime traits. perform_binding_action
handles every binding action.

Cross-crate integration:
- The core<->runtime traits (CoreApp, CoreSurface, RtApp, RtSurface,
  Waker) move from apprt-gtk into ghostty_apprt::runtime_api so the core
  stays runtime-agnostic; Scrollbar/RendererHealth stand-ins are replaced
  by the real terminal/renderer types.
- termio now uses ghostty_renderer::state::{State, SharedState}; the
  renderer calls kitty_update; image-storage-limit is applied at init
  and on config change.
- The search thread locks the terminal through a TerminalLock trait so
  it can share the render state mutex; termio's Wakeup gained a hook to
  wake the renderer thread.
- apprt-gtk: GL proc addresses are resolved through libepoxy's
  epoxy_glFoo pointer variables (plain glFoo symbols resolved to null),
  default DPI fixed to 96, libadwaita version read without GTK init so
  --version works headless.

The root binary dispatches +actions to ghostty-cli (list-fonts,
show-face and new-window are now wired) and otherwise runs the GTK app
with the real core.

Verified at runtime on Wayland and X11: shell prompt and colored output
render, child exit closes the window cleanly. Not yet verified: keyboard
and mouse input, clipboard, IME, tabs and splits (no key injection was
possible in this environment). GHOSTTY_DEBUG_SCREENSHOT=<png> dumps the
renderer's last frame for headless checks.

Test Plan:
- cargo test --workspace (2890 passed)
- cargo clippy --workspace --all-targets -- -D warnings
- GSETTINGS_BACKEND=memory GHOSTTY_RESOURCES_DIR=/usr/share/ghostty \
  cargo run
This commit is contained in:
ddidderr committed 2026-10-12 01:33:44 +02:00
1 parent 9c3eeeba50
commit 3266108c10
42 files changed
+9301 -179

No files matched your search

+69 -5
View File
@@ -1,7 +1,4 @@
//! `+list-fonts` (ZIG/src/cli/list_fonts.zig).
//!
//! DEFERRED: needs the font crate (font discovery). Only the options and
//! help are ported; running the action reports that it is not available.
use ghostty_config::config_struct;
@@ -52,6 +49,73 @@ pub fn run(args: &[String]) -> Result<u8, Error> {
let mut opts = Options::default();
crate::parse_options(&mut opts, args)?;
// TODO(integration): port the discovery/listing once ghostty-font lands.
Err(Error::NotYetAvailable("list-fonts"))
use std::collections::HashMap;
use std::io::Write;
// We'll be putting our fonts into a list categorized by family
// so it is easier to read the output.
let mut families: Vec<String> = Vec::new();
let mut map: HashMap<String, Vec<String>> = HashMap::new();
// Look up all available fonts
let disco = ghostty_font::Discover::init();
let desc = ghostty_font::Descriptor {
monospace: opts.family.is_none(),
family: opts.family.clone(),
style: opts.style.clone(),
bold: opts.bold,
italic: opts.italic,
..ghostty_font::Descriptor::default()
};
let mut it = disco
.discover(&desc)
.map_err(|e| Error::Other(e.to_string()))?;
while let Some(face) = it.next().map_err(|e| Error::Other(e.to_string()))? {
let family = match face.family_name() {
Ok(v) => v,
Err(err) => {
log::error!("failed to get font family name: {err}");
continue;
}
};
let full_name = match face.name() {
Ok(v) => v,
Err(err) => {
log::error!("failed to get font name: {err}");
continue;
}
};
let list = map.entry(family.clone()).or_insert_with(|| {
families.push(family);
Vec::new()
});
list.push(full_name);
}
// Sort our keys.
if opts.family.is_none() {
families.sort_unstable();
}
// Output each
let mut stdout = std::io::BufWriter::new(std::io::stdout().lock());
for family in &families {
let Some(list) = map.get_mut(family) else {
continue;
};
if list.is_empty() {
continue;
}
if opts.family.is_none() {
list.sort_unstable();
}
writeln!(stdout, "{family}")?;
for item in list.iter() {
writeln!(stdout, " {item}")?;
}
writeln!(stdout)?;
}
stdout.flush()?;
Ok(0)
}