diff options
Diffstat (limited to 'core/replica.zig')
| -rw-r--r-- | core/replica.zig | 50 |
1 files changed, 35 insertions, 15 deletions
diff --git a/core/replica.zig b/core/replica.zig index ff43203a..24d1ad21 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -6229,9 +6229,12 @@ const may_wait = [_]Wait{ .{ .what = "*", .on = .addon, .stop = "a kind's close", .why = "a kind's pane closed: its state let go on the session" }, .{ .what = "*", .on = .addon, .stop = "a kind's word", .why = "a word to a kind (a key it takes as one): its own state" }, .{ .what = "*", .on = .addon, .stop = "a kind's open", .why = "a kind's pane opened (`Life`): its state made on the session" }, -} ++ (if (pardes.platform == .gui) [_]Wait{ +} ++ (if (pardes.font_picker) [_]Wait{ // A window's view (the font words are a window's). .{ .what = "Font *", .on = .any, .stop = "fonts", .why = "the session's machine's fonts, its disk" }, +} else [_]Wait{}) ++ (if (pardes.builtins.capabilities.font_picker) [_]Wait{ + // ...and Fonts a terminal's build has too, which a window client of its + // session runs (exec.zig's Font, a window build's alone, does not). .{ .what = "Fonts", .on = .any, .stop = "fonts", .why = "the session's machine's fonts, its disk" }, } else [_]Wait{}); @@ -6385,6 +6388,23 @@ const Walk = struct { return what.len >= pattern.len - 1 and std.mem.startsWith(u8, what, pattern[0..star]) and std.mem.endsWith(u8, what, pattern[star + 1 ..]); } + /// Every word, with a sample argument where one is required. + fn words(w: *Walk) !void { + var line: [128]u8 = undefined; + for (std.enums.values(pardes.builtins.registry.Builtin())) |b| { + const name = @tagName(b); + const arg: ?[]const u8 = for (walk_samples) |s| { + if (std.mem.eql(u8, s[0], name)) break s[1]; + } else null; + if (pardes.builtins.registry.requiresArg(b) and arg == null) { + std.debug.print("may_wait: `{s}` requires an argument: give it one in walk_samples\n", .{name}); + return error.NoSample; + } + const cmd = if (arg) |x| try std.fmt.bufPrint(&line, "{s} {s}", .{ name, x }) else name; + try w.try_(cmd, &.{.{ .command = cmd }}); + } + } + /// The name of what stopped the inputs, "" when none did. fn try_(w: *Walk, what: []const u8, evs: []const pardes.Event) !void { const r = w.r; @@ -6451,7 +6471,6 @@ test "a far client's every word and key, on a file's pane, a kind's and a shell' var hit: [may_wait.len]bool = @splat(false); var unlisted: u32 = 0; var tried: u32 = 0; - const Builtin = pardes.builtins.registry.Builtin(); const stands = [_]struct { On, ?usize }{ .{ .file, file }, .{ .kind, kind }, .{ .shell, shell }, .{ .shell_normal, shell } }; for (stands) |stand| { const on, const at = stand; @@ -6473,19 +6492,7 @@ test "a far client's every word and key, on a file's pane, a kind's and a shell' try std.testing.expectEqual(id, r.core().view().active); if (on == .shell) try std.testing.expect(pardes.Term.modes(r.core().panes[id].?.terminal).focus); var w: Walk = .{ .r = r, .on = on, .seen = &seen, .hit = &hit }; - // Every word, with a sample argument where one is required. - for (std.enums.values(Builtin)) |b| { - const name = @tagName(b); - const arg: ?[]const u8 = for (walk_samples) |s| { - if (std.mem.eql(u8, s[0], name)) break s[1]; - } else null; - if (pardes.builtins.registry.requiresArg(b) and arg == null) { - std.debug.print("may_wait: `{s}` requires an argument: give it one in walk_samples\n", .{name}); - return error.NoSample; - } - const cmd = if (arg) |x| try std.fmt.bufPrint(&line, "{s} {s}", .{ name, x }) else name; - try w.try_(cmd, &.{.{ .command = cmd }}); - } + try w.words(); // Every key, plain, with Ctrl and with Alt, and after each prefix. var name_buf: [64]u8 = undefined; for (walk_keys) |k| try w.try_(keyName(&name_buf, k), &.{.{ .key = k }}); @@ -6524,6 +6531,19 @@ test "a far client's every word and key, on a file's pane, a kind's and a shell' unlisted += w.unlisted; tried += w.tried; } + // A terminal's build has the window's words too, which a window's view + // runs (a window client of its session; builtins.capabilities): its + // words walked again in one. + if (comptime pardes.builtins.desktop and pardes.platform != .gui) { + a.core.view().active = file; + _ = try a.local(.{ .frontend = .{ .windowed = true } }); + const r = try joinedFresh(a); + defer r.deinit(); + var w: Walk = .{ .r = r, .on = .file, .seen = &seen, .hit = &hit }; + try w.words(); + unlisted += w.unlisted; + tried += w.tried; + } // A row is stale where every kind of pane was walked: with no terminal // compiled in (core-test), a shell's rows stop nothing. var stale: u32 = 0; |
