feat: port GTK version fallbacks, helpgen, bench modes, CLI leftovers

- apprt-gtk: Ghostty's runtime+build-time version gating (at_least)
  with cargo features adw_1_3/adw_1_4/adw_1_5/gtk_4_16 (default on) and
  the fallbacks for older libraries: MessageDialog (adw < 1.5),
  clipboard dialog without SwitchRow, pre-Banner debug warning and
  child-exited widgets, the old about dialog, GTK 4.16 CSS error source
  bytes. The minimum stays GTK 4.14 / libadwaita 1.5 (Ghostty's floor).
  The root build links with -z lazy so version-gated symbols don't keep
  older libraries from loading.
- ghostty-helpgen (port of helpgen.zig) generates CLI action help and
  keybinding action docs from doc comments at build time, replacing the
  checked-in help/*.txt; +help and +list-actions --docs stay
  byte-identical to Ghostty 1.3.1.
- ghostty-bench: libc wcwidth mode and separate simd/table and
  uucode/table code paths like Zig.
- ghostty-cli: Windows branches of edit-config, list-colors,
  list-keybinds and boo; ssh-cache DiskCache flock locking (no-op on
  Windows, as in Zig) with an exclusivity test.

Test Plan:
- cargo test --workspace
- diff <(cargo run -q -- +list-actions --docs) \
  <(ghostty +list-actions --docs)
This commit is contained in:
ddidderr committed 2026-10-12 06:38:33 +02:00
1 parent 020beb2d75
commit 4787565397
51 files changed
+2426 -1621

No files matched your search

@@ -1,26 +1,41 @@
//! Port of apprt/gtk/class/surface_child_exited.zig.
//!
//! Child exited overlay based on `adw.Banner` (Adwaita 1.3+; the crate
//! requires 1.5 so the Zig `SurfaceChildExitedNoop` fallback is omitted).
//! Emits `close-request` when the banner button is clicked.
//! Child exited overlay based on `adw.Banner` (Adwaita 1.3+, the `adw_1_3`
//! build level; emits `close-request` when the banner button is clicked).
//! Without it Zig compiles `SurfaceChildExitedNoop`, an empty widget that
//! immediately asks to be closed (`NOOP == true`); so does this port.
#[cfg(feature = "adw_1_3")]
use std::sync::OnceLock;
#[cfg(feature = "adw_1_3")]
use adw::{prelude::*, subclass::prelude::*};
use ghostty_apprt::surface::ChildExited;
use gtk::{glib, glib::subclass::Signal};
use gtk::glib;
#[cfg(feature = "adw_1_3")]
use gtk::glib::subclass::Signal;
#[cfg(not(feature = "adw_1_3"))]
use gtk::prelude::*;
/// Boxed wrapper so `ChildExited` can be a GObject property.
#[derive(Debug, Clone, Copy, PartialEq, Eq, glib::Boxed)]
#[boxed_type(name = "GhosttyChildExited", nullable)]
pub struct ChildExitedBoxed(pub ChildExited);
#[cfg(feature = "adw_1_3")]
glib::wrapper! {
pub struct SurfaceChildExited(ObjectSubclass<imp::SurfaceChildExited>)
@extends adw::Bin, gtk::Widget,
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
}
#[cfg(not(feature = "adw_1_3"))]
glib::wrapper! {
pub struct SurfaceChildExited(ObjectSubclass<imp::SurfaceChildExited>)
@extends gtk::Widget,
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
}
impl Default for SurfaceChildExited {
fn default() -> Self {
Self::new()
@@ -28,16 +43,27 @@ impl Default for SurfaceChildExited {
}
impl SurfaceChildExited {
/// Can be detected at compile time (Zig: `pub const noop = true`).
pub const NOOP: bool = !cfg!(feature = "adw_1_3");
#[must_use]
pub fn new() -> Self {
glib::Object::new()
}
/// Set the child exited data (Zig: `setData`).
#[cfg(feature = "adw_1_3")]
pub fn set_child_exited(&self, data: Option<&ChildExited>) {
self.set_data(data.map(|d| ChildExitedBoxed(*d)));
}
/// Set the child exited data (Zig: `setData`); the noop widget just asks
/// to be closed.
#[cfg(not(feature = "adw_1_3"))]
pub fn set_child_exited(&self, _data: Option<&ChildExited>) {
self.emit_by_name::<()>("close-request", &[]);
}
pub fn connect_close_request<F: Fn(&Self) + 'static>(&self, f: F) -> glib::SignalHandlerId {
self.connect_closure(
"close-request",
@@ -47,6 +73,7 @@ impl SurfaceChildExited {
}
}
#[cfg(feature = "adw_1_3")]
mod imp {
use std::cell::RefCell;
@@ -141,3 +168,31 @@ mod imp {
impl WidgetImpl for SurfaceChildExited {}
impl BinImpl for SurfaceChildExited {}
}
/// Empty widget that does nothing if we don't have a new enough Adwaita
/// version to support the child exited banner.
#[cfg(not(feature = "adw_1_3"))]
mod imp {
use std::sync::OnceLock;
use gtk::{glib, glib::subclass::Signal, subclass::prelude::*};
#[derive(Default)]
pub struct SurfaceChildExited;
#[glib::object_subclass]
impl ObjectSubclass for SurfaceChildExited {
const NAME: &'static str = "GhosttySurfaceChildExited";
type Type = super::SurfaceChildExited;
type ParentType = gtk::Widget;
}
impl ObjectImpl for SurfaceChildExited {
fn signals() -> &'static [Signal] {
static SIGNALS: OnceLock<Vec<Signal>> = OnceLock::new();
SIGNALS.get_or_init(|| vec![Signal::builder("close-request").build()])
}
}
impl WidgetImpl for SurfaceChildExited {}
}