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 792a7e62..0032b03a 100644 --- a/core/config.zig +++ b/core/config.zig @@ -79,7 +79,7 @@ pub const leader_path = paths: { .Mode = null, .Togglettymode = null, .Collapse = null, - .Unattach = null, + .Undock = null, .Undo = null, .Edit = null, .Redo = null, @@ -600,7 +600,7 @@ pub const delete_word_forward: []const Chord = &.{ .{ .cp = 'd', .alt = true }, pub const kill_to_line_start: []const Chord = &.{.{ .cp = 'u', .ctrl = true }}; pub const kill_to_line_end: []const Chord = &.{.{ .cp = 'k', .ctrl = true }}; -pub const Runtime = struct { +pub const Settings = struct { theme: usize = 0, wrap: bool = true, debug: bool = false, @@ -662,7 +662,7 @@ pub const Runtime = struct { tab: u16 = tab_width, callstack_depth: u8 = @import("lsp/lsp.zig").callstack_default_depth, - /// A setting that is one of a few words, each an enum field of Runtime. + /// A setting that is one of a few words, each an enum field of Settings. pub const Choice = enum { pet }; pub const Pet = enum { off, cat, frog }; @@ -710,7 +710,7 @@ pub const Runtime = struct { }; // Validate the complete request before changing any member. - pub fn requestFont(state: *Runtime, path: []const u8, name: []const u8, size_hundredths: u16) bool { + pub fn requestFont(state: *Settings, path: []const u8, name: []const u8, size_hundredths: u16) bool { if (path.len > state.font.requested_path.bytes.len or name.len > state.font.requested_name.bytes.len) return false; if (size_hundredths != 0 and (size_hundredths < 800 or size_hundredths > 7200)) return false; @@ -834,7 +834,7 @@ pub const Runtime = struct { } /// `home`: what `~` is (the session's: Pardes.session_home). - pub fn apply(state: *Runtime, tape: *pardes.tape.Tape, setting: Setting, argument: ?[]const u8, home: ?[]const u8) bool { + pub fn apply(state: *Settings, 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 @@ -903,7 +903,7 @@ pub const Runtime = struct { return switch (action) { .toggle => "on, off", .choice => |which| switch (which) { - inline else => |field| comptime words.of(@FieldType(Runtime, @tagName(field))), + inline else => |field| comptime words.of(@FieldType(Settings, @tagName(field))), }, else => null, }; @@ -970,7 +970,7 @@ pub const Runtime = struct { default_dump_dir: []const u8 = "", native_images: bool = false, capabilities: Capabilities, - state: *const Runtime, + state: *const Settings, /// The `LocationsConfig` argument in effect, as it would be typed. locations: []const u8 = "", }; @@ -1068,7 +1068,7 @@ pub const Runtime = struct { } test "a toggle flips when bare and sets when told on or off" { - var state: Runtime = .{}; + var state: Settings = .{}; const verbose = find("Verbose").?; try std.testing.expect(state.verbose); // Bare, it flips: that is what a tagline word does. @@ -1090,7 +1090,7 @@ pub const Runtime = struct { } test "simple setting application mutates only its plain field" { - var state: Runtime = .{}; + var state: Settings = .{}; 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, &pardes.tape.none, find("Shell").?, " fish\n", null)); @@ -1100,7 +1100,7 @@ pub const Runtime = struct { test "tagline size validates before mutating live state" { const setting = find("TaglineSize").?; - var state: Runtime = .{}; + var state: Settings = .{}; for ([_][]const u8{ "1", " 82\n", "100" }) |argument| { try std.testing.expect(apply(&state, &pardes.tape.none, setting, argument, null)); @@ -1116,7 +1116,7 @@ pub const Runtime = struct { test "window opacity defaults to opaque validates atomically and retries" { const setting = find("WindowOpacity").?; - var state: Runtime = .{}; + var state: Settings = .{}; try std.testing.expectEqual(@as(u8, 100), state.window_opacity); try std.testing.expect(state.window_opacity_pending); try std.testing.expectEqual(Capability.window_opacity, availability(setting.action).?); @@ -1141,7 +1141,7 @@ pub const Runtime = struct { } test "font request tuple rejects atomically" { - var state: Runtime = .{}; + var state: Settings = .{}; try std.testing.expect(requestFont(&state, "/fonts/old.ttf", "Old", 1200)); var too_long: [256]u8 = @splat('x'); try std.testing.expect(!requestFont(&state, "/fonts/new.ttf", &too_long, 1800)); @@ -1168,7 +1168,7 @@ pub const Runtime = struct { // The switches, Theme, Shell, Pager and the shell's own lines are // test/behaviour/settings.zig's, read through the root ctl and the // +DumpConfig pane. - var state: Runtime = .{}; + var state: Settings = .{}; // Every setting, every context line: the report outgrows 4K. var storage: [8192]u8 = undefined; const context: ReportContext = .{ @@ -1219,7 +1219,7 @@ pub const Runtime = struct { "# Native images: on\n", }) |expected| try std.testing.expect(std.mem.indexOf(u8, report, expected) != null); - var defaults: Runtime = .{}; + var defaults: Settings = .{}; var defaults_context = context; defaults_context.startup_config_path = null; defaults_context.platform = "tui"; @@ -1693,7 +1693,7 @@ test "wheel drift guard" { } test { - _ = Runtime; + _ = Settings; _ = User; } @@ -1838,14 +1838,14 @@ test "reference.typ's #fstree is the tree the session serves, file for file" { } test "CallstackDepth is bounded and keeps the last valid runtime limit" { - var state: Runtime = .{}; + var state: Settings = .{}; 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, &pardes.tape.none, Runtime.find("CallstackDepth").?, value, null)); + try std.testing.expect(Settings.apply(&state, &pardes.tape.none, Settings.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, &pardes.tape.none, Runtime.find("CallstackDepth").?, value, null)); + try std.testing.expect(!Settings.apply(&state, &pardes.tape.none, Settings.find("CallstackDepth").?, value, null)); try std.testing.expectEqual(@as(u8, 64), state.callstack_depth); } } |
