diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-23 15:47:11 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-23 15:55:44 -0300 |
| commit | 544d7265a8527be11ad9e8f944fa3723ae113a31 (patch) | |
| tree | bf014e290626ad88e546b06079b94dc53326d938 /test | |
| parent | 33b1f209162f94a9200f8c00d131aae772eb02f2 (diff) | |
| download | pardes-544d7265a8527be11ad9e8f944fa3723ae113a31.tar.gz pardes-544d7265a8527be11ad9e8f944fa3723ae113a31.zip | |
help: bare `Help` lists every builtin of this view as before, a row each (its keys, its name, its other shortcuts), now with its whole documentation under it, a line a paragraph, and a blank line after; `Help <name>` shows that one alone, and `Help <keys>` the builtins under SPC and those keys (the user's words of 2026-11-23: "the Help command wiht no arguments should list all builtins like now but with their larger-ish documentation, and the Help builtin with arguments should show the documentation specific for that builtin only"): Help took no argument, so `Help l` ran as a shell command and only `SPC l ?` opened a group; now `Help` takes one (core/builtins.zig `Help`): a builtin's name as the registry takes it, or an addon's word, opens its row, its documentation and what the list does not say, a line each (core/Output.zig `writeWordHelp`: its keys spelled out, its argument, a setting's values (`Settings.takes`), what it acts on and so which ctl takes it, a window's word in a terminal, and `pardes do <Word> [ARG]`); SPC keys open that group (`openHelp`, as `SPC <keys> ?` does); a word that is neither fails, `Help: <word>: no such builtin, nor SPC keys`, the +Help left as it was; every Help fills the one +Help (openRead, as before: a second replaces its text); the header is one paragraph, wrapped by the pane, not three lines broken for a 40-column pane; an addon's word's row puts its name in the builtins' name column, `(addon <kind>)` after it and its doc under it; the paragraph "Callstack: static caller chains, ..." is gone, Callstack's and Callers' documentation say it; tests: test/behaviour/builtins.zig "builtins: Help holds every builtin with its whole documentation, `Help <name>` that one's alone, and B2 on a builtin's name in it runs it" (through 9P alone: for every word of /commands, `Help <word>`'s documentation is in bare Help's text whole under its row, begins with its /commands summary and holds no other word's; `Help diff` refused; `Help c` the column group; B2 on `Newcol` in `Help Newcol`'s row adds a column), core/Output.zig's full-Help test (rows, each one's paragraphs, the language keys), test/behaviour/addons.zig's addon row, test/panes.zig's Tutor click finds its row by the pane's wrap map (the documentation above it wraps), test/process/tty_boot.zig's waits for the new header; docs/typ/builtins-tui.json regenerated (Help takes an argument); core-test (Help) 12/12, behaviour-test (Help) 4/4, pane-test (Help) 4/4, Debug tui; the whole suites run on item 4's change, and the process-test goldens the Help pane shows change in the last change (the full index's scroll is set once the documentation is written)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test')
| -rw-r--r-- | test/behaviour/addons.zig | 2 | ||||
| -rw-r--r-- | test/behaviour/builtins.zig | 44 | ||||
| -rw-r--r-- | test/panes.zig | 6 | ||||
| -rw-r--r-- | test/process/tty_boot.zig | 6 |
4 files changed, 53 insertions, 5 deletions
diff --git a/test/behaviour/addons.zig b/test/behaviour/addons.zig index e36b088c..abadd781 100644 --- a/test/behaviour/addons.zig +++ b/test/behaviour/addons.zig @@ -334,7 +334,7 @@ test "addons: a Look at a file whose extension an addon claims opens a pane of i try s.write(s.at("/pane/{d}/ctl", .{pane}), "Del\n"); try s.write("/ctl", "Help\n"); const help = try s.read(s.at("/pane/{d}/body", .{try s.focused()})); - try std.testing.expect(has(help, "SPC z f Fake a fake pane, counting (addon fake)\n")); + try std.testing.expect(has(help, "SPC z f Fake (addon fake)\na fake pane, counting\n\n")); } test "addons: an image pane whose file changes on disk shows the new picture, under a new key: a window keeps a texture by its key" { diff --git a/test/behaviour/builtins.zig b/test/behaviour/builtins.zig index 86ee6ca9..50e6e688 100644 --- a/test/behaviour/builtins.zig +++ b/test/behaviour/builtins.zig @@ -35,6 +35,50 @@ test "builtins: Mini maps a file of the pane's directory over pardes's own sourc try std.testing.expectEqual(@as(usize, 0), s.saved); } +test "builtins: Help holds every builtin with its whole documentation, `Help <name>` that one's alone, and B2 on a builtin's name in it runs it" { + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + try s.write(s.at("/pane/{d}/exec", .{try s.focused()}), "Help\n"); + const help = try s.focused(); + const body = s.at("/pane/{d}/body", .{help}); + const all = try s.read(body); + const commands = try s.read("/commands"); + var words = std.mem.tokenizeScalar(u8, commands, '\n'); + while (words.next()) |line| { + const name = line[0..std.mem.indexOfScalar(u8, line, ' ').?]; + // One alone: its row, a blank, its documentation, a blank, then what + // the list does not say; the one +Help, filled again. + try s.write(s.at("/pane/{d}/exec", .{help}), s.at("Help {s}\n", .{name})); + try std.testing.expectEqual(help, try s.focused()); + const one = try s.read(body); + const doc_end = std.mem.indexOf(u8, one, "\n\nkeys: ").?; + const row = one[0..std.mem.indexOfScalar(u8, one, '\n').?]; + const documented = one[0..doc_end]; + // The list holds it whole: its row, its documentation under it. + try std.testing.expect(std.mem.indexOf(u8, all, s.at("{s}\n{s}\n\n", .{ row, documented[row.len + 2 ..] })) != null); + // Its documentation begins with its summary, /commands' line. + try std.testing.expect(std.mem.startsWith(u8, documented[row.len + 2 ..], line[std.mem.indexOf(u8, line, " -- ").? + 4 ..])); + // And holds no other word's. + var others = std.mem.tokenizeScalar(u8, commands, '\n'); + while (others.next()) |other| if (!std.mem.eql(u8, other, line)) + try std.testing.expect(std.mem.indexOf(u8, one, other[std.mem.indexOf(u8, other, " -- ").? + 4 ..]) == null); + } + // A word that is neither a builtin, as the registry spells it, nor SPC + // keys is said, the +Help left as it was. + const kept = try s.read(body); + try std.testing.expect(try s.refused("/ctl", "Help diff\n") != 0); + try s.expect(body, kept); + // SPC keys: the builtins under them. + try s.write("/ctl", "Help c\n"); + try std.testing.expect(std.mem.startsWith(u8, try s.read(body), "pardes builtins under SPC c\n")); + // All text is text: B2 on a builtin's name in the +Help runs it. + try s.write("/ctl", "Help Newcol\n"); + const before = std.mem.count(u8, try s.columns(), ":"); + // (its row, `SPC c n Newcol`: the topbar's Newcol is drawn first) + try s.click("c n Newcol", "c n N".len, 2); + try std.testing.expectEqual(before + 1, std.mem.count(u8, try s.columns(), ":")); +} + test "builtins: Build prints this build into a +Build pane" { var s = try Session.initFile(std.testing.allocator, "x\n"); defer s.deinit(); diff --git a/test/panes.zig b/test/panes.zig index 88209693..bd39beba 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -2083,7 +2083,11 @@ const OutputTests = struct { _ = try p.render(frame.allocator()); const rect = p.view().rects[id]; const x = rect.x + config.GUTTER + panes.File.gutterWidth(help) + @as(u16, @intCast(at - line_start + 2)); - const y = (bodyY(p, rect)) + @as(u16, @intCast(row)); + // Its documentation above it wraps: the row the line starts on. + const shown = for (help.wrap_line[0..help.wrap_n], 0..) |line, i| { + if (line == @as(i32, @intCast(row))) break i; + } else return error.MissingTutorRow; + const y = (bodyY(p, rect)) + @as(u16, @intCast(shown)); p.update(.{ .mouse = .{ .button = config.exec_button, .kind = .press, .col = x, .row = y } }); p.update(.{ .mouse = .{ .button = config.exec_button, .kind = .release, .col = x, .row = y } }); try std.testing.expect(p.view().active != id); diff --git a/test/process/tty_boot.zig b/test/process/tty_boot.zig index 51aea53b..231469f1 100644 --- a/test/process/tty_boot.zig +++ b/test/process/tty_boot.zig @@ -122,7 +122,7 @@ fn builtins(gpa: std.mem.Allocator, exe: [:0]const u8) !void { // The full index includes commands without leader paths. try t.key("space ?"); - try t.wait(10000, "pardes builtins, and how to run each:"); + try t.wait(10000, "pardes builtins: each one's keys and its name"); try t.wait(10000, "ClipPasteBefore"); try t.key("g e"); // Every builtin added since adds an index line, and one wheel tick is one row @@ -539,7 +539,7 @@ fn leader(gpa: std.mem.Allocator, exe: [:0]const u8) !void { // 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, and how to run each:"); + try t.wait(10000, "pardes builtins: each one's keys and its name"); try t.wait(10000, "ClipPasteBefore"); try t.key("space h ?"); try t.wait(10000, "under SPC h"); @@ -562,7 +562,7 @@ fn leader(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.stable(700, 15000); try t.key("space ?"); - try t.wait(10000, "pardes builtins, and how to run each:"); + 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. |
