summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-23 15:47:11 -0300
committerGabriel Schneider <[email protected]>2026-11-23 15:55:44 -0300
commit544d7265a8527be11ad9e8f944fa3723ae113a31 (patch)
treebf014e290626ad88e546b06079b94dc53326d938
parent33b1f209162f94a9200f8c00d131aae772eb02f2 (diff)
downloadpardes-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
-rw-r--r--core/Output.zig171
-rw-r--r--core/builtins.zig16
-rw-r--r--docs/typ/builtins-tui.json2
-rw-r--r--test/behaviour/addons.zig2
-rw-r--r--test/behaviour/builtins.zig44
-rw-r--r--test/panes.zig6
-rw-r--r--test/process/tty_boot.zig6
7 files changed, 205 insertions, 42 deletions
diff --git a/core/Output.zig b/core/Output.zig
index 09ec2a51..a1e5865e 100644
--- a/core/Output.zig
+++ b/core/Output.zig
@@ -757,13 +757,16 @@ fn openStepped(p: *Pardes, id: usize, from: Origin, content: []u8) !void {
look.armLookWalk(p, free);
}
+/// The +Help's text: a builtin a row (its keys, its name, its other
+/// shortcuts) with its documentation under it, a line a paragraph, and a
+/// blank line; bare (`prefix` empty) every builtin of this view, then the
+/// addons' words, the language keys and how a query pane is driven; with
+/// `prefix`, the builtins under SPC and those keys.
fn helpContent(p: *const Pardes, gpa: std.mem.Allocator, prefix: []const u8) ![]u8 {
- const full_header = "pardes builtins, and how to run each:\nSPC and its keys, a chord, a button, the\ntopbar - or the name, executed anywhere.\n\n";
+ const full_header = "pardes builtins: each one's keys and its name, then what it does. Run one by its keys, or by its name anywhere: B2 on the word, Exec <name>, a line of a ctl file, or `pardes do <name>` from a shell. `Help <name>` shows one builtin alone; `Help <keys>` (or SPC, those keys, then ?) the builtins under SPC and those keys.\n\n";
const group_header = "pardes builtins under SPC";
- const calls_help = "\nCallstack: static caller chains,\nwith signatures and clickable call sites.\nCallers / Callees: one direction at a time.\n";
- const show_calls_help = prefix.len == 0 or std.mem.eql(u8, prefix, "l");
const language_footer =
- "\nlanguage keys (motions, not words):\n" ++
+ "language keys (motions, not words):\n" ++
"gd gD gy gi gr goto: definition,\n" ++
" declaration, type-def,\n" ++
" implementation, refs\n" ++
@@ -775,7 +778,7 @@ fn helpContent(p: *const Pardes, gpa: std.mem.Allocator, prefix: []const u8) ![]
"Tab after a . completion, in insert\n" ++
"C-left-click definition, by mouse\n" ++
"SPC l ... hover, rename, symbols,\n" ++
- " calls, types: above\n";
+ " calls, types: above\n\n";
var out: std.Io.Writer.Allocating = .init(gpa);
errdefer out.deinit();
const w = &out.writer;
@@ -790,26 +793,15 @@ fn helpContent(p: *const Pardes, gpa: std.mem.Allocator, prefix: []const u8) ![]
// word is none in a terminal's view
if (!std.mem.startsWith(u8, row.path orelse "", prefix)) continue;
if (!builtins.registry.here(p, row.cmd)) continue;
- try w.print("{s}\n", .{row.line});
+ try w.print("{s}\n{s}\n\n", .{ row.line, builtins.registry.doc(row.cmd).text });
}
// An addon's words, after the core's, each saying whose it is.
for (p.kinds.words[0..p.kinds.nwords]) |*kw| {
const path = kw.leader.slice();
if (!std.mem.startsWith(u8, path, prefix) or (prefix.len > 0 and path.len == 0)) continue;
- var keys: [64]u8 = undefined;
- var n: usize = 0;
- if (path.len > 0) for ("SPC") |ch| {
- keys[n] = ch;
- n += 1;
- };
- for (path) |ch| if (n + 2 <= keys.len) {
- keys[n] = ' ';
- keys[n + 1] = ch;
- n += 2;
- };
- try w.print("{s: <12}{s} {s} (addon {s})\n", .{ keys[0..n], kw.name.slice(), kw.doc.slice(), p.kinds.kinds[kw.kind].nameOf() });
+ try addonRow(w, p, kw);
+ try w.print("{s}\n\n", .{kw.doc.slice()});
}
- if (show_calls_help) try w.writeAll(calls_help);
if (prefix.len == 0) try w.writeAll(language_footer);
// The paths that run a builtin with a word (config.leader_args), and how
// a query pane is driven: under SPC f, b, s and in the whole listing.
@@ -817,7 +809,7 @@ fn helpContent(p: *const Pardes, gpa: std.mem.Allocator, prefix: []const u8) ![]
if (std.mem.startsWith(u8, la.path, prefix)) break true;
} else std.mem.eql(u8, prefix, "f");
if (prefix.len == 0 or search_group) {
- try w.writeAll("\nsearch: a query pane under the text,\nits line 1 the query, its first word\nthe source (/ Find Grep Recent Panes\nSymbols All Refs Def Impl Diagnostics)\n");
+ try w.writeAll("search: a query pane under the text,\nits line 1 the query, its first word\nthe source (/ Find Grep Recent Panes\nSymbols All Refs Def Impl Diagnostics)\n");
for (config.leader_args) |la| {
if (!std.mem.startsWith(u8, la.path, prefix)) continue;
var keys: [16]u8 = @splat(' ');
@@ -836,6 +828,91 @@ fn helpContent(p: *const Pardes, gpa: std.mem.Allocator, prefix: []const u8) ![]
return out.toOwnedSlice();
}
+/// The column a builtin's name stands at in its row (pardes.builtin_rows):
+/// an addon's word's row puts its name there too.
+const name_column = std.mem.indexOf(u8, pardes.builtin_rows[0].line, @tagName(pardes.builtin_rows[0].cmd)).?;
+
+/// An addon's word's row: its keys, its name, whose it is.
+fn addonRow(w: *std.Io.Writer, p: *const Pardes, kw: *const pardes.Kind.Word) std.Io.Writer.Error!void {
+ var key_buf: [32]u8 = undefined;
+ var keys: std.Io.Writer = .fixed(&key_buf);
+ const path = kw.leader.slice();
+ if (path.len > 0) keys.writeAll("SPC") catch {};
+ for (path) |ch| keys.print(" {c}", .{ch}) catch {};
+ try w.print("{s}", .{keys.buffered()});
+ try w.splatByteAll(' ', name_column -| keys.buffered().len);
+ try w.print("{s} (addon {s})\n", .{ kw.name.slice(), p.kinds.kinds[kw.kind].nameOf() });
+}
+
+/// Builtin `b` alone (`Help <name>`, `pardes help <name>`): its row, its
+/// documentation, and what the list does not say, a line each: its keys
+/// spelled out, its argument, what it acts on, and the same word from a
+/// shell.
+pub fn writeWordHelp(w: *std.Io.Writer, b: Builtin) std.Io.Writer.Error!void {
+ const row = for (pardes.builtin_rows) |r| {
+ if (r.cmd == b) break r;
+ } else unreachable; // a row a builtin
+ const name = @tagName(b);
+ try w.print("{s}\n\n{s}\n\n", .{ row.line, builtins.registry.doc(b).text });
+ try w.writeAll("keys: ");
+ const shortcuts = std.mem.trim(u8, row.line[std.mem.indexOf(u8, row.line, name).? + name.len ..], " ");
+ var first = true;
+ if (row.path) |path| {
+ try w.writeAll("SPC");
+ for (path) |c| try w.print(" {c}", .{c});
+ try w.writeAll(" in normal mode");
+ first = false;
+ }
+ var parts = std.mem.splitSequence(u8, shortcuts, ", ");
+ while (parts.next()) |part| if (part.len > 0) {
+ if (!first) try w.writeAll("; ");
+ first = false;
+ try w.writeAll(if (std.mem.eql(u8, part, "topbar")) "its word in the workspace tag" else part);
+ };
+ if (row.path == null and shortcuts.len == 0) try w.print("none: run its name (B2 on it, Exec {s})", .{name});
+ try w.writeAll("\nargument: ");
+ if (config.Settings.find(name)) |setting| {
+ try w.writeAll(config.Settings.takes(setting.action) orelse "a value");
+ if (!builtins.registry.requiresArg(b)) try w.writeAll(", or none");
+ } else try w.writeAll(if (!builtins.registry.takesArg(b)) "none" else if (builtins.registry.requiresArg(b)) "required" else "optional");
+ try w.writeAll("\nacts on: ");
+ if (builtins.registry.needs(b)) |kind| try w.print("{s}, ", .{kind.noun()});
+ try w.writeAll(if (b == .Edit)
+ "the pane it runs from (over 9P, a pane's ctl, or the root's for the pane with the keyboard)"
+ else if (builtins.registry.scope(b) == .session)
+ "the session (over 9P, the root ctl)"
+ else
+ "the pane it runs from (over 9P, that pane's ctl)");
+ if (!builtins.registry.hereFor(b, builtins.capabilities, false)) try w.writeAll("; a window's word: none in a terminal");
+ try w.print("\nfrom a shell: pardes do {s}{s}\n", .{ name, if (!builtins.registry.takesArg(b)) "" else if (builtins.registry.requiresArg(b)) " ARG" else " [ARG]" });
+}
+
+/// An addon's word alone, as `writeWordHelp` writes a builtin.
+fn writeAddonWordHelp(w: *std.Io.Writer, p: *const Pardes, kw: *const pardes.Kind.Word) std.Io.Writer.Error!void {
+ try addonRow(w, p, kw);
+ try w.print("\n{s}\n\nkeys: ", .{kw.doc.slice()});
+ const path = kw.leader.slice();
+ if (path.len == 0) try w.print("none: run its name (B2 on it, Exec {s})", .{kw.name.slice()}) else {
+ try w.writeAll("SPC");
+ for (path) |c| try w.print(" {c}", .{c});
+ try w.writeAll(" in normal mode");
+ }
+ const arg = switch (kw.arg) {
+ pardes.Kind.c.PA_ARG_NONE => "none",
+ pardes.Kind.c.PA_ARG_REQUIRED => "required",
+ else => "optional",
+ };
+ try w.print("\nargument: {s}\nacts on: {s} pane, the one it runs from (over 9P, that pane's ctl)\nfrom a shell: pardes do {s}{s}\n", .{
+ arg,
+ p.kinds.kinds[kw.kind].nameOf(),
+ kw.name.slice(),
+ if (kw.arg == pardes.Kind.c.PA_ARG_NONE) "" else if (kw.arg == pardes.Kind.c.PA_ARG_REQUIRED) " ARG" else " [ARG]",
+ });
+}
+
+/// The +Help (keys.zig's `SPC ... ?`, the `Help` word): bare, every
+/// builtin; `prefix`, those under SPC and those keys. One +Help: a second
+/// fills it again.
pub fn openHelp(p: *Pardes, id: usize, prefix: []const u8) !void {
const content = try helpContent(p, p.gpa, prefix);
// content is handed off unfreed on purpose: openRead adopts it or frees
@@ -843,6 +920,35 @@ pub fn openHelp(p: *Pardes, id: usize, prefix: []const u8) !void {
return openRead(p, id, .{ .cmd = .Help }, prefix, content);
}
+/// `Help <what>`: a builtin's name or an addon's word, as the registry
+/// takes them, that one alone in the +Help; SPC keys, the builtins under
+/// them. False for a word that is neither, the +Help left as it was.
+pub fn openHelpOn(p: *Pardes, id: usize, what: []const u8) !bool {
+ const b = std.meta.stringToEnum(Builtin, what);
+ const word = for (p.kinds.words[0..p.kinds.nwords]) |*kw| {
+ if (std.mem.eql(u8, kw.name.slice(), what)) break kw;
+ } else null;
+ if (b == null and word == null) {
+ if (!underKeys(p, what)) return false;
+ try openHelp(p, id, what);
+ return true;
+ }
+ var out: std.Io.Writer.Allocating = .init(p.gpa);
+ errdefer out.deinit();
+ if (b) |one| try writeWordHelp(&out.writer, one) else try writeAddonWordHelp(&out.writer, p, word.?);
+ try openRead(p, id, .{ .cmd = .Help }, what, try out.toOwnedSlice());
+ return true;
+}
+
+/// Whether some builtin of this view, or an addon's word, is under SPC and
+/// `keys`.
+fn underKeys(p: *const Pardes, keys: []const u8) bool {
+ for (pardes.builtin_rows) |row| if (row.path) |path| if (std.mem.startsWith(u8, path, keys) and builtins.registry.here(p, row.cmd)) return true;
+ for (config.leader_args) |la| if (std.mem.startsWith(u8, la.path, keys)) return true;
+ for (p.kinds.words[0..p.kinds.nwords]) |*kw| if (kw.leader.slice().len > 0 and std.mem.startsWith(u8, kw.leader.slice(), keys)) return true;
+ return false;
+}
+
/// Where a dump goes by default, as the session's environment says (the
/// authority's, `tape.authority`): in `buf`.
fn dumpDirectory(buf: []u8) []const u8 {
@@ -1078,33 +1184,30 @@ test "plain output does not opt into location decoration" {
try std.testing.expect(traits(.{ .query = .completion }).locations);
}
-test "full Help renders builtin rows, a call hierarchy guide, then language keys" {
+test "full Help renders each builtin's row with its documentation under it, then language keys" {
const core = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
defer core.deinit();
const content = try helpContent(core, std.testing.allocator, "");
defer std.testing.allocator.free(content);
- // FIRST blank line: the end of the header (the footer opens with one too)
+ // FIRST blank line: the end of the header
const body = content[(std.mem.indexOf(u8, content, "\n\n") orelse
return error.MissingHelpHeader) + 2 ..];
var lines = std.mem.splitScalar(u8, body, '\n');
- for (pardes.builtin_rows) |row| if (builtins.registry.here(core, row.cmd))
- try std.testing.expectEqualStrings(row.line, lines.next() orelse
- return error.MissingBuiltinHelpRow);
- // The short call guide disambiguates the three related commands.
- try std.testing.expectEqualStrings("", lines.next() orelse return error.MissingCallHelp);
- try std.testing.expectEqualStrings("Callstack: static caller chains,", lines.next() orelse return error.MissingCallHelp);
- try std.testing.expectEqualStrings("with signatures and clickable call sites.", lines.next() orelse return error.MissingCallHelp);
- try std.testing.expectEqualStrings("Callers / Callees: one direction at a time.", lines.next() orelse return error.MissingCallHelp);
+ for (pardes.builtin_rows) |row| if (builtins.registry.here(core, row.cmd)) {
+ try std.testing.expectEqualStrings(row.line, lines.next() orelse return error.MissingBuiltinHelpRow);
+ // A line a paragraph, then a blank line.
+ var paragraphs = std.mem.splitScalar(u8, builtins.registry.doc(row.cmd).text, '\n');
+ while (paragraphs.next()) |paragraph| try std.testing.expectEqualStrings(paragraph, lines.next() orelse return error.MissingDocumentation);
+ try std.testing.expectEqualStrings("", lines.next() orelse return error.MissingBlank);
+ };
// The language keys close the page.
- try std.testing.expectEqualStrings("", lines.next() orelse
- return error.MissingLanguageKeys);
try std.testing.expectEqualStrings("language keys (motions, not words):", lines.next() orelse
return error.MissingLanguageKeys);
try std.testing.expect(std.mem.indexOf(u8, body, "\ngd gD gy gi gr goto: definition,\n") != null);
- // The language group also explains call commands, without the motion footer.
+ // The language group: its words' documentation, without the motion footer.
const group = try helpContent(core, std.testing.allocator, "l");
defer std.testing.allocator.free(group);
try std.testing.expect(std.mem.indexOf(u8, group, "language keys") == null);
- try std.testing.expect(std.mem.indexOf(u8, group, "Callstack: static caller chains") != null);
+ try std.testing.expect(std.mem.indexOf(u8, group, builtins.registry.doc(.Callstack).text) != null);
}
diff --git a/core/builtins.zig b/core/builtins.zig
index b7e1a111..81ec4c2b 100644
--- a/core/builtins.zig
+++ b/core/builtins.zig
@@ -1520,12 +1520,24 @@ pub const Tutor = struct {
}
};
-/// Open the help: every key and every builtin.
+/// Show every builtin with its keys and documentation, or one builtin's alone.
+///
+/// `Help <name>`: that builtin alone, its keys spelled out, what it acts on
+/// and its line for a shell (`Help Diff`); a setting or an addon's word the
+/// same. `Help <keys>`: the builtins under SPC and those keys (`Help l`, as
+/// `SPC l ?` shows them). Each fills the one +Help: a second Help replaces
+/// its text.
pub const Help = struct {
pub const scope: Scope = .session;
+ pub const takes_arg = true;
pub const output: OutputTraits = .{ .name = config.help_buffer };
pub fn run(c: Ctx) void {
- panes.Output.openHelp(c.p, c.id, "") catch |err| c.p.reportError(.at(c.id), "help", err);
+ const what = std.mem.trim(u8, c.arg orelse "", " \t\r\n");
+ if (what.len == 0) return panes.Output.openHelp(c.p, c.id, "") catch |err| c.p.reportError(.at(c.id), "help", err);
+ const found = panes.Output.openHelpOn(c.p, c.id, what) catch |err| return c.p.reportError(.at(c.id), "help", err);
+ if (found) return;
+ var said: pardes.Kind.Buf(128) = .{};
+ c.p.reportFailure(c.id, said.print("Help: {s}: no such builtin, nor SPC keys", .{what[0..@min(what.len, 64)]}));
}
};
diff --git a/docs/typ/builtins-tui.json b/docs/typ/builtins-tui.json
index ad5753a9..63dd263c 100644
--- a/docs/typ/builtins-tui.json
+++ b/docs/typ/builtins-tui.json
@@ -44,7 +44,7 @@
{"name": "Forward", "leader": "SPC j i", "also": ["C-i"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Ctrl-i: one step forward again, up to wherever Back started.", "text": "Ctrl-i: one step forward again, up to wherever Back started."},
{"name": "Get", "leader": null, "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "acme's Get: the pane's file read again, its unsaved edits refused once as Del refuses them.", "text": "acme's Get: the pane's file read again, its unsaved edits refused once as Del refuses them. `Get file` loads that file into the pane instead, the pane taking its name."},
{"name": "Grep", "leader": "SPC f g", "also": ["topbar"], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "List the lines of the files below this pane's directory that hold its argument.", "text": "List the lines of the files below this pane's directory that hold its argument.\nFind matches the files' names, Grep the lines of those files, on the disk engine's worker. A query pane under this pane: bare (`SPC f g`) typed into; with a word, listed."},
- {"name": "Help", "leader": "SPC ?", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Open the help: every key and every builtin.", "text": "Open the help: every key and every builtin."},
+ {"name": "Help", "leader": "SPC ?", "also": ["topbar"], "arg": true, "scope": "root", "setting": false, "choices": null, "doc": "Show every builtin with its keys and documentation, or one builtin's alone.", "text": "Show every builtin with its keys and documentation, or one builtin's alone.\n`Help <name>`: that builtin alone, its keys spelled out, what it acts on and its line for a shell (`Help Diff`); a setting or an addon's word the same. `Help <keys>`: the builtins under SPC and those keys (`Help l`, as `SPC l ?` shows them). Each fills the one +Help: a second Help replaces its text."},
{"name": "History", "leader": "SPC f h", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "List the state file's dumps, newest first, each with the Restore that brings it back.", "text": "List the state file's dumps, newest first, each with the Restore that brings it back.\nThose Dump made and those every session's end left: each a `Restore <label>` line, its date, size and pane count, the panes' names indented under it. A click on the Restore (an exec, or a Look at the line) is that Restore."},
{"name": "Hover", "leader": "SPC l k", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Ask the language server about the symbol under the cursor.", "text": "Ask the language server about the symbol under the cursor."},
{"name": "InactiveDim", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "Fade the unfocused panes' text by a percentage, 0 through 100, 0 off.", "text": "Fade the unfocused panes' text by a percentage, 0 through 100, 0 off."},
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.