From 544d7265a8527be11ad9e8f944fa3723ae113a31 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 23 Nov 2026 15:47:11 -0300 Subject: 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 ` shows that one alone, and `Help ` 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 [ARG]`); SPC keys open that group (`openHelp`, as `SPC ?` does); a word that is neither fails, `Help: : 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 )` 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 ` that one's alone, and B2 on a builtin's name in it runs it" (through 9P alone: for every word of /commands, `Help `'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 Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- test/behaviour/addons.zig | 2 +- test/behaviour/builtins.zig | 44 ++++++++++++++++++++++++++++++++++++++++++++ test/panes.zig | 6 +++++- test/process/tty_boot.zig | 6 +++--- 4 files changed, 53 insertions(+), 5 deletions(-) (limited to 'test') 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 ` 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. -- cgit v1.3 From 36dab7187fa0322c728848532638d549af02f746 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 23 Nov 2026 15:14:30 -0300 Subject: upgrade: a window comes back from an Upgrade the size it had (the user's two windows went from 140 x 74 cells to 112 x 32 and from 343 columns to 193 at the 15:11 install): a window session's Upgrade is an exec, and its record said only that there was a window (runtime/upgrade.zig `Record.window`), so the new image made it the default 1120 x 720 points, or the `--geometry` it was started with (its arguments are passed again), never the size the user had given it since; now `upgradeNow` (dev/gui/gui.zig) puts the window's size in points as SDL_GetWindowSize says it then in the record, a line `size WxH` after `window 1` (`Record.size`), and the new image takes it as its `--geometry`, ahead of the one it was started with: the pair's road (a client window's PARDES_JOIN_SIZE, runtime/client.zig `execAgain`, read by the same parse), size only as the pair's (no place: an X11 window started at `+X+Y` is placed by the window manager after an Upgrade now); an older build's record has no such line (the word is passed over by a build before this one): the default, as before; a test window keeps a carried size over PARDES_TEST_COLS and ROWS; test: test/daemon.py `gui_upgrades` resizes the session's window to 100 x 30 cells (the test feed's in-band resize) before the Upgrade and reads the new image's first frame's size from its capture: on the base 1280x840 (80 x 24, the default) where it had been 1600x1050; now 1600x1050 from a build that writes the line, the default from one that does not (the record on the new process's command line says which), and upgrade.zig's record test reads the line back and an older record's none; core-test 934/1100 (166 skipped), shell-test 1142/1145 (3 skipped), gui unit-test 1739/1743 (4 skipped; its perf step's known BaselineHarnessMismatch), test/daemon.py `--upgrade --gui` between this tree's builds (Debug, unstamped and -Dstamp-commit: two semantics) 3/3 and from the installed build (62c6caf414fd) 3/3, `--upgrade` from it 1/1, plain 1/1 Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- dev/gui/gui.zig | 17 ++++++++++++++--- runtime/upgrade.zig | 15 +++++++++++---- test/daemon.py | 29 +++++++++++++++++++++++++++-- 3 files changed, 52 insertions(+), 9 deletions(-) (limited to 'test') diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig index 76af0ec8..2756f69b 100644 --- a/dev/gui/gui.zig +++ b/dev/gui/gui.zig @@ -809,9 +809,12 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, detached: bool, di var want_w: c_int = 1120; var want_h: c_int = 720; var want_at: ?[2]c_int = null; - // ...or the size an Upgrade's exec says its window had (client.zig + // ...or the size an Upgrade's exec says its window had: a session's in + // its record (upgrade.zig `Record.size`), ahead of the `--geometry` it + // was started with, a client's in PARDES_JOIN_SIZE (client.zig // `execAgain`). - if (opts_in.geometry orelse if (std.c.getenv("PARDES_JOIN_SIZE")) |e| std.mem.span(e) else null) |spec| geometry: { + const kept = if (upgrade.resumed) |rec| rec.size else null; + if (kept orelse opts_in.geometry orelse if (std.c.getenv("PARDES_JOIN_SIZE")) |e| std.mem.span(e) else null) |spec| geometry: { const x_at = std.mem.indexOfScalar(u8, spec, 'x') orelse break :geometry; const plus = std.mem.indexOfAnyPos(u8, spec, x_at, "+-") orelse spec.len; want_w = std.math.clamp(std.fmt.parseInt(c_int, spec[0..x_at], 10) catch break :geometry, 200, 16384); @@ -881,7 +884,8 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, detached: bool, di const cell_w: u32 = @intCast(@max(cw, 1)); const cell_h: u32 = @intCast(@max(chh, 1)); const tagline = taglineRaster(&atlas, px, cell_w, cell_h, config.gui_tagline_font_percent); - if (test_mode) { + // An upgraded window keeps its size in a test too. + if (test_mode and kept == null) { const cols = envU16(env, "PARDES_TEST_COLS") orelse 80; const rows = envU16(env, "PARDES_TEST_ROWS") orelse 24; // PARDES_TEST_PAD: extra pixels past the grid, as a real window has. @@ -2535,6 +2539,13 @@ const Shell = struct { // dials the session again once it is back. s.peers.refuseAll(core); var rec: upgrade.Record = .{ .link = daemon.link, .window = s.gui != null, .exe = path }; + // Its window's size now, the new one's (the user's since its start). + var size_buf: [32]u8 = undefined; + if (s.gui) |g| { + var w: c_int = 0; + var h: c_int = 0; + if (c.SDL_GetWindowSize(g.window, &w, &h)) rec.size = std.fmt.bufPrint(&size_buf, "{d}x{d}", .{ w, h }) catch null; + } s.ptys.record(&rec); var at_buf: [1024:0]u8 = undefined; const failed = upgrade.dumpInto(core, &rec, &at_buf, &why) orelse upgrade.execAs(s.gpa, path, &rec, &at_buf, s.fs, &why); diff --git a/runtime/upgrade.zig b/runtime/upgrade.zig index 510c50ea..b385556c 100644 --- a/runtime/upgrade.zig +++ b/runtime/upgrade.zig @@ -134,6 +134,10 @@ pub const Record = struct { old: c_int = -1, /// A window was open (the GUI). window: bool = false, + /// Its size in points at the Upgrade, `WxH` (SDL_GetWindowSize then: the + /// user's since its start), the new window's `--geometry` (gui.zig). + /// None, an older build's record: the default. + size: ?[]const u8 = null, ptys: [pardes.MAX_PANES]Pty = undefined, nptys: usize = 0, ttys: [pardes.views.max]Tty = undefined, @@ -187,6 +191,7 @@ pub const Record = struct { /// One `word value` a line, the dump's path last (its line is all of it). pub fn encode(rec: *const Record, w: *std.Io.Writer) !void { try w.print("link {d}\nstub {d}\nold {d}\nwindow {d}\n", .{ rec.link, rec.stub, rec.old, @intFromBool(rec.window) }); + if (rec.size) |wh| try w.print("size {s}\n", .{wh}); for (rec.ptys[0..rec.nptys]) |p| try w.print("pty {d} {d} {d}\n", .{ p.pane, p.pid, p.fd }); for (rec.ttys[0..rec.nttys]) |t| try w.print("tty {d} {d} {d} {d} {x}\n", .{ t.view, t.fd, t.stub, @intFromBool(t.primary), std.mem.asBytes(&t.termios) }); if (rec.refused.len > 0) try w.print("refused {s}\n", .{rec.refused}); @@ -206,11 +211,12 @@ pub const Record = struct { const rest = line[sp + 1 ..]; var it = std.mem.tokenizeScalar(u8, rest, ' '); // A word of a later build's record is passed over. - switch (std.meta.stringToEnum(enum { link, stub, old, window, pty, tty, refused, label, state, exe, dump }, word) orelse continue) { + switch (std.meta.stringToEnum(enum { link, stub, old, window, size, pty, tty, refused, label, state, exe, dump }, word) orelse continue) { .link => rec.link = try std.fmt.parseInt(c_int, rest, 10), .stub => rec.stub = try std.fmt.parseInt(c_int, rest, 10), .old => rec.old = try std.fmt.parseInt(c_int, rest, 10), .window => rec.window = std.mem.eql(u8, rest, "1"), + .size => rec.size = rest, .pty => { if (rec.nptys == rec.ptys.len) return error.BadRecord; const pane = try std.fmt.parseInt(u8, it.next() orelse return error.BadRecord, 10); @@ -474,7 +480,7 @@ pub fn load(gpa: std.mem.Allocator, core_gpa: std.mem.Allocator, opts: pardes.Op } test "an upgrade's record reads back as it was written, and refuses one cut short" { - var rec: Record = .{ .link = 5, .stub = 7, .old = 9, .window = true, .exe = "/a b/pardes", .dump = "/home/u/.local/share/pardes/pardes.xitdb", .label = "upgrade-1", .state = .kept }; + var rec: Record = .{ .link = 5, .stub = 7, .old = 9, .window = true, .size = "1402x1488", .exe = "/a b/pardes", .dump = "/home/u/.local/share/pardes/pardes.xitdb", .label = "upgrade-1", .state = .kept }; rec.addPty(3, 1234, 11); rec.addPty(0, 99, 12); var tio: posix.termios = std.mem.zeroes(posix.termios); @@ -487,6 +493,7 @@ test "an upgrade's record reads back as it was written, and refuses one cut shor try std.testing.expectEqual(@as(c_int, 5), back.link); try std.testing.expectEqual(@as(c_int, 9), back.old); try std.testing.expect(back.window); + try std.testing.expectEqualStrings("1402x1488", back.size.?); try std.testing.expectEqual(@as(usize, 2), back.nptys); try std.testing.expectEqual(Pty{ .pane = 3, .pid = 1234, .fd = 11 }, back.ptys[0]); try std.testing.expectEqual(@as(usize, 1), back.nttys); @@ -496,11 +503,11 @@ test "an upgrade's record reads back as it was written, and refuses one cut shor try std.testing.expectEqualStrings("/home/u/.local/share/pardes/pardes.xitdb", back.dump); try std.testing.expectEqualStrings("upgrade-1", back.label); try std.testing.expectEqual(daemon.State.kept, back.state.?); - // An older build's: its dump a file, no label, no state. + // An older build's: its dump a file, no label, no state, no size. const older = try Record.decode("link 5\nexe /a\ndump /run/u/pardes-upgrade-1.dump\n"); try std.testing.expectEqualStrings("/run/u/pardes-upgrade-1.dump", older.dump); try std.testing.expectEqualStrings("", older.label); - try std.testing.expect(older.state == null); + try std.testing.expect(older.state == null and older.size == null); try std.testing.expectError(error.BadRecord, Record.decode("link 5\n")); try std.testing.expectError(error.BadRecord, Record.decode("tty 0 1 2 1 abc\ndump x\n")); } diff --git a/test/daemon.py b/test/daemon.py index f456837b..b9296ea2 100644 --- a/test/daemon.py +++ b/test/daemon.py @@ -3995,10 +3995,17 @@ def upgrade_clients(old, new): shutil.rmtree(root, ignore_errors=True) +def frame_size(ppm): + """A window's capture's width and height in pixels (its P6 header).""" + return tuple(int(n) for n in ppm.read_bytes()[:32].split()[1:3]) + + def gui_upgrades(old, new): """Upgrade in a window session (test mode: hidden windows, captured): - its window, a client window, an unsaved edit and a shell's job, onto - another build.""" + its window, resized since its start, a client window, an unsaved edit + and a shell's job, onto another build; its new window the size the old + one had when its record names it (upgrade.zig `Record.size`), the + default when an older build's names none.""" scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' root = Path(tempfile.mkdtemp(prefix='rtgu-', dir=scratch)) env = base_env() @@ -4042,12 +4049,19 @@ def gui_upgrades(old, new): started.append(second.pid) frames = [caps / 'latest.ppm', root / 'second' / 'latest.ppm'] wait_for('both windows drawn', lambda: all(f.exists() for f in frames), timeout=20) + # The window resized by hand since its start (the test feed's + # in-band resize, CSI 48;rows;cols t, as a user's drag). + start = frame_size(frames[0]) + os.write(feed_w, b'\x1b[48;30;100t') + wait_for('the window resized', lambda: frame_size(frames[0]) != start) + sized = frame_size(frames[0]) install(new, binary) time.sleep(.05) mark = time.time() client.write(f'/pane/{shell}/exec', b'Upgrade\n') client.socket.close() wait_for('the session on the new build', lambda: exe_of(proc.pid) == (str(binary), True), timeout=30) + exec_at = time.time() client = reconnect(sock) assert proc.poll() is None wait_for('the daemon on the new build', lambda: exe_of(daemon) == (str(binary), True)) @@ -4070,6 +4084,17 @@ def gui_upgrades(old, new): second.p.wait(timeout=30) said = second.err.read_bytes() assert b'upgrade this client too' in said or b'run the same pardes at both ends' in said, said[-400:] + # The new build's window (a frame captured since the exec) the size + # the old one had at the Upgrade, not the one it started at, when + # the old build's record (the new process's command line) names it; + # an older build's names none: the default. + wait_for('a frame of the new build\'s window', lambda: frames[0].stat().st_mtime > exec_at) + record = next((a for a in cmdline(proc.pid) if a.startswith(b'--upgraded=')), b'') + size = re.search(rb'\nsize (\S+)\n', record) + back = frame_size(frames[0]) + assert back == (sized if size else start), ('the window back the size it had' if size else 'the default', back, sized, start, record) + print(f'upgrade: the window resized from {start[0]}x{start[1]} to {sized[0]}x{sized[1]} pixels came back ' + + (f'that size (its record: size {size[1].decode()})' if size else 'at the default (the old build\'s record names no size)')) said = Replica(root / 'pardes-replica.sock').hello('win', semantics(new)) assert said == ('welcome', proc.pid, 'win'), said os.kill(sleeper, signal.SIGTERM) -- cgit v1.3 From 0742955e2cb52d644fb868b21865149d2a6438f8 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 23 Nov 2026 15:55:44 -0300 Subject: help: `pardes help ` prints what `Help ` shows (one function writes both, core/Output.zig `writeWordHelp`: the builtin's row, its whole documentation, its keys, argument, what it acts on and its `pardes do` line), and the manual's glossary prints each word's whole documentation under it (the sinks of the one table, `registry.doc`: the user's "the CLI as living documentation, like 9P, maybe sharing the source with different sinks"): `pardes help ` read the word's line of /commands, a session's or a core made here, and printed its first sentence; now a builtin of this build is answered from the table with no tree asked (runtime/main.zig `help`), the name as the registry takes it (`pardes help index` stays the tree's file), and an addon's word, which only a session knows, as before from /commands; `pardes help`, `pardes words` and /commands keep one line a word, the summary; docs/typ/style.typ's `builtin-entry` prints `text`, a paragraph a line, where it printed `doc` (the summary); tests: test/process/cli.zig's help case (`pardes help Newcol`: its row and `acts on: the session (over 9P, the root ctl)`; `pardes help Save`: `from a shell: pardes do Save [ARG]`; `pardes help Diff`: its second paragraph's `Diff `); process-test (cli: help) 1/1, core-test (docs/typ) 9/9, Debug tui; the book builds in the change that regenerates builtins-gui.json (its words need `text` too) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- docs/typ/style.typ | 6 ++++-- runtime/main.zig | 6 ++++++ test/process/cli.zig | 8 ++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/docs/typ/style.typ b/docs/typ/style.typ index bf005c63..1b172dc8 100644 --- a/docs/typ/style.typ +++ b/docs/typ/style.typ @@ -188,7 +188,8 @@ /// Every builtin of either build, written by `zig build builtins-json` /// from the registry and the Help rows (core/builtins_json.zig), a file per /// build: name, leader, also (Help's other shortcuts), arg, scope, setting, -/// choices, doc, and for a shipped addon's word its addon first. Merged here, each with `platforms`: "both", "tui" (the +/// choices, doc (its summary), text (its whole documentation, a line a +/// paragraph), and for a shipped addon's word its addon first. Merged here, each with `platforms`: "both", "tui" (the /// terminal only) or "gui" (the window only). #let builtin-data = { let tui = json("builtins-tui.json") @@ -426,7 +427,8 @@ #if "addon" in b [#emph[the #raw(b.addon) addon's] · ] #if keys.len() > 0 [#keys.join([, ]) · ] #if b.choices != none [#raw(b.choices.replace(", ", "|")) · ] else if b.arg [takes an argument · ] - #prose(b.doc) + // its whole documentation (`text`), a paragraph a line, as Help shows it + #b.text.split("\n").map(prose).join(parbreak()) ] /// The glossary: everyday words first, then the groups, then internals, diff --git a/runtime/main.zig b/runtime/main.zig index 5cdf5ee0..8558e25f 100644 --- a/runtime/main.zig +++ b/runtime/main.zig @@ -879,6 +879,12 @@ fn help(init: std.process.Init, out: *std.Io.Writer, args: []const []const u8, s writeLeaf(out, c) catch {}; return 0; } + // A builtin of this build: what `Help ` shows, its whole + // documentation (builtins.registry.doc) and what the list does not say. + if (std.meta.stringToEnum(pardes.builtins.registry.Builtin(), what)) |b| { + pardes.panes.Output.writeWordHelp(out, b) catch {}; + return 0; + } const t = readTree(init, session); const commands = t.read(arena, "commands") catch ""; if (Word.find(commands, what)) |w| { diff --git a/test/process/cli.zig b/test/process/cli.zig index 083ba368..bf3716a8 100644 --- a/test/process/cli.zig +++ b/test/process/cli.zig @@ -52,8 +52,12 @@ fn helpOffline(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try expectRan(try pardes(a, exe, root, &.{ "help", "attach" }), 0, "\n pardes attach box:notes ", "help attach"); try expectRan(try pardes(a, exe, root, &.{ "help", "new" }), 0, " --detach[=NAME]", "help new"); try expectRan(try pardes(a, exe, root, &.{ "help", "fs" }), 0, "usage: fs ls [PATH]", "help fs"); - try expectRan(try pardes(a, exe, root, &.{ "help", "Newcol" }), 0, "Newcol (the root ctl; SPC c n; column)", "help Newcol"); - try expectRan(try pardes(a, exe, root, &.{ "help", "Save" }), 0, "pardes do Save", "help Save"); + // A builtin: what `Help ` shows, its whole documentation. + const newcol = try pardes(a, exe, root, &.{ "help", "Newcol" }); + try expectRan(newcol, 0, "SPC c n Newcol", "help Newcol"); + try expectRan(newcol, 0, "\nacts on: the session (over 9P, the root ctl)\n", "help Newcol"); + try expectRan(try pardes(a, exe, root, &.{ "help", "Save" }), 0, "\nfrom a shell: pardes do Save [ARG]\n", "help Save"); + try expectRan(try pardes(a, exe, root, &.{ "help", "Diff" }), 0, "`Diff `", "help Diff"); try expectRan(try pardes(a, exe, root, &.{ "help", "pane/3/addr" }), 0, "pane// name body tag", "help pane/3/addr"); try expectRan(try pardes(a, exe, root, &.{ "help", "nowhere" }), 1, "is not a command, a builtin", "help nowhere"); const all = try pardes(a, exe, root, &.{ "help", "--all" }); -- cgit v1.3 From 73c916113fd8ca732e3e58586399020c2e291871 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 23 Nov 2026 16:06:49 -0300 Subject: help: the process cases that show the Help pane read it as it is now, their goldens with them, builtins-gui.json regenerated, and Compare's row said in words: test/process/tty_boot.zig's `builtins` case reached the full index's words with no SPC path by `g e` and forty wheel ticks up (a count every builtin added moved); with each word's documentation under its row they are some 220 lines down, so the case searches for Look's row, `/^ +Look ` and Enter (the one line that starts with blanks and `Look `: the documentation's lines start with a letter), and B2 on Tutor in the SPC h group at its row now (24); the `leader` case waits for the SPC t group's first two rows (`SPC t a Ascii`, `SPC t c Changes`), the rest being below its 41 rows now; tty_terminals.zig's `ttyhelp` waits for `SPC ? Help`; the three goldens (test/snapshots/builtins.golden, leader.golden, ttyhelp.golden) updated a case at a time (`-- --update `) and read: each Help capture now shows the rows with their documentation under them, the builtins case's query pane `/^ +Look` and its row `@p2:220:1`, Tutor opened by B2 from the index; docs/typ/builtins-gui.json regenerated (`text` in it, every doc the table's); Compare's second paragraph says its pair's row in words (the two points, how many changes lie between them, their first and last days) where the format `from..to N changes dates` lost a blank where the `///` wrapped; docs/typ/builtins-tui.json with it; the tui suites on the tree before this change's Compare edit: core-test 942/1108 (166 skipped), shell-test 1150/1153 (3 skipped), pane-test 182/183 (1 skipped), behaviour-test 277/277 and `-- --replay` 20 seeds of 70 steps 0 failures, term-test 17/17, kitty-test 45/45, process-test 0 of 146 failed (2 skipped), Debug, load 3.6-10; `zig build book` builds (128/128), its glossary each word's whole documentation; on this change: the frame and perf gate vs tree6 (`gpu/help1-g`, 1,648 s): 77 frames, 0 differ, gui unit-test 1748/1752 (no failure the base has not), perfab PASS (pictures identical in 10 runs, corpus2x -0.002%), perfops 120 of 121 within 0.1%, the one over the base's own (`open on small` +0.171%, the base's table +0.167%); the cross-builds (macOS, macOS aarch64, FreeBSD) build; the base's own counts here: core-test 941/1107, shell-test 1149/1152 Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/builtins.zig | 9 +- docs/typ/builtins-gui.json | 246 ++++++++++++++++++++--------------------- docs/typ/builtins-tui.json | 2 +- test/process/tty_boot.zig | 72 ++---------- test/process/tty_terminals.zig | 2 +- test/snapshots/builtins.golden | 133 ++++++++++++---------- test/snapshots/leader.golden | 194 ++++++++++++++++++++------------ test/snapshots/ttyhelp.golden | 30 ++--- 8 files changed, 352 insertions(+), 336 deletions(-) (limited to 'test') diff --git a/core/builtins.zig b/core/builtins.zig index dfa0b534..692d4fbf 100644 --- a/core/builtins.zig +++ b/core/builtins.zig @@ -1310,10 +1310,11 @@ pub const Changes = struct { /// /// `Compare [ ...]`: two points or more in their order, each /// one revision (a commit or change id, a bookmark, `master@origin`, `@`): -/// `Compare 9ef6312813 ea63317630 master@origin`. A pair is one change -/// however many lie between its points, its row after its last line `from..to -/// N changes dates`. One set a pane: a later Changes or Compare replaces -/// it. Bare: as bare Changes. +/// `Compare 9ef6312813 ea63317630 master@origin`. A pair is drawn as one +/// change however many lie between its points; after its last line, its row: +/// the two points, how many changes lie between them, their first and last +/// days. One set a pane: a later Changes or Compare replaces it. Bare: as +/// bare Changes. pub const Compare = struct { pub const takes_arg = true; pub const run = @import("jj.zig").compareWord; diff --git a/docs/typ/builtins-gui.json b/docs/typ/builtins-gui.json index 82d5e279..4f39f88c 100644 --- a/docs/typ/builtins-gui.json +++ b/docs/typ/builtins-gui.json @@ -1,125 +1,125 @@ [ - {"name": "Addon", "leader": null, "also": [], "arg": true, "scope": "root", "setting": false, "choices": null, "doc": "Addons, the libraries that bring kinds of pane: `Addon load `, `Addon unload `, `Addon reload `; bare, the kinds here."}, - {"name": "Adopt", "leader": null, "also": [], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Take in the shells of a session that died holding them, each as a terminal pane here: the pardes daemon kept their terminals open."}, - {"name": "Ascii", "leader": "SPC t a", "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "add the printable ASCII bitmaps to the matcher's glyph set"}, - {"name": "At", "leader": null, "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Show a file as it was at revision `rev` (jj), read-only, beside its pane; in such a pane, that file at another revision in its place, or bare, the file."}, - {"name": "Back", "leader": "SPC j o", "also": ["C-o"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Ctrl-o: one step back into the history."}, - {"name": "Build", "leader": "SPC h b", "also": [], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "This build: its version, commit, jj change and build time (a stamped build's: a release or the ~/.local install), the zig that built it, its optimize mode, target, platform, grammars, whether the addons are compiled in, and its dependencies, printed into an output buffer."}, - {"name": "Callees", "leader": "SPC l C", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "List the functions the function under the cursor calls."}, - {"name": "Callers", "leader": "SPC l c", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "List the callers of the function under the cursor."}, - {"name": "Callstack", "leader": "SPC l b", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Show outermost callers first, with signatures and call sites (gc)."}, - {"name": "CallstackDepth", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "Caller levels collected by Callstack, 1 through 64; default 8. Bare, it says the current limit."}, - {"name": "Changelog", "leader": "SPC h c", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "This build's version and what changed to reach it, printed into an output buffer the same way Config prints the live settings."}, - {"name": "Changes", "leader": "SPC t c", "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Pin the changes `revset` names (jj) on a file's pane and show them in this view: a lane each after the line number, a line one added whole green, what the file no longer has drawn where it stood (ghost rows: a line taken away whole red, each change's description after its last line); bare, shown here or not (none pinned yet: `@`)."}, - {"name": "Churn", "leader": "SPC t u", "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Count, for each declaration of a file's pane, the changes in `window` (jj) that touched it, and show it in this view: a heat lane after the line number and a strip by the scroll thumb, the line numbers' grey to the theme's red on a log scale; `window` a revset or a span of time (`3d`, `2w`, `6m`, `1y`); bare, shown here or not (none counted yet: the file's whole history)."}, - {"name": "ClipPaste", "leader": "SPC p", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Paste the system clipboard after the selection."}, - {"name": "ClipPasteBefore", "leader": "SPC P", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Paste the system clipboard before the selection."}, - {"name": "ClipReplace", "leader": "SPC R", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Replace the selection with the system clipboard."}, - {"name": "ClipYank", "leader": "SPC y", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Copy the selection to the system clipboard."}, - {"name": "ClipYankMain", "leader": "SPC Y", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "helix `Y`: the PRIMARY selection alone, where `SPC y` joins every cursor's."}, - {"name": "CodeAction", "leader": "SPC l a", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "List the language server's code actions for the cursor."}, - {"name": "Collapse", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Fold a pane to its tag, or restore its share of the column."}, - {"name": "Compare", "leader": null, "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Pin on a file's pane the file's whole difference between each two of `points` (jj revisions, a blank between, two or more) as one change, however many changes lie between them, and show them in this view as `Changes` shows a change: a lane each, the lines it wrote and took away, its row `from..to N changes dates` after its last line; bare, as bare `Changes`."}, - {"name": "Config", "leader": "SPC f c", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Open the startup file, `init`, in a pane: its pane when it is open, else the file, else a pane of that name for Save to make it and its directory."}, - {"name": "CursorBlink", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "The cursor blinks, solid while typing, on or off."}, - {"name": "Debug", "leader": "SPC t d", "also": ["topbar"], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "A small box of frame statistics at the top right, on or off."}, - {"name": "Def", "leader": null, "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Go to the definition of the symbol under the cursor; with an argument (a 2-1 chord's selection), of that symbol, where it is nearest."}, - {"name": "Del", "leader": "SPC d", "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Close the pane."}, - {"name": "DelAbove", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Close the pane, giving its rows to the pane above it."}, - {"name": "DelBelow", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Close the pane, giving its rows to the pane below it."}, - {"name": "Delcol", "leader": "SPC c d", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Close this column and its panes, refusing once over unsaved text."}, - {"name": "Detach", "leader": "SPC s D", "also": [], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Detach this pardes from its terminal or window, leaving the session running: `pardes attach` (or `pardes-gui attach`) shows it as a client."}, - {"name": "Diagnostics", "leader": "SPC l d", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "List the file's diagnostics from the language server."}, - {"name": "Diff", "leader": null, "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Stack a diff's hunks as a diff viewer shows them, each under its place and the declarations around it, in a +Diff; on a +Diff, show the diff itself as text."}, - {"name": "Down", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Move the keyboard to the pane below, off a tag onto the pane under it."}, - {"name": "Dump", "leader": "SPC s d", "also": ["topbar"], "arg": true, "scope": "root", "setting": false, "choices": null, "doc": "Write the session's panes and layout to the state file, for Restore; `Dump export ` writes them to a file of their own instead."}, - {"name": "DumpConfig", "leader": null, "also": [], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Open the settings in effect, each a word to click, and the startup file's path."}, - {"name": "DumpDir", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "The directory of the state file Dump writes to and Recent is kept in, where a relative Restore name is looked for too; bare, the default."}, - {"name": "DumpThemes", "leader": null, "also": [], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Write the bundled themes into the config directory's themes, to edit."}, - {"name": "Edit", "leader": null, "also": [], "arg": true, "scope": "both", "setting": false, "choices": null, "doc": "acme's Edit: sam's command language over the open text panes, from a tag, a pane ctl or exec, starting in the pane's body."}, - {"name": "Exec", "leader": null, "also": ["tab", "middle-click"], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Execute its argument as a middle click on it would, a builtin or a shell command."}, - {"name": "Exit", "leader": "SPC q", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Quit the editor, refusing once while a pane holds unsaved text: an Exit with nothing edited since discards it."}, - {"name": "Filter", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Recolour a terminal's or a +Pager's program colours to the theme, or show them as sent, flipping between them."}, - {"name": "Find", "leader": "SPC f f", "also": ["topbar"], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "List the files below this pane's directory whose names hold its argument, in a +Search."}, - {"name": "Follow", "leader": "SPC c f", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Emacs's follow-mode: one text across a chain of panes as consecutive pages, each going on where the one before ends, scrolled as one."}, - {"name": "Font", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "The body font, by name or path, and its size."}, - {"name": "Fonts", "leader": "SPC t f", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "List the fonts in a pane, each a word to click."}, - {"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."}, - {"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."}, - {"name": "Grep", "leader": "SPC f g", "also": ["topbar"], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Find's sibling: Find matches file NAMES under this pane's directory, Grep matches the LINES of those files, on the disk engine's worker."}, - {"name": "GripWidth", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "The grip and scrollbar width, as a percent of the theme's rail."}, - {"name": "Help", "leader": "SPC ?", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Open the help: every key and every builtin."}, - {"name": "History", "leader": "SPC f h", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "List the state file's dumps, those Dump made and those every session's end left (dump.dumpExit), the newest first, each as the command that brings it back, `Restore