summaryrefslogtreecommitdiff
path: root/src/FrameStats.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 12:14:58 -0300
committerGabriel Schneider <[email protected]>2026-11-06 14:56:36 -0300
commit4c194047d210ad9cf571c6019731d00d1e3615a4 (patch)
tree257b994e471db3011589acd0cfb4a9168f803019 /src/FrameStats.zig
parent60dd9514c8676e79c625948b5e9d2c6d745e8e87 (diff)
downloadpardes-4c194047d210ad9cf571c6019731d00d1e3615a4.tar.gz
pardes-4c194047d210ad9cf571c6019731d00d1e3615a4.zip
idioms #4, string chains are an enum and a switch: main's flags (each exact one a Flag, the prefixed ones as they were), --ps's rows and manage's verb, the daemon's verbs on both ends and its registry's rows, an upgrade record's words, the window driver's mouse kinds and finger names, a frame script's click target and a mount name's reserved words go through std.meta.stringToEnum; with them main asks std.Io for its working directory, its chdir, a directory's access and /proc's comm, not libc
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/FrameStats.zig')
-rw-r--r--src/FrameStats.zig5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/FrameStats.zig b/src/FrameStats.zig
index 34a629dd..d55b9269 100644
--- a/src/FrameStats.zig
+++ b/src/FrameStats.zig
@@ -379,9 +379,8 @@ pub fn parseScript(arena: std.mem.Allocator, text: []const u8) error{ OutOfMemor
var parts = std.mem.tokenizeScalar(u8, arg, ' ');
const button = std.meta.stringToEnum(pardes.Mouse.Button, parts.next() orelse "") orelse return error.BadScript;
const where = std.fmt.parseFloat(f32, parts.next() orelse "") catch return error.BadScript;
- const on = parts.next() orelse "";
- if (!std.mem.eql(u8, on, "rail") and !std.mem.eql(u8, on, "text")) return error.BadScript;
- break :click .{ .click = .{ .button = button, .at = where, .rail = std.mem.eql(u8, on, "rail") } };
+ const on = std.meta.stringToEnum(enum { rail, text }, parts.next() orelse "") orelse return error.BadScript;
+ break :click .{ .click = .{ .button = button, .at = where, .rail = on == .rail } };
},
.paste => .{ .paste = try unescaped(arena, arg) },
.exec => .{ .exec = try unescaped(arena, arg) },