diff options
Diffstat (limited to 'src/tui_event.zig')
| -rw-r--r-- | src/tui_event.zig | 35 |
1 files changed, 6 insertions, 29 deletions
diff --git a/src/tui_event.zig b/src/tui_event.zig index c32db39..3f59ba2 100644 --- a/src/tui_event.zig +++ b/src/tui_event.zig @@ -73,16 +73,6 @@ //! own default and returns that boundary's own chosen component. Parallel tool //! calls each get their own. //! -//! ## Bridge friendliness (§7.6) -//! -//! Dispatch is a vtable of function pointers over `*anyopaque`, matching the -//! `Component` vtable in `tui_component.zig`. A Lua-backed (or future C-ABI) -//! handler implements the same `Handler` callback shape; a Lua-defined -//! component implements the same `Component` vtable across the bridge. Nothing -//! here knows or cares whether a handler/component is native or bridged. The -//! Lua side is implemented in a LATER sub-phase; this module is Zig-only and -//! must not depend on the Lua machinery. - const std = @import("std"); const component = @import("tui_component.zig"); @@ -93,8 +83,7 @@ const Component = component.Component; // =========================================================================== /// A registered event handler. Vtable-style: a `callback` function pointer over -/// an opaque `ctx`, so a native closure, a Lua-backed handler, or a future -/// C-ABI handler all plug into the same shape (§7.6). +/// an opaque `ctx`. /// /// The callback receives the live `*Event`; it inspects `payload`, reads the /// current component with `event.getComponent()`, and optionally replaces it @@ -114,16 +103,8 @@ pub const Handler = struct { // Payload — structured per-event data (§7.2) // =========================================================================== -/// Structured data carried by an event, surfaced to handlers as typed fields -/// (the §7.2 `event.tool_name`, `event.args`, … shape). A tagged union keeps -/// the per-event fields explicit and bridge-friendly (the Lua bridge maps each -/// variant's fields onto the `event` object's properties). -/// -/// New built-in event types add a variant here; extension-defined events use -/// `.custom` with an opaque pointer the emitter and handler agree on. Borrowed -/// slices are valid only for the duration of the `emit` call (handlers must -/// copy anything they retain), mirroring the streaming-event borrow contract -/// elsewhere in panto. +/// Structured data carried by an event, surfaced to handlers as typed fields. +/// Borrowed slices are valid only for the duration of the `emit` call. pub const Payload = union(enum) { /// `session_start`: the welcome/banner boundary. session_start: SessionStart, @@ -146,9 +127,8 @@ pub const Payload = union(enum) { tool: Tool, /// `compaction`: a compaction-summary boundary. compaction: Compaction, - /// An extension-defined event. The emitter and handler agree on the - /// meaning of `data`; panto does not interpret it. - custom: Custom, + /// An extension-defined event with no structured payload. + custom: void, pub const SessionStart = struct { version: []const u8 = "", @@ -217,9 +197,6 @@ pub const Payload = union(enum) { pub const Compaction = struct { summary: []const u8 = "", }; - pub const Custom = struct { - data: ?*anyopaque = null, - }; }; // =========================================================================== @@ -399,7 +376,7 @@ test "emit with zero handlers returns the seeded default unchanged" { try testing.expectEqual(@as(*anyopaque, def.comp().ptr), out.?.ptr); // And a null default passes through as null. - const none = bus.fire("nope", null, .{ .custom = .{} }); + const none = bus.fire("nope", null, .{ .custom = {} }); try testing.expect(none == null); } |
