diff options
Diffstat (limited to 'core/config.zig')
| -rw-r--r-- | core/config.zig | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/core/config.zig b/core/config.zig index f1e2a239..792a7e62 100644 --- a/core/config.zig +++ b/core/config.zig @@ -834,7 +834,7 @@ pub const Runtime = struct { } /// `home`: what `~` is (the session's: Pardes.session_home). - pub fn apply(state: *Runtime, setting: Setting, argument: ?[]const u8, home: ?[]const u8) bool { + pub fn apply(state: *Runtime, tape: *pardes.tape.Tape, setting: Setting, argument: ?[]const u8, home: ?[]const u8) bool { switch (setting.action) { // Every toggle names a bool field of its own, so one line covers // all of them and a new toggle needs no arm here. Bare, a toggle @@ -868,7 +868,7 @@ pub const Runtime = struct { var home_buf: [4096]u8 = undefined; // The session's disk's answer, as a failed save's (Core.zig): // a client's replay takes it, never its own disk's. - if (pardes.tape.value(.denied, pardes.filesystem.deniedAbove, .{pardes.filesystem.expandHomeFrom(text, &home_buf, home)})) return false; + if (tape.value(.denied, pardes.filesystem.deniedAbove, .{pardes.filesystem.expandHomeFrom(tape, text, &home_buf, home)})) return false; } if (!state.dump_dir.set(text)) return false; }, @@ -1072,28 +1072,28 @@ pub const Runtime = struct { const verbose = find("Verbose").?; try std.testing.expect(state.verbose); // Bare, it flips: that is what a tagline word does. - try std.testing.expect(apply(&state, verbose, null, null)); + try std.testing.expect(apply(&state, &pardes.tape.none, verbose, null, null)); try std.testing.expect(!state.verbose); // Told, it SETS -- twice over, so the second call proves it is not // flipping past the value it was given. - try std.testing.expect(apply(&state, verbose, "on", null)); + try std.testing.expect(apply(&state, &pardes.tape.none, verbose, "on", null)); try std.testing.expect(state.verbose); - try std.testing.expect(apply(&state, verbose, " on\n", null)); + try std.testing.expect(apply(&state, &pardes.tape.none, verbose, " on\n", null)); try std.testing.expect(state.verbose); - try std.testing.expect(apply(&state, verbose, "off", null)); + try std.testing.expect(apply(&state, &pardes.tape.none, verbose, "off", null)); try std.testing.expect(!state.verbose); - try std.testing.expect(apply(&state, verbose, "off", null)); + try std.testing.expect(apply(&state, &pardes.tape.none, verbose, "off", null)); try std.testing.expect(!state.verbose); // And anything else is refused rather than silently flipping. - try std.testing.expect(!apply(&state, verbose, "maybe", null)); + try std.testing.expect(!apply(&state, &pardes.tape.none, verbose, "maybe", null)); try std.testing.expect(!state.verbose); } test "simple setting application mutates only its plain field" { var state: Runtime = .{}; - try std.testing.expect(apply(&state, find("Wrap").?, null, null)); + try std.testing.expect(apply(&state, &pardes.tape.none, find("Wrap").?, null, null)); try std.testing.expect(!state.wrap); - try std.testing.expect(apply(&state, find("Shell").?, " fish\n", null)); + try std.testing.expect(apply(&state, &pardes.tape.none, find("Shell").?, " fish\n", null)); try std.testing.expectEqualStrings("fish", state.shell.requested.get()); try std.testing.expect(state.shell.pending); } @@ -1103,13 +1103,13 @@ pub const Runtime = struct { var state: Runtime = .{}; for ([_][]const u8{ "1", " 82\n", "100" }) |argument| { - try std.testing.expect(apply(&state, setting, argument, null)); + try std.testing.expect(apply(&state, &pardes.tape.none, setting, argument, null)); try std.testing.expectEqual(try std.fmt.parseInt(u8, std.mem.trim(u8, argument, " \t\r\n"), 10), state.font.tagline_percent); } state.font.tagline_percent = 67; for ([_]?[]const u8{ null, "", "0", "101", "-1", "50%", "999999999999999999999" }) |argument| { - try std.testing.expect(!apply(&state, setting, argument, null)); + try std.testing.expect(!apply(&state, &pardes.tape.none, setting, argument, null)); try std.testing.expectEqual(@as(u8, 67), state.font.tagline_percent); } } @@ -1123,7 +1123,7 @@ pub const Runtime = struct { for ([_][]const u8{ "0", " 85\n", "100" }, [_]u8{ 0, 85, 100 }) |argument, expected| { state.window_opacity_pending = false; - try std.testing.expect(apply(&state, setting, argument, null)); + try std.testing.expect(apply(&state, &pardes.tape.none, setting, argument, null)); try std.testing.expectEqual(expected, state.window_opacity); try std.testing.expect(state.window_opacity_pending); } @@ -1131,12 +1131,12 @@ pub const Runtime = struct { state.window_opacity = 85; state.window_opacity_pending = false; for ([_]?[]const u8{ null, "", " \t\n", "101", "-1", "+85", "85%", "0.5", "85.0", "85 20", "8_5", "0x55", "999999999999999999999" }) |argument| { - try std.testing.expect(!apply(&state, setting, argument, null)); + try std.testing.expect(!apply(&state, &pardes.tape.none, setting, argument, null)); try std.testing.expectEqual(@as(u8, 85), state.window_opacity); try std.testing.expect(!state.window_opacity_pending); } // Reissuing the same request still asks the host to apply it again. - try std.testing.expect(apply(&state, setting, "85", null)); + try std.testing.expect(apply(&state, &pardes.tape.none, setting, "85", null)); try std.testing.expect(state.window_opacity_pending); } @@ -1192,7 +1192,7 @@ pub const Runtime = struct { .{ "GripWidth", "200" }, .{ "InactiveDim", "35" }, .{ "CallstackDepth", "16" }, .{ "Tab", "8" }, }; - for (values) |v| try std.testing.expect(apply(&state, find(v[0]).?, v[1], null)); + for (values) |v| try std.testing.expect(apply(&state, &pardes.tape.none, find(v[0]).?, v[1], null)); try std.testing.expect(state.font.requested_name.set("Wanted Mono")); try std.testing.expect(state.font.requested_path.set("/fonts/wanted.ttf")); state.font.requested_size_hundredths = 1850; @@ -1841,11 +1841,11 @@ test "CallstackDepth is bounded and keeps the last valid runtime limit" { var state: Runtime = .{}; try std.testing.expectEqual(@as(u8, 8), state.callstack_depth); for ([_][]const u8{ "1", "8", "16", "64" }) |value| { - try std.testing.expect(Runtime.apply(&state, Runtime.find("CallstackDepth").?, value, null)); + try std.testing.expect(Runtime.apply(&state, &pardes.tape.none, Runtime.find("CallstackDepth").?, value, null)); try std.testing.expectEqual(try std.fmt.parseInt(u8, value, 10), state.callstack_depth); } for ([_][]const u8{ "0", "65", "256", "-1", "+8", "1_6", "eight", "" }) |value| { - try std.testing.expect(!Runtime.apply(&state, Runtime.find("CallstackDepth").?, value, null)); + try std.testing.expect(!Runtime.apply(&state, &pardes.tape.none, Runtime.find("CallstackDepth").?, value, null)); try std.testing.expectEqual(@as(u8, 64), state.callstack_depth); } } |
