From 0d5c7d937c7d592ac7f3a9a8253993bffa283288 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 19 Nov 2026 20:34:29 -0300 Subject: core, dev, runtime, test: the settings a session changes while it runs are `config.Settings`, no longer `config.Runtime` (P18, the user's ruling on the tree step's name collisions: the type's name collided with the directory `runtime/`, and the core's field of that type is already `settings`): the type on 17 lines of core/config.zig (its declaration, its methods' receivers, its tests, the comment naming it), `config.Settings` on 50 lines of eleven other files (core/Core.zig, Output.zig, builtins.zig, builtins_json.zig, exec.zig, ninep/ctl.zig, surface.zig; dev/gui/gui.zig 598, 5860, 5909; dev/jump_trail.zig's comment; runtime/main.zig 756; test/output.zig 552) and docs/next-winmode.md's one mention; a rename only, nothing else on any line; the semantics hash does not move (a type's name is not in the tape's shape); tui core-test 848/991 (143 skipped), shell-test 1027/1030, gui unit-test 1625/1629 failing only the perf check's BaselineHarnessMismatch (as the base), the macOS library for Linux and aarch64-macos and the FreeBSD cross-build rc 0, under a load of 6 to 42 Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- dev/gui/gui.zig | 6 +++--- dev/jump_trail.zig | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'dev') diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig index c147c2e2..3aed1ed6 100644 --- a/dev/gui/gui.zig +++ b/dev/gui/gui.zig @@ -595,7 +595,7 @@ fn acknowledgeGuiFont(g: *const Gui, core: *pardes.Pardes) void { /// A replica client's font is the window's raster state: it follows the /// session's request by the face's name on this machine (fonts.fromSession), /// never acknowledging it or otherwise changing the replicated core. -fn syncReplicaFont(g: *Gui, f: *const @FieldType(pardes.config.Runtime, "font"), gpa: std.mem.Allocator) bool { +fn syncReplicaFont(g: *Gui, f: *const @FieldType(pardes.config.Settings, "font"), gpa: std.mem.Allocator) bool { const path = f.requested_path.get(); const name = f.requested_name.get(); if (path.len == 0 and name.len == 0) return false; @@ -5857,7 +5857,7 @@ fn cursorDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, /// The triangle overlay: the cursor's glide, over everything. fn buildOverlay( g: *Gui, - which: pardes.config.Runtime.Pet, + which: pardes.config.Settings.Pet, trail_on: bool, surface: *const pardes.Surface, now_ns: u64, @@ -5906,7 +5906,7 @@ fn appendJumpTrail(g: *Gui, on: bool, surface: *const pardes.Surface, now_ns: u6 /// The workspace tag's pet (the Pet setting, gui/pet.zig): in the blank /// end of the grid's first row, past the tag's text, in the tag's colours, /// on the window's own clock. Nothing of it reaches the core. -fn appendWorkspacePet(g: *Gui, which: pardes.config.Runtime.Pet, surface: *const pardes.Surface, builder: *OverlayBuilder) void { +fn appendWorkspacePet(g: *Gui, which: pardes.config.Settings.Pet, surface: *const pardes.Surface, builder: *OverlayBuilder) void { const kind: pet.Kind = @fromBackingInt(@backingInt(which)); if (kind == .off or surface.rows == 0 or surface.cols == 0) { g.pet_state = .{}; diff --git a/dev/jump_trail.zig b/dev/jump_trail.zig index 25eba636..05664ec1 100644 --- a/dev/jump_trail.zig +++ b/dev/jump_trail.zig @@ -4,7 +4,7 @@ //! the cursor of the Surface it shows, frame after frame, and times the fade //! on its own clock; the tty tints those cells' ground toward the text, the //! window draws over them. Nothing of it reaches the core, which keeps the -//! setting alone (config.Runtime.jump_trail). +//! setting alone (config.Settings.jump_trail). const std = @import("std"); pub const life_ns: u64 = 120 * std.time.ns_per_ms; -- cgit v1.3 From a18b99e1e0862de4b3c8fd55e0fd816fe2dca621 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 19 Nov 2026 21:02:38 -0300 Subject: abi, runtime, dev/macos, test, docs: what the macOS host lends the core is `Callbacks` in runtime/macos.zig and `pardes_callbacks_s` in abi/pardes.h and the Swift, no longer `Runtime` and `pardes_runtime_s` (P18, the user's ruling on the tree step's name collisions: the type's name collided with the directory `runtime/`; the C name follows so the three sides keep one name): the header's typedef, its use in `pardes_init`'s declaration and its section banner; the Zig type, its four uses (the State field's type, `pardes_init`, `initCore`) and the ABI guard's line; the Swift's two constructors (dev/macos/Sources/AppDelegate.swift 135, test/macos_e2e.swift 171) and that file's comment naming "the runtime struct"; docs/macos.md (two lines) and docs/ghostty-macos-notes.md (two lines) naming the struct; the field and parameter named `runtime` stay (not ruled); a rename only, nothing else on any line; the macOS library is not in the tape, so the semantics hash does not move; the Swift app cannot be built here: the header and the Zig agree by the ABI guard (`unit-test -Dplatform=macos -Dtest-filter="pardes.h matches the Zig boundary"` on Linux, 1/1, which reads the header through translate-c (build/macos.zig) and compares `@sizeOf(c.pardes_callbacks_s)` with `Callbacks`), the Swift by reading (the two constructors name the typedef the header declares, with its unchanged field labels); tui core-test 848/991 (143 skipped), shell-test 1027/1030, the window builds (`install -Dplatform=gui`), the macOS library for Linux and aarch64-macos and the FreeBSD cross-build rc 0, under a load of 34 to 57 Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- abi/pardes.h | 6 +++--- dev/macos/Sources/AppDelegate.swift | 2 +- docs/ghostty-macos-notes.md | 4 ++-- docs/macos.md | 4 ++-- runtime/macos.zig | 10 +++++----- test/macos_e2e.swift | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) (limited to 'dev') diff --git a/abi/pardes.h b/abi/pardes.h index 65ca5c60..ca65b8f3 100644 --- a/abi/pardes.h +++ b/abi/pardes.h @@ -191,7 +191,7 @@ typedef enum { PARDES_HAPTIC_LOOK = 2, } pardes_haptic_e; -// ---------------------------------------------------------------- runtime +// ---------------------------------------------------------------- callbacks // What the host lends the core. Three callbacks, because everything else the // core wants done it already does itself: it owns the ptys, and it opens URLs @@ -214,7 +214,7 @@ typedef struct { // pardes_paste, which may be synchronous inside this call. Main thread, // inside pardes_tick. void (*read_clipboard)(void *userdata); -} pardes_runtime_s; +} pardes_callbacks_s; // ---------------------------------------------------------------- lifecycle @@ -223,7 +223,7 @@ typedef struct { // core defers each shell's greeting until it has seen one), and the first // forkpty takes its winsize straight off the core — boot at 80x24 and the // shell draws its first prompt to a width the window never had. -int pardes_init(const pardes_runtime_s *runtime, uint16_t cols, uint16_t rows); +int pardes_init(const pardes_callbacks_s *runtime, uint16_t cols, uint16_t rows); void pardes_deinit(void); // Drain pty output into the core and perform the effects it queued. Call after diff --git a/dev/macos/Sources/AppDelegate.swift b/dev/macos/Sources/AppDelegate.swift index 767d3766..4168999f 100644 --- a/dev/macos/Sources/AppDelegate.swift +++ b/dev/macos/Sources/AppDelegate.swift @@ -132,7 +132,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, PardesViewDelegate { // to change the day macos_min_version reaches 14. NSApp.activate(ignoringOtherApps: true) - var runtime = pardes_runtime_s( + var runtime = pardes_callbacks_s( userdata: Unmanaged.passUnretained(self).toOpaque(), wakeup: { ud in // A pty reader thread. Every other function in pardes.h is diff --git a/docs/ghostty-macos-notes.md b/docs/ghostty-macos-notes.md index 830d4b1f..3dc03265 100644 --- a/docs/ghostty-macos-notes.md +++ b/docs/ghostty-macos-notes.md @@ -56,10 +56,10 @@ comptime { The payoff is that adding a feature adds an enum case, not a struct field: hosts that do not implement it return `false` and the ABI never changed. Worth copying the day a fixed callback list starts growing. pardes has three callbacks today -— `wakeup`, `set_clipboard`, `read_clipboard` (`Runtime` in `runtime/macos.zig:153`) +— `wakeup`, `set_clipboard`, `read_clipboard` (`Callbacks` in `runtime/macos.zig:153`) — and does not need it yet. -Two userdata scopes, worth noting: the runtime struct's `userdata` is +Two userdata scopes, worth noting: the callbacks struct's `userdata` is app-scoped, and each surface carries its own. Swift round-trips both with `Unmanaged.passUnretained(self).toOpaque()` — libghostty never retains, so lifetime stays entirely on the Swift side. diff --git a/docs/macos.md b/docs/macos.md index 44b77d67..98cd5312 100644 --- a/docs/macos.md +++ b/docs/macos.md @@ -85,7 +85,7 @@ copies had in common is the argument for the shared file existing: none set the pty master, so a program in one pane could read and write another pane's terminal and closing a master did not reliably hang its shell up. -That is why the runtime struct is three callbacks rather than a second vtable — +That is why the callbacks struct is three callbacks rather than a second vtable — and why two of the three are the clipboard: the pasteboard is AppKit's, in both directions, and is the one piece of IO the Zig side cannot reach for itself. @@ -128,7 +128,7 @@ is made of and what opens a path from argv or the Dock (`Look `). it. `pardes_resize` also carries one cell in *physical* pixels, which only the native PDF placement path reads — pass the backing-store size, not points. -**Runtime callbacks.** `pardes_runtime_s` is a `userdata` and three functions, +**Callbacks.** `pardes_callbacks_s` is a `userdata` and three functions, copied by value during init so the struct need not outlive the call. `wakeup` means "your state moved, please pump me". `set_clipboard` hands over text to put on the pasteboard, borrowed for the duration of the call; it fires inside a tick diff --git a/runtime/macos.zig b/runtime/macos.zig index 408915da..a5869753 100644 --- a/runtime/macos.zig +++ b/runtime/macos.zig @@ -103,7 +103,7 @@ pub const Image = extern struct { paper_bg: u32, }; -pub const Runtime = extern struct { +pub const Callbacks = extern struct { userdata: ?*anyopaque = null, wakeup: ?*const fn (?*anyopaque) callconv(.c) void = null, set_clipboard: ?*const fn (?*anyopaque, [*]const u8, usize) callconv(.c) void = null, @@ -250,7 +250,7 @@ const State = struct { io: std.Io, core: *pardes.Pardes, started: bool = false, - runtime: Runtime, + runtime: Callbacks, tag_cells: [pardes.MAX_TAG_LAYERS][]Cell = @splat(&.{}), layer_cells: [pardes.MAX_PANES][]Cell = @splat(&.{}), cells: []Cell = &.{}, @@ -290,7 +290,7 @@ const State = struct { var state: ?State = null; -export fn pardes_init(runtime: ?*const Runtime, cols_arg: u16, rows_arg: u16) c_int { +export fn pardes_init(runtime: ?*const Callbacks, cols_arg: u16, rows_arg: u16) c_int { if (state != null) return 1; // already up; deinit first initCore(runtime, cols_arg, rows_arg) catch |err| { log.err("init failed: {t}", .{err}); @@ -302,7 +302,7 @@ export fn pardes_init(runtime: ?*const Runtime, cols_arg: u16, rows_arg: u16) c_ /// The shell's gpa in a Debug build, as std.start's is for the others. var debug_gpa: std.heap.DebugAllocator(.{}) = .init; -fn initCore(runtime: ?*const Runtime, cols_arg: u16, rows_arg: u16) !void { +fn initCore(runtime: ?*const Callbacks, cols_arg: u16, rows_arg: u16) !void { // The allocator every other shell gets from std.start: a DebugAllocator // in Debug, libc's malloc otherwise. libc's measured at least as fast as // std.heap.smp_allocator everywhere and faster on MuPDF's page-sized @@ -2461,7 +2461,7 @@ test "pardes.h matches the Zig boundary" { try expectEqual(@sizeOf(c.pardes_image_s), @sizeOf(Image)); inline for (@typeInfo(Image).@"struct".field_names) |name| try expectEqual(@offsetOf(c.pardes_image_s, name), @offsetOf(Image, name)); - try expectEqual(@sizeOf(c.pardes_runtime_s), @sizeOf(Runtime)); + try expectEqual(@sizeOf(c.pardes_callbacks_s), @sizeOf(Callbacks)); try expectEqual(@as(u32, c.PARDES_COLOR_DEFAULT), color_default); try expectEqual(@as(u32, c.PARDES_COLOR_INDEXED), color_indexed); diff --git a/test/macos_e2e.swift b/test/macos_e2e.swift index 74a03200..38d27808 100644 --- a/test/macos_e2e.swift +++ b/test/macos_e2e.swift @@ -51,7 +51,7 @@ private struct ScriptError: Error { } /// What the three C callbacks reach through `userdata`. A class, because a C -/// function pointer cannot capture: a pointer the runtime struct carries is the +/// function pointer cannot capture: a pointer the callbacks struct carries is the /// only way back into Swift state. private final class Host { /// Set by `wakeup`, which runs on a pty reader thread. Nothing else in the @@ -168,7 +168,7 @@ private final class Driver: PardesViewDelegate { message: "the view measured \(got.cols)x\(got.rows) cells, not the \(cols)x\(rows) the script asked for") } - var runtime = pardes_runtime_s( + var runtime = pardes_callbacks_s( userdata: Unmanaged.passUnretained(host).toOpaque(), wakeup: { ud in // A pty reader thread. One flag and out — see Host.woke. -- cgit v1.3