summaryrefslogtreecommitdiff
path: root/src/detached/wire.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-21 14:35:15 -0300
committerGabriel Schneider <[email protected]>2026-10-22 10:03:15 -0300
commitbc3d18d27f9fc1155db7fac3946c4d38774f9e65 (patch)
tree9178ce95952797f8a78b16c2b805e53368efb35a /src/detached/wire.zig
parent1ecb9b720840ea8e4753823fa8cddcf5d6a3a4d2 (diff)
downloadpardes-bc3d18d27f9fc1155db7fac3946c4d38774f9e65.tar.gz
pardes-bc3d18d27f9fc1155db7fac3946c4d38774f9e65.zip
Build with Zig 0.17
ghostty, libvaxis and uucode move to ghostty's 0.17 pins, cloud9 to its 0.17 main, SDL to castholm's release-3.4.x (3.4.18), zstbi and tree-sitter to forks with 0.17 build files (see build.zig.zon). A bare zig build copies the binaries into ~/.local/bin (-Dhome-install=false leaves it out): 0.17 keeps the prefix from build scripts. A terminal's edited copy goes when the program clears the screen. tinywin.snap is gone; perf baselines are re-recorded. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/detached/wire.zig')
-rw-r--r--src/detached/wire.zig39
1 files changed, 21 insertions, 18 deletions
diff --git a/src/detached/wire.zig b/src/detached/wire.zig
index c9d9b578..f1b7a1b3 100644
--- a/src/detached/wire.zig
+++ b/src/detached/wire.zig
@@ -20,9 +20,10 @@ const chrome_layout: u64 = 0x5e758b47fb0cf8da;
comptime {
@setEvalBranchQuota(10_000);
var hash = std.hash.Fnv1a_64.init();
- for (@typeInfo(pardes.Chrome).@"struct".fields) |field| {
- hash.update(field.name);
- hash.update(@typeName(field.type));
+ const info = @typeInfo(pardes.Chrome).@"struct";
+ for (info.field_names, info.field_types) |name, T| {
+ hash.update(name);
+ hash.update(@typeName(T));
}
if (hash.final() != chrome_layout) @compileError(std.fmt.comptimePrint("pardes.Chrome changed (layout 0x{x}): bump wire.version, then chrome_layout", .{hash.final()}));
}
@@ -285,21 +286,22 @@ pub const Frame = struct {
region.clip > region.rect.w or region.thumb_y > region.rect.h or region.thumb_h > region.rect.h - region.thumb_y) return error.BadValue;
regions.appendAssumeCapacity(region);
}
- inline for (@typeInfo(pardes.Chrome).@"struct".fields) |field| {
- const rgb = &@field(chrome, field.name);
- if (field.type == ?[3]u8) {
+ const info = @typeInfo(pardes.Chrome).@"struct";
+ inline for (info.field_names, info.field_types) |name, T| {
+ const rgb = &@field(chrome, name);
+ if (T == ?[3]u8) {
if (try r.getBool()) {
rgb.* = .{ 0, 0, 0 };
for (&rgb.*.?) |*channel| channel.* = try r.getByte();
}
- } else if (field.type == u8) {
+ } else if (T == u8) {
rgb.* = try r.getByte();
- } else if (field.type == u32) {
+ } else if (T == u32) {
rgb.* = try r.getU32();
- } else if (field.type == f32) {
+ } else if (T == f32) {
rgb.* = @bitCast(try r.getU32());
if (!std.math.isFinite(rgb.*)) return error.BadValue;
- } else if (field.type == [8]f32) {
+ } else if (T == [8]f32) {
for (rgb) |*value| {
value.* = @bitCast(try r.getU32());
if (!std.math.isFinite(value.*)) return error.BadValue;
@@ -781,7 +783,7 @@ pub fn layersBound(layers: []const pardes.Layer, tags: []const pardes.Layer, reg
const region_len = 1 + 1 + 4 + 8 + 1 + 2 + 2 + 1 + 2 + 4 + 4;
/// The palette: each colour three bytes, a theme's optional ones a flag
/// before them.
-const chrome_len = @typeInfo(pardes.Chrome).@"struct".fields.len * 4 + 8 * 4;
+const chrome_len = @typeInfo(pardes.Chrome).@"struct".field_names.len * 4 + 8 * 4;
pub fn encodeFrameLayers(out: []u8, cols: u16, rows: u16, cursor: ?Cursor, pointer_shape: pardes.Surface.PointerShape, cells: []const pardes.Cell, prev: []const pardes.Cell, layers: []const pardes.Layer, tags: []const pardes.Layer, regions: []const pardes.Region, chrome: pardes.Chrome) Error![]const u8 {
// The protocol's ceiling, enforced by the ENCODER too, and BEFORE the
@@ -865,18 +867,19 @@ pub fn encodeFrameLayers(out: []u8, cols: u16, rows: u16, cursor: ?Cursor, point
try w.putU32(@bitCast(region.lift));
try w.putU32(@bitCast(region.line));
}
- inline for (@typeInfo(pardes.Chrome).@"struct".fields) |field| {
- const rgb = @field(chrome, field.name);
- if (field.type == ?[3]u8) {
+ const info = @typeInfo(pardes.Chrome).@"struct";
+ inline for (info.field_names, info.field_types) |name, T| {
+ const rgb = @field(chrome, name);
+ if (T == ?[3]u8) {
try w.putBool(rgb != null);
if (rgb) |value| for (value) |channel| try w.putByte(channel);
- } else if (field.type == u8) {
+ } else if (T == u8) {
try w.putByte(rgb);
- } else if (field.type == u32) {
+ } else if (T == u32) {
try w.putU32(rgb);
- } else if (field.type == f32) {
+ } else if (T == f32) {
try w.putU32(@bitCast(rgb));
- } else if (field.type == [8]f32) {
+ } else if (T == [8]f32) {
for (rgb) |value| try w.putU32(@bitCast(value));
} else for (rgb) |channel| try w.putByte(channel);
}