Ports ZIG/src/apprt/{action,structs,surface,ipc,runtime}.zig into
ghostty-apprt: the Action enum performed by the core on the app runtime
(all 65 variants with docs), Target<S> generic over the runtime's
surface handle, clipboard/size/scale/selection structs, the core->surface
Message enum with a Mailbox over an AppMailbox trait, and IPC action
types for +new-window.
Owned Strings and Arc<Config> replace Zig's borrowed slices/pointers.
Scrollbar and RendererHealth are local stand-ins until core integration.
The embedded C API and browser runtime are out of scope.
Test Plan:
- cargo test -p ghostty-apprt (16 tests)
2.9 KiB
2.9 KiB
ghostty-apprt notes
Mapping (ZIG/src/apprt -> crates/ghostty-apprt/src)
- action.zig -> action.rs:
Target<S>(+TargetKey),Actionenum (all 65 variants, docs ported),Key(C-enum order,Action::key()), helper enums/structs (SplitDirection, GotoSplit, GotoWindow, GotoTab, ResizeSplit, MoveTab, Fullscreen, FloatWindow, SecureInput, Inspector, QuitTimer, Readonly, MouseVisibility, PromptTitle, SizeLimit, InitialSize, CellSize, SetTitle, Pwd, DesktopNotification, KeySequence, KeyTable, ColorChange/ColorKind, ReloadConfig, ConfigChange, OpenUrl/OpenUrlKind, CloseTabMode, CommandFinished, StartSearch, SearchTotal, SearchSelected, MouseOverLink). - structs.zig -> structs.rs: ContentScale, SurfaceSize, CursorPos, ImePos (Zig
IMEPos), Clipboard, ClipboardContent, ClipboardRequest(+Type), ColorScheme, Selection. - surface.zig -> surface.rs:
Message,Mailbox<S, A>,AppMailbox<S>trait,NewSurfaceContext,should_inherit_working_directory,new_config. - ipc.zig -> ipc.rs:
Target(Class/Detect),Action::NewWindow(NewWindow{arguments}),ActionKey,Error::IpcFailed. - runtime.zig/none.zig -> runtime.rs:
Runtime{None,Gtk},none_perform_ipc(always false). - Skipped: embedded.zig, browser.zig, gtk.zig (apprt-gtk), all C ABI (
C,CValue,cval,getGObjectType).
Reused types
ghostty_input::binding::Trigger, ghostty_vt::mouse_shape::MouseShape, ghostty_vt::osc::{ProgressReport, color::ColoredTarget}, ghostty_config::{config::Config, types_b::Duration, types_a::WorkingDirectory}, ghostty_datastruct::{MessageData, blocking_queue::Timeout}.
Deviations
- Strings are
String(not NUL-terminated);surface::Message::SetTitleandDesktopNotificationkeep fixed arrays (256 / 64 / 256 bytes, NUL-terminated) withtitle()/body()accessors. ConfigChange.configandMessage::ChangeConfigholdArc<Config>instead of a borrowed pointer.GotoTab/ColorKind(non-exhaustive Zig enums) are Rust enums with anIndex(i32)/Palette(i32)catch-all andfrom_int/int.Mailbox::pushforwards through theAppMailbox<S>::push_surface_message(surface, msg, timeout)trait (Zig wraps inApp.Message.surface_message).new_configtakes the previous focused surface's pwd asOption<String>rather than anApp.- Tests of kind
ghostty.h ...(checkGhosttyHEnum) skipped (C ABI);refAllDeclsskipped. Replaced by 16 Rust tests (discriminants, key order, roundtrips, mailbox, config inheritance).
TODO(integration)
surface::Scrollbarstands in for ghostty_terminalpage_list::Scrollbar;surface::RendererHealthfor ghostty_rendererbackend::Health. Core should convert or (if dep order permits) re-export the real ones.- ghostty-core implements
AppMailbox<S>for its app mailbox (S = core surface handle) and instantiatesTarget<S>. - Selection (structs) is the pixel-based apprt struct; terminal::Selection is not used by any payload here.