summaryrefslogtreecommitdiff
path: root/src/detached
diff options
context:
space:
mode:
Diffstat (limited to 'src/detached')
-rw-r--r--src/detached/wire.zig35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/detached/wire.zig b/src/detached/wire.zig
index 2f2b95c8..119601fc 100644
--- a/src/detached/wire.zig
+++ b/src/detached/wire.zig
@@ -11,28 +11,40 @@ const config = @import("pardes_config");
/// 16: a far client says so, the session sends it its blobs' hashes before
/// the rest and only the blobs it asks for, all of it in zstd (phase 6's
-/// content cache and zstd notes); 15: the session streams a replica its
-/// dump and units, and terminal deltas both ways (phase 5 part B); 14: the hello names a session and
+/// content cache and zstd notes), and a client says its frontend (a window
+/// or a terminal) as its first input, a window replicating a terminal's
+/// session and back (phase 6's GUI replica notes); 15: the session streams
+/// a replica its dump and units, and terminal deltas both ways (phase 5
+/// part B); 14: the hello names a session and
/// carries the semantics hash, and a ping is answered (phase 5's
/// groundwork); 13: the frames went (phase 3).
pub const version: u16 = 16;
+/// The terminal's build and the window's step alike (`semantics`).
+const family = switch (config.platform) {
+ .tty, .gui => "desktop",
+ else => @tagName(config.platform),
+};
+
/// What makes two cores step differently, hashed: a replica's hello carries
/// its own, and one of another build is refused. The protocol, the release
/// and commit, the platform and build options, every dependency's content
/// hash (grammars, ghostty, Unicode) and the walker codec's assumptions
/// (pointer width, byte order). Not the OS: a Linux client of a FreeBSD
/// session is the main case, and what differs there is the host's, taped.
+/// Nor the terminal's build against the window's: their cores step alike,
+/// the GUI's own words by the view's frontend (builtins.zig `here`), so a
+/// window replicates a terminal's session and a terminal a window's.
/// ponytail: an unstamped build (Debug with -Dplatform, every test build)
/// has no commit, so two dev trees of one release are told apart only by
/// their options and dependencies; -Dstamp-commit stamps one.
pub const semantics: u64 = blk: {
@setEvalBranchQuota(1_000_000);
break :blk std.hash.Wyhash.hash(0, std.fmt.comptimePrint(
- "wire {d}\npardes {s} {s}\n{t} grammars {} {} {} {} mupdf {} themes {} workspace_tag {} sources {} board {d}x{d}\nusize {d} {t}\n{s}",
+ "wire {d}\npardes {s} {s}\n{s} grammars {} {} {} {} mupdf {} themes {} workspace_tag {} sources {} board {d}x{d}\nusize {d} {t}\n{s}",
.{
version, config.version, config.commit orelse "unstamped",
- config.platform, config.syntax_highlighting, config.syntax_zig_grammar,
+ family, config.syntax_highlighting, config.syntax_zig_grammar,
config.syntax_minimal_grammars, config.syntax_full_grammars, config.mupdf,
config.theme_animation, config.workspace_tag, config.embed_sources,
config.esp32p4_cols, config.esp32p4_rows, @sizeOf(usize),
@@ -78,6 +90,8 @@ pub const ClientTag = enum(u8) {
touch_scroll = 0x1c,
pointer_leave = 0x1d,
focus = 0x1e,
+ /// Which frontend the client is: a window, or a terminal.
+ frontend = 0x20,
};
const ButtonTag = enum(u8) {
@@ -505,6 +519,11 @@ pub fn encodeClient(out: []u8, msg: ClientMsg) Error![]const u8 {
.touch_scroll => |v| try w.writeInt(u32, @bitCast(v), .little),
.pointer_leave => {},
.focus => |focused| try w.writeByte(@intFromBool(focused)),
+ .frontend => |f| {
+ try w.writeByte(@intFromBool(f.windowed));
+ try w.writeByte(@intFromBool(f.native_images));
+ try w.writeByte(@intFromBool(f.native_image_patches));
+ },
// See `clientTag`: no tag, so nothing to encode.
.output, .eof, .exited, .lsp_resp, .pipe_resp, .search, .file_changed, .handed, .tick => unreachable,
},
@@ -577,6 +596,7 @@ pub fn decodeClient(tag: u8, payload: []const u8) Error!ClientMsg {
.touch_scroll => .{ .event = .{ .touch_scroll = try getF32(&r) } },
.pointer_leave => .{ .event = .pointer_leave },
.focus => .{ .event = .{ .focus = try getBool(&r) } },
+ .frontend => .{ .event = .{ .frontend = .{ .windowed = try getBool(&r), .native_images = try getBool(&r), .native_image_patches = try getBool(&r) } } },
};
try end(&r);
return msg;
@@ -594,7 +614,7 @@ pub fn clientBound(msg: ClientMsg) usize {
.bye, .ping, .check, .far => 0,
.screen_ack, .want => |bytes| bytes.len,
.event => |ev| switch (ev) {
- .mouse, .resize, .pdf_scroll, .pinch, .touch_scroll, .pointer_leave, .focus => 0,
+ .mouse, .resize, .pdf_scroll, .pinch, .touch_scroll, .pointer_leave, .focus, .frontend => 0,
.key => |k| k.text.len,
.paste => |b| b.len,
.command => |line| line.len,
@@ -732,9 +752,12 @@ test "detached wire: a session is never told to do a frontend's remembering" {
// ...and how far it is, and which of the join's blobs it lacks.
"far", "want",
// ...and everything a person can do to a window.
- "key", "mouse", "resize",
+ "key", "mouse", "resize",
"paste", "command", "pdf_scroll", "pinch", "touch_scroll",
"pointer_leave", "focus",
+ // ...and which of its frontends the person sits at: a window, or a
+ // terminal (what the view draws, and the words it takes).
+ "frontend",
};
// One: the tag set is exactly that, named rather than counted, so