summaryrefslogtreecommitdiff
path: root/src/config.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.zig')
-rw-r--r--src/config.zig45
1 files changed, 33 insertions, 12 deletions
diff --git a/src/config.zig b/src/config.zig
index 48f49d50..01a5daf8 100644
--- a/src/config.zig
+++ b/src/config.zig
@@ -74,6 +74,7 @@ pub const leader_path = paths: {
.Delcol = "cd",
.Joincol = "cj",
.Placement = "cp",
+ .BootShell = null,
.Debug = "td",
.Msg = null,
.Colors = "tc",
@@ -666,9 +667,16 @@ pub const Runtime = struct {
/// Where a new pane goes (exec.placeNew): `acme`, acme's makenewwindow,
/// or `pardes`, the rules pardes had before it.
placement: Placement = .acme,
+ /// A document dragged into the left column where a lone shell nobody
+ /// has typed into stands: `keep` leaves the shell, `replace` closes it
+ /// (exec.evictLonePristineTty).
+ boot_shell: BootShell = .keep,
pub const ShaderAnimation = enum { off, on, always };
pub const Placement = enum { acme, pardes };
+ pub const BootShell = enum { keep, replace };
+ /// A setting that is one of a few words, each an enum field of Runtime.
+ pub const Choice = enum { placement, boot_shell };
/// Each pass the bundled Crt or a Shadertoy file.
pub const Post = struct {
@@ -841,7 +849,7 @@ pub const Runtime = struct {
/// it of files.
shader,
shader_animation,
- placement,
+ choice: Choice,
};
pub const Setting = struct {
@@ -893,7 +901,8 @@ pub const Runtime = struct {
.{ .word = "Crt", .action = .{ .scene = .crt }, .availability = .scene_shaders },
.{ .word = "Shader", .action = .shader, .availability = .scene_shaders },
.{ .word = "ShaderAnimation", .action = .shader_animation, .availability = .scene_shaders },
- .{ .word = "Placement", .action = .placement },
+ .{ .word = "Placement", .action = .{ .choice = .placement } },
+ .{ .word = "BootShell", .action = .{ .choice = .boot_shell } },
};
pub fn find(name: []const u8) ?Setting {
@@ -1052,13 +1061,17 @@ pub const Runtime = struct {
const text = std.mem.trim(u8, argument orelse return false, " \t\r\n");
state.shader_animation = std.meta.stringToEnum(ShaderAnimation, text) orelse return false;
},
- // Bare, it flips between the two, as a tag word should.
- .placement => {
- const text = std.mem.trim(u8, argument orelse "", " \t\r\n");
- state.placement = if (text.len == 0)
- (if (state.placement == .acme) .pardes else .acme)
- else
- std.meta.stringToEnum(Placement, text) orelse return false;
+ // Bare, it steps to the next word, as a tag word should.
+ .choice => |which| switch (which) {
+ inline else => |field| {
+ const now = &@field(state, @tagName(field));
+ const T = @TypeOf(now.*);
+ const text = std.mem.trim(u8, argument orelse "", " \t\r\n");
+ now.* = if (text.len == 0)
+ @enumFromInt((@as(usize, @intFromEnum(now.*)) + 1) % std.enums.values(T).len)
+ else
+ std.meta.stringToEnum(T, text) orelse return false;
+ },
},
.theme, .font => return false,
}
@@ -1229,7 +1242,9 @@ pub const Runtime = struct {
try out.print("{s} {s}\n", .{ setting.word, @tagName(state.shader_animation) })
else
try out.print("{s} unsupported\n", .{setting.word}),
- .placement => try out.print("{s} {s}\n", .{ setting.word, @tagName(state.placement) }),
+ .choice => |which| switch (which) {
+ inline else => |field| try out.print("{s} {s}\n", .{ setting.word, @tagName(@field(state, @tagName(field))) }),
+ },
};
if (context.startup_config_path) |path|
@@ -1481,7 +1496,10 @@ pub const Runtime = struct {
.dump_dir => "~/dumps",
.shader => "~/crt.glsl",
.shader_animation => "always",
- .placement => "pardes",
+ .choice => |which| switch (which) {
+ .placement => "pardes",
+ .boot_shell => "replace",
+ },
else => null,
};
try std.testing.expect(apply(&state, setting, argument));
@@ -1531,7 +1549,10 @@ pub const Runtime = struct {
},
.shader => "Shader ~/crt.glsl\n",
.shader_animation => "ShaderAnimation always\n",
- .placement => "Placement pardes\n",
+ .choice => |which| switch (which) {
+ .placement => "Placement pardes\n",
+ .boot_shell => "BootShell replace\n",
+ },
.theme, .font => unreachable,
};
try std.testing.expect(std.mem.indexOf(u8, report, expected) != null);