diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/behaviour/keys.zig | 8 | ||||
| -rw-r--r-- | test/behaviour/modes.zig | 12 | ||||
| -rw-r--r-- | test/daemon.py | 2 | ||||
| -rw-r--r-- | test/panes.zig | 3 | ||||
| -rw-r--r-- | test/perf.zig | 186 | ||||
| -rw-r--r-- | test/process/tty_boot.zig | 51 | ||||
| -rw-r--r-- | test/process/tty_editing.zig | 5 | ||||
| -rw-r--r-- | test/process/tty_terminals.zig | 9 | ||||
| -rw-r--r-- | test/snapshots/builtins.golden | 95 | ||||
| -rw-r--r-- | test/snapshots/find.golden | 10 | ||||
| -rw-r--r-- | test/snapshots/leader.golden | 74 | ||||
| -rw-r--r-- | test/snapshots/ttyhelp.golden | 38 |
12 files changed, 368 insertions, 125 deletions
diff --git a/test/behaviour/keys.zig b/test/behaviour/keys.zig index 49c85512..8bf187f8 100644 --- a/test/behaviour/keys.zig +++ b/test/behaviour/keys.zig @@ -381,12 +381,12 @@ test "keys: a PDF in normal mode keeps : (its tag and back), SPC (a leader, canc try std.testing.expect(std.mem.endsWith(u8, try s.read(s.at("/pane/{d}/ctl", .{n})), " mode:normal ")); try s.keys(":"); try std.testing.expect(try s.cursor() == null); - // The leader shows its keys until one it has not (over the panes: the - // notice row under them names SPC h m). + // The leader shows its key cell in the tag at once (walk UI) until a + // key the PDF takes, which takes the leader away. try s.keys(" "); - try std.testing.expect(std.mem.indexOf(u8, try panesShown(&s), " SPC") != null); + try std.testing.expect(std.mem.indexOf(u8, try panesShown(&s), " ␣ ") != null); try s.keys("!"); - try std.testing.expect(std.mem.indexOf(u8, try panesShown(&s), " SPC") == null); + try std.testing.expect(std.mem.indexOf(u8, try panesShown(&s), " ␣ ") == null); try s.keys("/"); try std.testing.expect(try s.cursor() != null); try std.testing.expectEqual(n, try s.focused()); diff --git a/test/behaviour/modes.zig b/test/behaviour/modes.zig index e615920d..a50cfb0e 100644 --- a/test/behaviour/modes.zig +++ b/test/behaviour/modes.zig @@ -118,11 +118,13 @@ fn threePanes(s: *Session) ![3]u32 { return .{ a, b, c }; } -/// The panes whose tag (`name Save`) is drawn in `lit`, the outline's colour. +/// The panes whose tag (`name `: the pane with the keyboard shows window +/// mode's head after its name, the others their own words) is drawn in +/// `lit`, the outline's colour. fn outlined(s: *Session, lit: []const u8, names: []const []const u8) ![]const u8 { var found: []const u8 = ""; for (names) |name| { - const x, const y = try s.where(s.at("{s} Save", .{name})); + const x, const y = try s.where(s.at("{s} ", .{name})); if (std.mem.eql(u8, lit, try s.bg(x, y))) found = s.at("{s}{s}", .{ found, name }); } return found; @@ -134,7 +136,7 @@ test "modes: Ctrl-w outlines a pane, h j k l move the outline, and Enter, Esc, : const a, const b, const c = try threePanes(&s); const names = &[_][]const u8{ "/a.txt", "/b.txt", "/c.txt" }; try s.keys("\x17"); - const x, const y = try s.where("/a.txt Save"); + const x, const y = try s.where("/a.txt "); const lit = try s.bg(x, y); try std.testing.expectEqualStrings("/a.txt", try outlined(&s, lit, names)); // Each pane's box shows its letter: the left column's is a. @@ -198,7 +200,7 @@ test "modes: in window mode d deletes the outlined pane, asking k or j between t try std.testing.expectEqualStrings("/mid", try outlined(&s, lit, names)); try s.keys("c"); try std.testing.expect(std.mem.indexOf(u8, try s.read(s.at("/pane/{d}/ctl", .{mid})), " collapsed ") == null); - try expectEqual(row_low, (try s.where("/low Save"))[1]); + try expectEqual(row_low, (try s.where("/low "))[1]); // d between two panes asks, as SPC d does; Esc takes it back, the // outline where it was. try s.keys("d"); @@ -210,7 +212,7 @@ test "modes: in window mode d deletes the outlined pane, asking k or j between t try s.keys("dj"); try std.testing.expect(!try listed(&s, mid)); try expectEqual(row_top, (try s.where("/test.txt Save"))[1]); - try expectEqual(row_mid, (try s.where("/low Save"))[1]); + try expectEqual(row_mid, (try s.where("/low "))[1]); try std.testing.expectEqualStrings("/low", try outlined(&s, lit, &.{ "/test.txt", "/low" })); // With one neighbour nothing is asked: d closes it, the outline on the // pane that grew. diff --git a/test/daemon.py b/test/daemon.py index 97b0de76..f9cbc9e1 100644 --- a/test/daemon.py +++ b/test/daemon.py @@ -340,7 +340,7 @@ class Replica: """A replica's connection (abi/wire.zig): length-prefixed messages, a tag byte and a little-endian u32 length. It is a near client: its first word after the hello says so.""" - WIRE = 35 + WIRE = 36 def __init__(self, path, timeout=10): self.path, self.timeout = path, timeout diff --git a/test/panes.zig b/test/panes.zig index 60bff538..2d3c345f 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -2073,7 +2073,8 @@ const OutputTests = struct { try std.testing.expect(help.body.vsel.active); try std.testing.expect(help.body.vsel.row > 5); try std.testing.expect(help.body.cur_row != help.body.vsel.row); - for (" h?") |key| p.update(.{ .key = .{ .cp = key } }); + // `Help h`, the word (SPC h ? is Help in the tag now: walk UI). + try std.testing.expect(p.executeBuiltinLine(id, "Help h")); try std.testing.expectEqual(id, p.view().active); const content = help.file.?.content; try std.testing.expect(std.mem.startsWith(u8, content, "pardes builtins under SPC h\n")); diff --git a/test/perf.zig b/test/perf.zig index f36d64ac..17098f3d 100644 --- a/test/perf.zig +++ b/test/perf.zig @@ -70,6 +70,31 @@ const Op = enum { /// the window: a kind's frame costs its window's cells, never its /// picture (docs: architecture §16.1, its trigger 5% of a frame). image_frame, + /// The walk UI's tag states (TagState.zig), each key pumped and the + /// frame that draws it: SPC struck at rest, its level shown when its + /// delay is up, Esc back to rest (three frames, two keys). + spc, + /// A Down in SPC's unrolled level: its cursor a row on, the band drawn. + spc_down, + /// A character typed in Help's field and a Backspace: its rows + /// filtered again each time (two keys). + help_type, + /// describe-key's `g d` replayed: the level and the leaf's doc under the + /// tag (two keys). + describe, + /// `j` and `k` at rest in the same loop (two keys, two frames): what + /// the tag states' keys compare with (key-down's frames each draw + /// another place of the file). + rest_keys, + + /// Run only when named (`--op`): a full run, its cells and the sums a + /// gate takes over them (perfops' "terminal on all") are as before. + fn named(o: Op) bool { + return switch (o) { + .spc, .spc_down, .help_type, .describe, .rest_keys => true, + else => false, + }; + } fn label(o: Op) []const u8 { return switch (o) { @@ -88,6 +113,11 @@ const Op = enum { .body_appends => "body-appends", .deep_selection => "deep-sel", .image_frame => "image-frame", + .spc => "spc", + .spc_down => "spc-down", + .help_type => "help-type", + .describe => "describe", + .rest_keys => "rest-keys", }; } }; @@ -394,6 +424,8 @@ const Options = struct { mini: bool = false, /// The scans a frame's slice bounds, a call at a time (`measureSearch`). search: bool = false, + /// A picker's key and frame (`measurePick`). + pick: bool = false, terminal_mib: ?usize = null, /// The real binary's keystroke-to-present, `yes` stream and big open /// (a tty pardes), or its keystrokes alone (a pardes-gui). @@ -410,7 +442,7 @@ const Options = struct { while (i < args.len) : (i += 1) { const arg = args[i]; if (!std.mem.startsWith(u8, arg, "--")) return error.UnknownOption; - const option = std.meta.stringToEnum(enum { json, creation, startup, mini, search, @"terminal-mib", @"self-test", reps, cols, rows, base, only, op, @"max-ratio", live, @"live-gui" }, arg[2..]) orelse + const option = std.meta.stringToEnum(enum { json, creation, startup, mini, search, pick, @"terminal-mib", @"self-test", reps, cols, rows, base, only, op, @"max-ratio", live, @"live-gui" }, arg[2..]) orelse return error.UnknownOption; switch (option) { .json => opts.json = true, @@ -418,6 +450,7 @@ const Options = struct { .startup => opts.startup = true, .mini => opts.mini = true, .search => opts.search = true, + .pick => opts.pick = true, .@"self-test" => opts.self_test = true, else => { i += 1; @@ -480,6 +513,7 @@ pub fn main(init: std.process.Init) !void { if (opts.terminal_mib) |mib| return measureTerminalSession(init.io, mib, reps, opts.json); if (opts.mini) return measureMini(init.io, init.gpa, reps, opts.json); if (opts.search) return measureSearch(init.io); + if (opts.pick) return measurePick(init.io); if (opts.live) |exe| return measureLive(init.io, exe, false, reps, opts.json); if (opts.live_gui) |exe| return measureLive(init.io, exe, true, reps, opts.json); // The image-frame cells load the image addon by the path the build baked @@ -524,6 +558,7 @@ pub fn main(init: std.process.Init) !void { for (fixtures, 0..) |fx, fi| { if (only) |name| if (!std.mem.eql(u8, name, fx.name)) continue; if (opts.op) |o| if (o != op) continue; + if (op.named() and opts.op == null) continue; cells[oi][fi] = try measure(op, fx, paths[fi], bytes[fi], reps); } } @@ -538,7 +573,7 @@ pub fn main(init: std.process.Init) !void { } } - if (opts.json) try reportJson(init.io, &cells, &term_cells, &bytes, opts) else reportText(&cells, &term_cells, &bytes, reps, opts.base, base); + if (opts.json) try reportJson(init.io, &cells, &term_cells, &bytes, opts) else reportText(&cells, &term_cells, &bytes, reps, opts.op, opts.base, base); if (opts.max_ratio) |ratio| try gate(&cells, &base.?, ratio); } @@ -583,6 +618,7 @@ fn measure(op: Op, fx: Fixture, path: []const u8, expected_bytes: usize, reps: u switch (op) { .image_frame => return measureImage(std.fs.path.dirname(path).?, samples, warmup), .client_key_down, .client_edit_char, .client_delete_undo => return measureClient(op, path, reps), + .spc, .spc_down, .help_type, .describe, .rest_keys => return measureTag(op, path, reps), else => {}, } if (op == .open) { @@ -637,7 +673,7 @@ fn measure(op: Op, fx: Fixture, path: []const u8, expected_bytes: usize, reps: u const wheel_row = rect.y + pardes.BOX_H; const t0 = nowNs(); switch (op) { - .open, .image_frame, .client_key_down, .client_edit_char, .client_delete_undo => unreachable, + .open, .image_frame, .client_key_down, .client_edit_char, .client_delete_undo, .spc, .spc_down, .help_type, .describe, .rest_keys => unreachable, .render, .deep_selection => {}, .key_down => core.update(.{ .key = .{ .cp = 'j', .text = "j" } }), .key_right => core.update(.{ .key = .{ .cp = 'l', .text = "l" } }), @@ -651,7 +687,7 @@ fn measure(op: Op, fx: Fixture, path: []const u8, expected_bytes: usize, reps: u _ = try frame(core); const dt = nowNs() -| t0; switch (op) { - .open, .image_frame, .client_key_down, .client_edit_char, .client_delete_undo => unreachable, + .open, .image_frame, .client_key_down, .client_edit_char, .client_delete_undo, .spc, .spc_down, .help_type, .describe, .rest_keys => unreachable, .body_write => if (pane.file.?.content.len != before.len + 8 * body_chunk.len) return error.BodyWriteWasNotAppended, .body_appends => if (pane.file.?.content.len != before.len + append_count * append_chunk_len) return error.BodyAppendsWereNotAppended, .render, .deep_selection => if (pane.body.cur_row != before.row or pane.body.cur_col != before.col or pane.file.?.content.len != before.len) @@ -736,6 +772,68 @@ fn clientKey(a: *pardes.replica.Authority, r: *pardes.replica.Replica, ev: parde r.settle(); } +/// A tag state's keys on the fixture's pane, each pumped and its frame +/// drawn, from the state the op starts in (entered untimed); the state +/// checked after each repetition. +fn measureTag(op: Op, path: []const u8, reps: usize) !Cell { + const Key = pardes.Key; + const warmup = 3; + const samples = try gpa.alloc(u64, reps); + defer gpa.free(samples); + const core = try boot(); + defer core.deinit(); + pardes.look.lookAt(core, 0, path); + pump(core); + const id = filePane(core) orelse return error.OpenDidNotOpenFile; + core.view().active = id; + const enter: []const Key = switch (op) { + .spc, .rest_keys => &.{}, + .spc_down => &.{ .{ .cp = ' ', .text = " " }, .{ .cp = Key.down } }, + .help_type => &.{ .{ .cp = ' ', .text = " " }, .{ .cp = '?', .text = "?" } }, + .describe => &.{ .{ .cp = ' ', .text = " " }, .{ .cp = 'h', .text = "h" }, .{ .cp = 'k', .text = "k" } }, + else => unreachable, + }; + for (enter) |k| core.update(.{ .key = k }); + pump(core); + _ = try frame(core); + const keys: []const Key = switch (op) { + .spc => &.{ .{ .cp = ' ', .text = " " }, .{ .cp = Key.escape } }, + .spc_down => &.{.{ .cp = Key.down }}, + .help_type => &.{ .{ .cp = 'e', .text = "e" }, .{ .cp = Key.backspace } }, + .describe => &.{ .{ .cp = 'g', .text = "g" }, .{ .cp = 'd', .text = "d" } }, + .rest_keys => &.{ .{ .cp = 'j', .text = "j" }, .{ .cp = 'k', .text = "k" } }, + else => unreachable, + }; + const s = &core.view().tag_state; + for (0..warmup + samples.len) |n| { + const t0 = nowNs(); + for (keys) |k| { + core.update(.{ .key = k }); + pump(core); + _ = try frame(core); + // SPC's level when its delay is up: the frame that shows it. + if (op == .spc and k.cp == ' ') { + core.advance(core.clock.now_ns); + core.clock.now_ns = s.due_ns; + if (!pardes.TagState.shown(core, core.view())) return error.LevelNotShown; + _ = try frame(core); + } + } + const dt = nowNs() -| t0; + const held = switch (op) { + .spc => s.kind == .rest and s.root == null, + .spc_down => s.unrolled and core.panes[id].?.band_rows > 0, + .help_type => s.kind == .help and s.field.len == 0 and s.nhits > 0, + .describe => s.kind == .describe and s.found, + .rest_keys => s.kind == .rest and s.root == null and core.panes[id].?.body.cur_row == 0, + else => unreachable, + }; + if (!held) return error.TagStateLost; + if (n >= warmup) samples[n - warmup] = dt / 1000; + } + return summarize(samples); +} + fn measureImage(dir: []const u8, samples: []u64, warmup: usize) !Cell { const path = try std.fmt.allocPrint(gpa, "{s}/picture.ppm", .{dir}); defer gpa.free(path); @@ -1824,6 +1922,81 @@ fn measureSearch(io: std.Io) !void { } } +/// `--pick`: a picker's hot paths (core/Pick.zig, walk UI line D), each +/// a step and the frame that draws it, timed and its instructions counted +/// (user space, this thread): a key typed into a Find of 50,000 paths and +/// the frames after it while its names are scored; a cursor move over rows +/// that are files, and the frame after it that loads the preview into the +/// landing pane's body (a 2,000-line file read from the disk). +fn measurePick(io: std.Io) !void { + var random: [12]u8 = undefined; + io.random(&random); + const dir = try std.fmt.allocPrint(gpa, "/tmp/pardes-pick-{x}", .{random}); + defer gpa.free(dir); + try std.Io.Dir.createDirAbsolute(io, dir, .default_dir); + defer std.Io.Dir.cwd().deleteTree(io, dir) catch {}; + var counter: Instructions = try .open(); + defer counter.close(); + var body: std.ArrayList(u8) = .empty; + defer body.deinit(gpa); + for (0..2000) |i| try body.print(gpa, " const value_{d} = compute(value_{d}, \"a line of the preview\");\n", .{ i, i -| 1 }); + var name: [160]u8 = undefined; + for (0..20) |i| try writeFile(try std.fmt.bufPrint(&name, "{s}/pickme_{d}.zig", .{ dir, i }), body.items); + const start = try std.fmt.allocPrint(gpa, "{s}/start.zig", .{dir}); + defer gpa.free(start); + try writeFile(start, "const start = 1;\n"); + const core = try boot(); + defer core.deinit(); + core.settings.jumps = .walk; + pardes.look.lookAt(core, 0, start); + pump(core); + const id = filePane(core) orelse return error.OpenDidNotOpenFile; + pardes.Pick.open(core, id, .find, "", "", ""); + const pk = pardes.Pick.live(core) orelse return error.NoPicker; + // The listing as the disk engine would give it: 50,000 paths, the + // real files among them. + _ = core.stream.stop(); + pk.names.reset(); + const dirs = [_][]const u8{ "core", "dev/gui", "dev/tui", "runtime", "test/behaviour", "addons/pdf", "zig-pkg/ghostty/src/terminal" }; + const words = [_][]const u8{ "layout", "places", "names", "query", "stream", "surface", "replica", "tape", "kitty", "render" }; + for (0..50_000) |i| { + const path = if (i % 2500 == 0) try std.fmt.bufPrint(&name, "pickme_{d}.zig", .{i / 2500}) else try std.fmt.bufPrint(&name, "{s}/module_{d}/{s}_{d}.zig", .{ dirs[i % dirs.len], i / 64 % 997, words[i * 7 % words.len], i }); + try pk.names.add(gpa, path, 0, path.len, @TypeOf(pk.names).baseOf(path), 0); + } + pk.names.typed(gpa, ""); + while (pk.names.busy()) pk.names.rescore(gpa); + try frame(core); + const Step = struct { + fn run(c: *pardes.Pardes, ev: pardes.Event, n: *Instructions, s: *Slowest, hits: usize) !void { + const was = n.read(); + const t0 = nowNs(); + c.update(ev); + try frame(c); + s.add(nowNs() -| t0, n.read() -| was, hits); + } + }; + var keys: Slowest = .{}; + var after: Slowest = .{}; + for ("pickme") |ch| { + try Step.run(core, .{ .key = .{ .cp = ch, .text = &[_]u8{ch} } }, &counter, &keys, pk.names.hits.items.len); + while (pk.names.busy()) try Step.run(core, .tick, &counter, &after, pk.names.hits.items.len); + } + keys.report("pick key + frame", "pickme", pk.names.hits.items.len); + after.report("pick tick + frame while scoring", "pickme", pk.names.hits.items.len); + // The first preview, then the cursor moved and the preview after it. + try Step.run(core, .tick, &counter, &after, 0); + var moves: Slowest = .{}; + var previews: Slowest = .{}; + for (0..19) |_| { + try Step.run(core, .{ .key = .{ .cp = pardes.Key.down } }, &counter, &moves, 0); + try Step.run(core, .tick, &counter, &previews, 0); + } + moves.report("pick Down + frame", "pickme", pk.names.hits.items.len); + previews.report("pick preview tick + frame", "pickme", pk.names.hits.items.len); + const landing = core.panes[core.paneBySerial(pk.landing) orelse return error.NoLanding].?; + if (!std.mem.endsWith(u8, landing.file.?.path, ".zig") or std.mem.indexOf(u8, landing.file.?.path, "pickme_") == null) return error.NoPreview; +} + /// The longest of a scan's calls. const Slowest = struct { calls: usize = 0, @@ -1988,6 +2161,7 @@ fn reportText( term_cells: *const [std.enums.values(TermOp).len][term_fixtures.len]Cell, bytes: *const [fixtures.len]usize, reps: usize, + named: ?Op, base_path: ?[]const u8, base: ?Base, ) void { @@ -2011,6 +2185,7 @@ fn reportText( o("\n{s}\n", .{if (base != null) &@as([12 + fixtures.len * 20]u8, @splat('-')) else &@as([12 + fixtures.len * 13]u8, @splat('-'))}); var worst_jitter: f64 = 0; for (std.enums.values(Op), 0..) |op, oi| { + if (op.named() and named != op) continue; o("{s:<12}", .{op.label()}); for (0..fixtures.len) |fi| { const c = cells[oi][fi]; @@ -2100,6 +2275,7 @@ fn writeJson( for (fixtures, 0..) |fx, fi| { if (opts.only) |name| if (!std.mem.eql(u8, name, fx.name)) continue; if (opts.op) |o| if (o != op) continue; + if (op.named() and opts.op == null) continue; const c = cells[oi][fi]; try out.print("{s}{{\"op\":\"{s}\",\"fixture\":\"{s}\",\"min_us\":{d},\"med_us\":{d},\"p90_us\":{d},\"max_us\":{d}}}", .{ if (first) "" else ",", op.label(), fx.name, c.min_us, c.med_us, c.p90_us, c.max_us, @@ -2204,7 +2380,7 @@ fn parseBase(src: []const u8, opts: Options, bytes: *const [fixtures.len]usize) } for (fixtures, 0..) |fixture, fi| { if (opts.only) |name| if (!std.mem.eql(u8, name, fixture.name)) continue; - for (file_seen) |row| if (!row[fi]) return error.BaselineCoverage; + for (file_seen, std.enums.values(Op)) |row, op| if (!row[fi] and !op.named()) return error.BaselineCoverage; } if (opts.only == null) for (term_seen) |row| { for (row) |seen| if (!seen) return error.BaselineCoverage; diff --git a/test/process/tty_boot.zig b/test/process/tty_boot.zig index 01b35a24..e342ea46 100644 --- a/test/process/tty_boot.zig +++ b/test/process/tty_boot.zig @@ -114,14 +114,17 @@ fn boot(gpa: std.mem.Allocator, exe: [:0]const u8) !void { fn builtins(gpa: std.mem.Allocator, exe: [:0]const u8) !void { var t = try Tty.init(gpa, exe, "builtins"); defer t.deinit(); - try t.lines("notes.txt", 6, ""); + // SPC ? is Help in the tag now (pick-ui SPEC §4.5): the +Help index is + // the word's, `Help` run from the workspace's tag, `Help c` swept here. + try t.file("notes.txt", "Help c Help h\nline 2\nline 3\nline 4\nline 5\nline 6\n"); try t.start(67, 120, &.{"notes.txt"}); try t.wait(8000, "notes.txt"); try t.stable(700, 20000); try t.snap("boot"); // The full index includes commands without leader paths. - try t.key("space ?"); + try t.press("middle", "@Help", 1); + try t.release("middle", "@Help", 1); try t.wait(10000, "pardes builtins: each one's keys and its name"); try t.wait(10000, "ClipPasteBefore"); // The words with no SPC path come last, each under its documentation: @@ -141,19 +144,20 @@ fn builtins(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.key("space j n space j n space j n"); try t.wait(10000, "Look enter, right-click"); try t.wait(10000, "Look at its argument as B3 does"); - try t.key("space c ?"); + try sweepHelp(&t, "@Help#1", 4); try t.wait(10000, "under SPC c"); try t.wait(10000, "Joincol"); try t.stable(700, 15000); try t.snap("column-group"); - try t.key("space h ?"); + try sweepHelp(&t, "@Help#2", 4); try t.wait(10000, "Tutor"); try t.stable(700, 15000); try t.snap("docs-group"); - // Tutor's row, under the documentation of the three before it - try t.press("middle", "@Tutor", 24); - try t.release("middle", "@Tutor", 24); + // Tutor's row, under the documentation of the four before it (Keys, + // describe-key, is SPC h k) + try t.press("middle", "@Tutor", 30); + try t.release("middle", "@Tutor", 30); try t.wait(10000, "PARDES TUTOR"); try t.stable(700, 15000); try t.snap("tutor-from-index"); @@ -472,13 +476,18 @@ fn topbarexec(gpa: std.mem.Allocator, exe: [:0]const u8) !void { fn leader(gpa: std.mem.Allocator, exe: [:0]const u8) !void { var t = try Tty.init(gpa, exe, "leader"); defer t.deinit(); - try t.file("cmds.txt", "Help"); + // SPC ? and `?` down a level are Help in the tag now (pick-ui SPEC + // §4.5): the +Help index for a group is the word's, `Help h` swept here. + try t.file("cmds.txt", "Help Help h Help t Help c Help l"); try t.start(41, 100, &.{"cmds.txt"}); try t.wait(8000, "Newcol Joincol"); try t.wait(8000, "cmds.txt"); try t.stable(700, 20000); + // SPC's level, rolled in the tag once its delay is up (a frame on the + // clock, which a quiet screen does not wait for) try t.key("space"); + try t.wait(5000, "↓ unroll"); try t.stable(400, 5000); try t.snap("spc"); try t.key("h"); @@ -489,15 +498,21 @@ fn leader(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.stable(400, 5000); try t.snap("abandoned"); try t.key("space x"); + try t.wait(5000, "↓ unroll"); try t.stable(400, 5000); try t.snap("unmapped"); + // A key the level has no child for is struck and the level stays + // (which-key); Esc leaves it. + try t.key("esc"); + try t.settle(100); + try t.stable(400, 5000); // Executing Help as text opens the full index, not a filtered group. try t.press("middle", "@Help", 4); try t.release("middle", "@Help", 4); try t.wait(10000, "pardes builtins: each one's keys and its name"); try t.wait(10000, "ClipPasteBefore"); - try t.key("space h ?"); + try sweepHelp(&t, "@Help#2", 4); try t.wait(10000, "under SPC h"); try t.stable(700, 15000); try t.snap("help-group"); @@ -517,23 +532,24 @@ fn leader(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.key("space d"); try t.stable(700, 15000); - try t.key("space ?"); + try t.press("middle", "@Help", 4); + try t.release("middle", "@Help", 4); try t.wait(10000, "pardes builtins: each one's keys and its name"); try t.wait(10000, "ClipPasteBefore"); // PDF commands depend on the build; these toggles do not. - try t.key("space t ?"); + try sweepHelp(&t, "@Help#3", 4); try t.wait(10000, "under SPC t"); // its first rows: each word's documentation under it, the rest below try t.wait(10000, "SPC t a Ascii"); try t.wait(10000, "SPC t c Changes"); // SPC w is Window itself now, not a group; the column group stands in - try t.key("space c ?"); + try sweepHelp(&t, "@Help#4", 4); try t.wait(10000, "under SPC c"); try t.wait(10000, "Joincol"); try t.stable(700, 15000); try t.snap("help-column"); - try t.key("space l ?"); + try sweepHelp(&t, "@Help#5", 4); try t.wait(10000, "WsDiagnostics"); try t.stable(700, 15000); try t.snap("help-language"); @@ -544,6 +560,15 @@ fn leader(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.done(); } +/// B2 swept over `Help <key>` from the word `at` on `row` (its six +/// cells): the word and its argument run, as a sweep anywhere runs them. +fn sweepHelp(t: *Tty, at: []const u8, row: u16) !void { + const end = try std.fmt.allocPrint(t.arena, "{s}+6", .{at}); + try t.press("middle", at, row); + try t.drag("middle", end, row); + try t.release("middle", end, row); +} + fn mini(gpa: std.mem.Allocator, exe: [:0]const u8) !void { var t = try Tty.init(gpa, exe, "mini"); defer t.deinit(); diff --git a/test/process/tty_editing.zig b/test/process/tty_editing.zig index efb5dc9b..896a3634 100644 --- a/test/process/tty_editing.zig +++ b/test/process/tty_editing.zig @@ -609,9 +609,12 @@ fn find(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.start(41, 120, &.{"here.txt"}); try t.wait(8000, "here.txt"); try t.stable(700, 20000); - // SPC f is a group (Find, New, Save, Recent, Grep): the indicator waits + // SPC f is a group (Find, New, Save, Recent, Grep): its level rolled in + // the tag once SPC's delay is up (a frame on the clock, which a quiet + // screen does not wait for) try t.key("space"); try t.key("f"); + try t.wait(5000, "↓ unroll"); try t.stable(400, 5000); try t.snap("group"); // the second f opens the query pane: every file listed, line 1 `Find ` diff --git a/test/process/tty_terminals.zig b/test/process/tty_terminals.zig index 550d5922..838b2aea 100644 --- a/test/process/tty_terminals.zig +++ b/test/process/tty_terminals.zig @@ -226,12 +226,13 @@ fn ttyhelp(gpa: std.mem.Allocator, exe: [:0]const u8) !void { // row 0, which is not a pane, so the terminal never saw it. try t.key("c-b"); try t.stable(600, 10000); + // SPC ? is Help in the focused pane's tag (pick-ui SPEC §4.5): a field + // typed in, the leaves it matches in rows under the tag, the cursor's + // documentation beside them. try t.key("space"); try t.key("?"); - // The bare-tty boot now opens an empty pane under the shell, so the index is - // half as tall: wait on a row that is on screen. What the leader route - // produced is the snapshot below, not this. - try t.wait(10000, "SPC ? Help"); + try t.send("tutor"); + try t.wait(10000, "SPC h t · Tutor · help"); try t.stable(700, 15000); try t.snap("leaderworks"); try t.done(); diff --git a/test/snapshots/builtins.golden b/test/snapshots/builtins.golden index 86d26b29..81a445e1 100644 --- a/test/snapshots/builtins.golden +++ b/test/snapshots/builtins.golden @@ -2,7 +2,7 @@ | Newcol Joincol Find Grep Help Changelog Tutor Dump Themes Config History Debug Exit | New Term Find Grep Joincol Delcol | /tmp/pardes-snap/builtins/cwd/notes.txt Save Term Collapse Follow Del -| 1 line 1 +| 1 Help c Help h | 2 line 2 | 3 line 3 | 4 line 4 @@ -91,8 +91,8 @@ |30: ~ |56: +Search 1/1 Save Undock Del |57: /^ +Look -|58: @p2:224:1 Look enter, right-click -|66: /tmp/pardes-snap/builtins/cwd/+Help:1 +|58: @p2:236:1 Look enter, right-click +|66: ✓ /tmp/pardes-snap/builtins/cwd/notes.txt Help 3 messages · SPC h m == snap docs-group grid=120x67 cursor=7,10 |10: 1 pardes builtins under SPC h |12: 3 SPC h b Build @@ -102,49 +102,46 @@ |17: 7 SPC h c Changelog topbar |18: 8 Show this build's version and what changed to reach it, in a +Changelog. |19: 9 -|20: 10 SPC h m Messages -|21: 11 Show the messages said so far in a +Messages, the newest first, an error's places under it. -|22: 12 -|23: 13 SPC h t Tutor topbar -|24: 14 Open the tutor, a document to work through. -|25: 15 -|26: ~ -|27: -|28: -|29: -|30: -== snap tutor-from-index grid=120x67 cursor=7,37 -|26: +Search 1/1 Save Undock Del -|27: /^ +Look -|28: @p2:224:1 Look enter, right-click -|36: /tmp/pardes-snap/builtins/cwd/+Tutor Save Term Collapse Follow Del -|37: 1 -|38: 2 PARDES TUTOR -|39: 3 -|40: 4 This pane is +Tutor, a copy: edit it freely; there is no need to -|41: 5 Save it (a bare Save asks for a path to write a copy to). -|42: 6 `Del` in its tag closes it; once you have edited it, `Del` refuses -|43: 7 once and the second `Del` discards. `Tutor` or SPC h t opens a -|44: 8 fresh copy. -|45: 9 -|46: 10 The guide (docs/typ/guide.typ) explains; this is the hands-on part. -|47: 11 Each lesson is a few things to do, then names its guide section. -|48: 12 Words in backticks, like `Save`, are builtins. -|49: 13 `Exec` (B2) runs the builtin a word names, or else runs it as a -|50: 14 shell line; `Look` (B3) opens what the text names, or else finds -|51: 15 it. Type a builtin in any tag and `Exec` it. Lines starting with -|52: 16 "| " are tags. -|53: 17 -|54: 18 Press j until you reach part 1. -|55: 19 -|56: 20 -|57: 21 ================================================================= -|58: 22 = PART 1 — MODES = -|59: 23 ================================================================= -|60: 24 -|61: 25 1. The box left of this pane's tag is blank, so you are in -|62: 26 NORMAL mode. Press i: it shows ^ (INSERT). Type a word, then -|63: 27 Esc: blank again. -|64: 28 2. Press Esc once more, in NORMAL: the keyboard goes back to the -|65: 29 pane you were in before (not what helix does). Come back with -|66: ✓ /tmp/pardes-snap/builtins/cwd/+Help Tutor 2 messages · SPC h m +|20: 10 SPC h k Keys +|21: 11 Show what a key sequence runs: the next keys typed are replayed in the tag. +|22: 12 The tag shows `Keys` and the keys as they are typed; a sequence that reaches a leaf unrolls its level under the ↩ +|23: tag with the leaf on the cursor and its documentation beside it, and Enter runs it. Every root answers: SPC, g, ↩ +|24: m, z, Z, [, ], window mode's C-w. A sequence nothing is bound to is shown struck, `runs nothing`. Esc leaves it. +|25: 13 +|26: 14 SPC h m Messages +|27: 15 Show the messages said so far in a +Messages, the newest first, an error's places under it. +|28: 16 +|29: 17 SPC h t Tutor topbar +|30: 18 Open the tutor, a document to work through. +|31: 19 +|32: ~ +|66: ✓ /tmp/pardes-snap/builtins/cwd/notes.txt Help 5 messages · SPC h m +== snap tutor-from-index grid=120x67 cursor=7,43 +|32: +Search 1/1 Save Undock Del +|33: /^ +Look +|34: @p2:236:1 Look enter, right-click +|42: /tmp/pardes-snap/builtins/cwd/+Tutor Save Term Collapse Follow Del +|43: 1 +|44: 2 PARDES TUTOR +|45: 3 +|46: 4 This pane is +Tutor, a copy: edit it freely; there is no need to +|47: 5 Save it (a bare Save asks for a path to write a copy to). +|48: 6 `Del` in its tag closes it; once you have edited it, `Del` refuses +|49: 7 once and the second `Del` discards. `Tutor` or SPC h t opens a +|50: 8 fresh copy. +|51: 9 +|52: 10 The guide (docs/typ/guide.typ) explains; this is the hands-on part. +|53: 11 Each lesson is a few things to do, then names its guide section. +|54: 12 Words in backticks, like `Save`, are builtins. +|55: 13 `Exec` (B2) runs the builtin a word names, or else runs it as a +|56: 14 shell line; `Look` (B3) opens what the text names, or else finds +|57: 15 it. Type a builtin in any tag and `Exec` it. Lines starting with +|58: 16 "| " are tags. +|59: 17 +|60: 18 Press j until you reach part 1. +|61: 19 +|62: 20 +|63: 21 ================================================================= +|64: 22 = PART 1 — MODES = +|65: 23 ================================================================= +|66: ✓ /tmp/pardes-snap/builtins/cwd/+Help Tutor 7 messages · SPC h m diff --git a/test/snapshots/find.golden b/test/snapshots/find.golden index 176a8d42..cad1b229 100644 --- a/test/snapshots/find.golden +++ b/test/snapshots/find.golden @@ -1,9 +1,9 @@ -== snap group grid=120x41 cursor=7,3 +== snap group grid=120x41 cursor=7,4 | Newcol Joincol Find Grep Help Changelog Tutor Dump Themes Config History Debug Exit | New Term Find Grep Joincol Delcol -| /tmp/pardes-snap/find/cwd/here.txt Save Term Collapse Follow Del -| 1 Find zqm SPC f -| +| /tmp/pardes-snap/find/cwd/here.txt ␣ f ▸ c Config f Find g Grep h History n New r Recent s Save ↓ unroll · ? h +| elp +| 1 Find zqm | | | @@ -41,7 +41,9 @@ | | /tmp/pardes-snap/find/cwd/here.txt:1 == snap armed grid=120x41 cursor=7,22 +|2: /tmp/pardes-snap/find/cwd/here.txt Save Term Collapse Follow Del |3: 1 Find zqm +|4: |21: ^ +Search 1/5 Del |22: Find |23: here.txt diff --git a/test/snapshots/leader.golden b/test/snapshots/leader.golden index 8c45af73..2714ad2c 100644 --- a/test/snapshots/leader.golden +++ b/test/snapshots/leader.golden @@ -1,10 +1,10 @@ -== snap spc grid=100x41 cursor=7,3 +== snap spc grid=100x41 cursor=7,5 | Newcol Joincol Find Grep Help Changelog Tutor Dump Themes Config History Debug Exit | New Term Find Grep Joincol Delcol -| /tmp/pardes-snap/leader/cwd/cmds.txt Save Term Collapse Follow Del -| 1 Help SPC -| -| +| /tmp/pardes-snap/leader/cwd/cmds.txt ␣ ▸ b buffer… c column… f file… h help… j jump… l lsp… +| n new… s session… t view… ' Resume / All ? Help d Del e Message p ClipPaste P ClipPasteBe +| fore q Exit R ClipReplace w Window y ClipYank Y ClipYankMain ↓ unroll · ? help +| 1 Help Help h Help t Help c Help l | | | @@ -40,12 +40,24 @@ | | | /tmp/pardes-snap/leader/cwd/cmds.txt:1 -== snap spc-h grid=100x41 cursor=7,3 -|3: 1 Help SPC h +== snap spc-h grid=100x41 cursor=7,4 +|2: /tmp/pardes-snap/leader/cwd/cmds.txt ␣ h ▸ b Build c Changelog k Keys m Messages t Tutor ↓ u +|3: nroll · ? help +|4: 1 Help Help h Help t Help c Help l +|5: == snap abandoned grid=100x41 cursor=7,3 -|3: 1 Help -== snap unmapped grid=100x41 cursor=7,3 +|2: /tmp/pardes-snap/leader/cwd/cmds.txt Save Term Collapse Follow Del +|3: 1 Help Help h Help t Help c Help l +|4: +== snap unmapped grid=100x41 cursor=7,5 +|2: /tmp/pardes-snap/leader/cwd/cmds.txt ␣ ▸ b buffer… c column… f file… h help… j jump… l lsp… +|3: n new… s session… t view… ' Resume / All ? Help d Del e Message p ClipPaste P ClipPasteBe +|4: fore q Exit R ClipReplace w Window y ClipYank Y ClipYankMain x ↓ unroll · ? help +|5: 1 Help Help h Help t Help c Help l == snap help-group grid=100x41 cursor=7,6 +|2: /tmp/pardes-snap/leader/cwd/cmds.txt Save Term Collapse Follow Del +|3: 1 Help Help h Help t Help c Help l +|4: |5: /tmp/pardes-snap/leader/cwd/+Help Save Term Collapse Follow Del |6: 1 pardes builtins under SPC h |7: 2 @@ -57,14 +69,21 @@ |13: 7 SPC h c Changelog topbar |14: 8 Show this build's version and what changed to reach it, in a +Changelog. |15: 9 -|16: 10 SPC h m Messages -|17: 11 Show the messages said so far in a +Messages, the newest first, an error's places under it. -|18: 12 -|19: 13 SPC h t Tutor topbar -|20: 14 Open the tutor, a document to work through. -|21: 15 -|22: ~ -|40: ✓ /tmp/pardes-snap/leader/cwd/cmds.txt Help 2 messages · SPC h m +|16: 10 SPC h k Keys +|17: 11 Show what a key sequence runs: the next keys typed are replayed in the tag. +|18: 12 The tag shows `Keys` and the keys as they are typed; a sequence that reaches a leaf unrolls ↩ +|19: its level under the tag with the leaf on the cursor and its documentation beside it, and Ent↩ +|20: er runs it. Every root answers: SPC, g, m, z, Z, [, ], window mode's C-w. A sequence nothing↩ +|21: is bound to is shown struck, `runs nothing`. Esc leaves it. +|22: 13 +|23: 14 SPC h m Messages +|24: 15 Show the messages said so far in a +Messages, the newest first, an error's places under it. +|25: 16 +|26: 17 SPC h t Tutor topbar +|27: 18 Open the tutor, a document to work through. +|28: 19 +|29: ~ +|40: ✓ /tmp/pardes-snap/leader/cwd/cmds.txt Help 4 messages · SPC h m == snap tutor grid=100x41 cursor=7,23 |22: /tmp/pardes-snap/leader/cwd/+Tutor Save Term Collapse Follow Del |23: 1 @@ -84,7 +103,7 @@ |37: 15 it. Type a builtin in any tag and `Exec` it. Lines starting with |38: 16 "| " are tags. |39: 17 -|40: ✓ /tmp/pardes-snap/leader/cwd/+Help Tutor 3 messages · SPC h m +|40: ✓ /tmp/pardes-snap/leader/cwd/+Help Tutor 5 messages · SPC h m == snap deleted grid=100x41 cursor=7,3 |5: |6: @@ -115,13 +134,13 @@ |31: 7 SPC h c Changelog topbar |32: 8 Show this build's version and what changed to reach it, in a +Changelog. |33: 9 -|34: 10 SPC h m Messages -|35: 11 Show the messages said so far in a +Messages, the newest first, an error's places under it. -|36: 12 -|37: 13 SPC h t Tutor topbar -|38: 14 Open the tutor, a document to work through. -|39: 15 -|40: ✓ /tmp/pardes-snap/leader/cwd/+Tutor Del 4 messages · SPC h m +|34: 10 SPC h k Keys +|35: 11 Show what a key sequence runs: the next keys typed are replayed in the tag. +|36: 12 The tag shows `Keys` and the keys as they are typed; a sequence that reaches a leaf unrolls ↩ +|37: its level under the tag with the leaf on the cursor and its documentation beside it, and Ent↩ +|38: er runs it. Every root answers: SPC, g, m, z, Z, [, ], window mode's C-w. A sequence nothing↩ +|39: is bound to is shown struck, `runs nothing`. Esc leaves it. +|40: ✓ /tmp/pardes-snap/leader/cwd/+Tutor Del 6 messages · SPC h m == snap help-column grid=100x41 cursor=7,6 |5: /tmp/pardes-snap/leader/cwd/+Help Save Term Collapse Follow Del |6: 1 pardes builtins under SPC c @@ -158,7 +177,7 @@ |37: |38: |39: -|40: ✓ /tmp/pardes-snap/leader/cwd/+Help Del 6 messages · SPC h m +|40: ✓ /tmp/pardes-snap/leader/cwd/cmds.txt Help 14 messages · SPC h m == snap help-language grid=100x41 cursor=7,6 |6: 1 pardes builtins under SPC l |8: 3 SPC l C Callees @@ -193,6 +212,7 @@ |37: 29 SPC l h SelectRefs |38: 30 Select every reference to the symbol under the cursor. |39: 31 +|40: ✓ /tmp/pardes-snap/leader/cwd/cmds.txt Help 16 messages · SPC h m == snap del-output grid=100x41 cursor=7,3 |5: |6: @@ -229,4 +249,4 @@ |37: |38: |39: -|40: ✓ /tmp/pardes-snap/leader/cwd/+Help Del 7 messages · SPC h m +|40: ✓ /tmp/pardes-snap/leader/cwd/+Help Del 17 messages · SPC h m diff --git a/test/snapshots/ttyhelp.golden b/test/snapshots/ttyhelp.golden index 7f7413ec..200aab50 100644 --- a/test/snapshots/ttyhelp.golden +++ b/test/snapshots/ttyhelp.golden @@ -37,15 +37,31 @@ |8: from a shell. `Help <name>` shows one builtin alone; `Help <keys>` (or SPC, those keys, the↩ |9: n ?) the builtins under SPC and those keys. |10: 2 -|11: 3 SPC ? Help topbar -|12: 4 Show every builtin with its keys and documentation, or one builtin's alone. -|13: 5 `Help <name>`: that builtin alone, its keys spelled out, what it acts on and its line for a ↩ -|14: shell (`Help Diff`); a setting or an addon's word the same. `Help <keys>`: the builtins unde↩ -|15: r SPC and those keys (`Help l`, as `SPC l ?` shows them). Each fills the one +Help: a second↩ -|16: Help replaces its text. -|17: 6 -|18: 7 SPC P ClipPasteBefore -|19: 8 Paste the system clipboard before the selection. -|20: 9 +|11: 3 SPC ' Resume +|12: 4 Reopen the last picker as it was: its rows, marks, cursor and query. +|13: 5 In the tag of the pane its Enter lands in from this one: this pane if it reads, else its rea↩ +|14: der. `SPC '`. +|15: 6 +|16: 7 SPC ? Help topbar +|17: 8 Show every builtin with its keys and documentation, or one builtin's alone. +|18: 9 `Help <name>`: that builtin alone, its keys spelled out, what it acts on and its line for a ↩ +|19: shell (`Help Diff`); a setting or an addon's word the same. `Help <keys>`: the builtins unde↩ +|20: r SPC and those keys (`Help l`, as `SPC l ?` shows them). Each fills the one +Help: a second |30: ✓ @p1 Help 1 message · SPC h m -== snap leaderworks grid=100x31 cursor=7,6 +== snap leaderworks grid=100x31 cursor=47,5 +|5: ^ /tmp/pardes-snap/ttyhelp/cwd/+Help Help tutor 1/136 +|6: ▶ SPC h t · Tutor · help│ t Tutor +|7: │ Open the tutor, a document to work through. +|8: │ keys SPC h t +|9: │ +|10: 1 pardes builtins: each one's keys and its name, then what it does. Run one by its keys, or by↩ +|11: its name anywhere: B2 on the word, Exec <name>, a line of a ctl file, or `pardes do <name>`↩ +|12: from a shell. `Help <name>` shows one builtin alone; `Help <keys>` (or SPC, those keys, the↩ +|13: n ?) the builtins under SPC and those keys. +|14: 2 +|15: 3 SPC ' Resume +|16: 4 Reopen the last picker as it was: its rows, marks, cursor and query. +|17: 5 In the tag of the pane its Enter lands in from this one: this pane if it reads, else its rea↩ +|18: der. `SPC '`. +|19: 6 +|20: 7 SPC ? Help topbar |
