summaryrefslogtreecommitdiff
path: root/src/wire.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 06:24:42 -0300
committerGabriel Schneider <[email protected]>2026-11-06 11:19:44 -0300
commitc1917b949b9580de8bf0977874a210f0266812da (patch)
tree447dd2235ea00634f662cd3becf4bceb8a895f41 /src/wire.zig
parent76c55b5bce0f181b0b15b16596c900397dfef544 (diff)
downloadpardes-c1917b949b9580de8bf0977874a210f0266812da.tar.gz
pardes-c1917b949b9580de8bf0977874a210f0266812da.zip
kinds #14, the core's PDF code gone: pdf.zig and pdf_view.zig leave and every pdf_enabled branch with them; look, Jump, Recent, dumps (one from before the addon opens as its pane), the watch, mouse, keys, the rail and the tag go through Kind for any kind's pane; test/pdf.zig's behaviours are T1 cases over 9P (addons_pdf.zig) and pane cases (a Shadow over a replica, a file changed under it), the harnesses load pdf.so by path
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/wire.zig')
-rw-r--r--src/wire.zig55
1 files changed, 11 insertions, 44 deletions
diff --git a/src/wire.zig b/src/wire.zig
index 91e805e7..d083ea82 100644
--- a/src/wire.zig
+++ b/src/wire.zig
@@ -9,6 +9,8 @@ const builtin = @import("builtin");
const pardes = @import("pardes.zig");
const config = @import("pardes_config");
+/// 22: a PDF's pixel scroll (0x1a) is gone with the core's PDF, the pdf
+/// addon's panes scrolled by the wheel as any kind's are;
/// 21: a session's views are `Pardes.views` in its dump and its digest
/// (src/views.zig), the panes' shares of the others under `shares`;
/// 20: a digest takes a blob of 4 KiB and up (a file's text, a register's,
@@ -29,7 +31,7 @@ const config = @import("pardes_config");
/// 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 = 21;
+pub const version: u16 = 22;
/// The terminal's build and the window's step alike (`semantics`).
const family = switch (config.platform) {
@@ -56,13 +58,13 @@ const family = switch (config.platform) {
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{s} grammars {} {} {} {} mupdf {} workspace_tag {} sources {}\nusize {d} {t}\n{s}\n{s}",
+ "wire {d}\npardes {s} {s}\n{s} grammars {} {} {} {} workspace_tag {} sources {}\nusize {d} {t}\n{s}\n{s}",
.{
version, config.version, config.commit orelse "unstamped",
family, config.syntax_highlighting, config.syntax_zig_grammar,
- config.syntax_minimal_grammars, config.syntax_full_grammars, config.mupdf,
- config.workspace_tag, config.embed_sources, @sizeOf(usize),
- builtin.cpu.arch.endian(), config.deps, pardes.tape.shape,
+ config.syntax_minimal_grammars, config.syntax_full_grammars, config.workspace_tag,
+ config.embed_sources, @sizeOf(usize), builtin.cpu.arch.endian(),
+ config.deps, pardes.tape.shape,
},
));
};
@@ -103,8 +105,8 @@ pub const ClientTag = enum(u8) {
resize = 0x12,
paste = 0x18,
command = 0x19,
- pdf_scroll = 0x1a,
- // 0x1b and 0x1c were a pinch and a touch scroll, gone since.
+ // 0x1a was a PDF's pixel scroll, 0x1b and 0x1c a pinch and a touch
+ // scroll, gone since.
pointer_leave = 0x1d,
focus = 0x1e,
/// Which frontend the client is: a window, or a terminal.
@@ -323,14 +325,6 @@ fn getSlice32(r: *std.Io.Reader) Error![]const u8 {
return r.take(n);
}
-/// A pane id the core can actually index. `Event.output{ .pane = 200 }`
-/// would reach `p.panes[200]`.
-fn getPane(r: *std.Io.Reader) Error!u8 {
- const pane = try r.takeByte();
- if (pane >= pardes.MAX_PANES) return error.BadValue;
- return pane;
-}
-
/// A grid the core can render into. Zero is refused rather than clamped: a
/// frontend that has not been sized yet must not be allowed to collapse a
/// shared session to nothing.
@@ -539,11 +533,6 @@ pub fn encodeClient(out: []u8, msg: ClientMsg) Error![]const u8 {
},
.paste => |b| try putSlice32(&w, b),
.command => |line| try putSlice16(&w, line),
- .pdf_scroll => |s| {
- try w.writeByte(s.pane);
- try w.writeInt(u32, @bitCast(s.delta_pixels), .little);
- try w.writeByte(@intFromBool(s.glide));
- },
.pointer_leave => {},
.focus => |focused| try w.writeByte(@intFromBool(focused)),
.frontend => |f| {
@@ -623,7 +612,6 @@ pub fn decodeClient(tag: u8, payload: []const u8) Error!ClientMsg {
},
.paste => .{ .event = .{ .paste = try getSlice32(&r) } },
.command => .{ .event = .{ .command = try r.take(try r.takeInt(u16, .little)) } },
- .pdf_scroll => .{ .event = .{ .pdf_scroll = .{ .pane = try getPane(&r), .delta_pixels = try getF32(&r), .glide = try getBool(&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) } } },
@@ -646,7 +634,7 @@ pub fn clientBound(msg: ClientMsg) usize {
.event => |ev| switch (ev) {
// Its hits' places (14 bytes each) past the slack.
.mouse => 28,
- .resize, .pdf_scroll, .pointer_leave, .focus, .frontend => 0,
+ .resize, .pointer_leave, .focus, .frontend => 0,
.key => |k| k.text.len,
.paste => |b| b.len,
.command => |line| line.len,
@@ -746,12 +734,6 @@ test "detached wire: every Event variant round-trips" {
}
try testing.expectEqualStrings("clip", (try roundClient(&buf, .{ .event = .{ .paste = "clip" } })).event.paste);
try testing.expectEqualStrings("Look /x", (try roundClient(&buf, .{ .event = .{ .command = "Look /x" } })).event.command);
- {
- const got = (try roundClient(&buf, .{ .event = .{ .pdf_scroll = .{ .pane = 2, .delta_pixels = -12.5, .glide = false } } })).event.pdf_scroll;
- try testing.expectEqual(@as(u8, 2), got.pane);
- try testing.expectEqual(@as(f32, -12.5), got.delta_pixels);
- try testing.expect(!got.glide);
- }
try testing.expectEqual(
std.meta.Tag(pardes.Event).pointer_leave,
(try roundClient(&buf, .{ .event = .pointer_leave })).event,
@@ -780,7 +762,7 @@ test "detached wire: a session is never told to do a frontend's remembering" {
"stamp",
// ...and everything a person can do to a window.
"key", "mouse", "resize",
- "paste", "command", "pdf_scroll", "pointer_leave", "focus",
+ "paste", "command", "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",
@@ -893,13 +875,6 @@ test "detached wire: values a field cannot mean are refused" {
@backingInt(ClientTag.key),
&.{ 0x00, 0x00, 0x11, 0x00, 0, 0, 0, 0, 0 },
));
- // A pane the core cannot index. `pdf_scroll` reads its pane byte before the
- // f32 that follows, so a one-byte payload reaches the check this is about
- // rather than tripping `EndOfStream` first.
- try testing.expectError(error.BadValue, decodeClient(
- @backingInt(ClientTag.pdf_scroll),
- &.{pardes.MAX_PANES},
- ));
// A session name longer than the daemon keeps one: refused, never cut
// to another session's name.
{
@@ -912,14 +887,6 @@ test "detached wire: values a field cannot mean are refused" {
try testing.expectEqual(@as(usize, max_name), (try decodeClient(@backingInt(ClientTag.hello), &hello)).hello.session.len);
try testing.expect(header_len + hello.len == hello_max);
}
- // A NaN or an infinite scroll distance.
- {
- var scroll: [6]u8 = .{ 0, 0, 0, 0, 0, 1 };
- std.mem.writeInt(u32, scroll[1..5], @bitCast(std.math.nan(f32)), .little);
- try testing.expectError(error.BadValue, decodeClient(@backingInt(ClientTag.pdf_scroll), &scroll));
- std.mem.writeInt(u32, scroll[1..5], @bitCast(std.math.inf(f32)), .little);
- try testing.expectError(error.BadValue, decodeClient(@backingInt(ClientTag.pdf_scroll), &scroll));
- }
}
test "detached wire: max_payload bounds every message this protocol can build" {