From 2c13f29da2441d0e0fb11f11bb7a180054030cc9 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 8 Nov 2026 23:28:26 -0300 Subject: tests: the editing snapshot scripts (41: modes, selections, look, search, the language client, diffs, tags) are process cases, test/process/tty_editing.zig, their goldens unchanged; checked against the old runner by two breaks, look's centring a third of the pane down (the same 4 fail in both) and the tty reading a drag as a motion (the same 7), grep the one flake in both, cured by the run alone Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- test/process/tty_editing.zig | 2556 +++++++++++++++++++++++++++++++++- test/snapshots/callstack.snap | 21 - test/snapshots/chordcut.snap | 157 --- test/snapshots/cmdword.snap | 93 -- test/snapshots/diffview.snap | 37 - test/snapshots/dirpane.snap | 27 - test/snapshots/edit.snap | 15 - test/snapshots/fileedit.snap | 42 - test/snapshots/find.snap | 71 - test/snapshots/follow.snap | 20 - test/snapshots/fsearch.snap | 61 - test/snapshots/grep.snap | 61 - test/snapshots/hscroll.snap | 48 - test/snapshots/jumps.snap | 117 -- test/snapshots/look-center.snap | 36 - test/snapshots/look-file-1col.snap | 18 - test/snapshots/look-file.snap | 19 - test/snapshots/lookloaded.snap | 48 - test/snapshots/lookpanes.snap | 95 -- test/snapshots/lookrange.snap | 74 - test/snapshots/lsp-client-edit.snap | 35 - test/snapshots/lsp-client.snap | 40 - test/snapshots/lsp-rename-files.snap | 29 - test/snapshots/lsp-rename.snap | 27 - test/snapshots/lsp.snap | 57 - test/snapshots/lspcomplete.snap | 157 --- test/snapshots/lspcompletemoved.snap | 33 - test/snapshots/lspdebug.snap | 45 - test/snapshots/lsprelpath.snap | 76 - test/snapshots/modal.snap | 53 - test/snapshots/multicursor.snap | 46 - test/snapshots/pipe.snap | 16 - test/snapshots/scrolloff.snap | 43 - test/snapshots/selarg.snap | 58 - test/snapshots/selregex.snap | 56 - test/snapshots/stepgrain.snap | 50 - test/snapshots/tag.snap | 49 - test/snapshots/tagcmd.snap | 41 - test/snapshots/tagnav.snap | 120 -- test/snapshots/tagpath.snap | 56 - test/snapshots/wrap.snap | 80 -- test/snapshots/yankpaste.snap | 37 - 42 files changed, 2555 insertions(+), 2265 deletions(-) delete mode 100644 test/snapshots/callstack.snap delete mode 100644 test/snapshots/chordcut.snap delete mode 100644 test/snapshots/cmdword.snap delete mode 100644 test/snapshots/diffview.snap delete mode 100644 test/snapshots/dirpane.snap delete mode 100644 test/snapshots/edit.snap delete mode 100644 test/snapshots/fileedit.snap delete mode 100644 test/snapshots/find.snap delete mode 100644 test/snapshots/follow.snap delete mode 100644 test/snapshots/fsearch.snap delete mode 100644 test/snapshots/grep.snap delete mode 100644 test/snapshots/hscroll.snap delete mode 100644 test/snapshots/jumps.snap delete mode 100644 test/snapshots/look-center.snap delete mode 100644 test/snapshots/look-file-1col.snap delete mode 100644 test/snapshots/look-file.snap delete mode 100644 test/snapshots/lookloaded.snap delete mode 100644 test/snapshots/lookpanes.snap delete mode 100644 test/snapshots/lookrange.snap delete mode 100644 test/snapshots/lsp-client-edit.snap delete mode 100644 test/snapshots/lsp-client.snap delete mode 100644 test/snapshots/lsp-rename-files.snap delete mode 100644 test/snapshots/lsp-rename.snap delete mode 100644 test/snapshots/lsp.snap delete mode 100644 test/snapshots/lspcomplete.snap delete mode 100644 test/snapshots/lspcompletemoved.snap delete mode 100644 test/snapshots/lspdebug.snap delete mode 100644 test/snapshots/lsprelpath.snap delete mode 100644 test/snapshots/modal.snap delete mode 100644 test/snapshots/multicursor.snap delete mode 100644 test/snapshots/pipe.snap delete mode 100644 test/snapshots/scrolloff.snap delete mode 100644 test/snapshots/selarg.snap delete mode 100644 test/snapshots/selregex.snap delete mode 100644 test/snapshots/stepgrain.snap delete mode 100644 test/snapshots/tag.snap delete mode 100644 test/snapshots/tagcmd.snap delete mode 100644 test/snapshots/tagnav.snap delete mode 100644 test/snapshots/tagpath.snap delete mode 100644 test/snapshots/wrap.snap delete mode 100644 test/snapshots/yankpaste.snap diff --git a/test/process/tty_editing.zig b/test/process/tty_editing.zig index 8d125aeb..72cbb573 100644 --- a/test/process/tty_editing.zig +++ b/test/process/tty_editing.zig @@ -1,3 +1,2557 @@ //! The tty frontend's own cases (test/tty.zig), editing: modes, selections, look, search, the language client, diffs. +const std = @import("std"); +const Tty = @import("../tty.zig").Tty; -pub const cases = .{}; +pub const cases = .{ + .{ "tty editing: edit", edit }, + .{ "tty editing: fileedit", fileedit }, + .{ "tty editing: modal", modal }, + .{ "tty editing: multicursor", multicursor }, + .{ "tty editing: selregex", selregex }, + .{ "tty editing: yankpaste", yankpaste }, + .{ "tty editing: pipe", pipe }, + .{ "tty editing: chordcut", chordcut }, + .{ "tty editing: selarg", selarg }, + .{ "tty editing: find", find }, + .{ "tty editing: fsearch", fsearch }, + .{ "tty editing: grep", grep }, + .{ "tty editing: stepgrain", stepgrain }, + .{ "tty editing: look-center", look_center }, + .{ "tty editing: look-file", look_file }, + .{ "tty editing: look-file-1col", look_file_1col }, + .{ "tty editing: lookloaded", lookloaded }, + .{ "tty editing: lookpanes", lookpanes }, + .{ "tty editing: lookrange", lookrange }, + .{ "tty editing: jumps", jumps }, + .{ "tty editing: cmdword", cmdword }, + .{ "tty editing: lsp", lsp }, + .{ "tty editing: lsp-client", lsp_client }, + .{ "tty editing: lsp-client-edit", lsp_client_edit }, + .{ "tty editing: lspcomplete", lspcomplete }, + .{ "tty editing: lspcompletemoved", lspcompletemoved }, + .{ "tty editing: lspdebug", lspdebug }, + .{ "tty editing: lsprelpath", lsprelpath }, + .{ "tty editing: lsp-rename", lsp_rename }, + .{ "tty editing: lsp-rename-files", lsp_rename_files }, + .{ "tty editing: callstack", callstack }, + .{ "tty editing: diffview", diffview }, + .{ "tty editing: dirpane", dirpane }, + .{ "tty editing: scrolloff", scrolloff }, + .{ "tty editing: wrap", wrap }, + .{ "tty editing: hscroll", hscroll }, + .{ "tty editing: follow", follow }, + .{ "tty editing: tagcmd", tagcmd }, + .{ "tty editing: tagnav", tagnav }, + .{ "tty editing: tagpath", tagpath }, + .{ "tty editing: tag", tag }, +}; + +// insert-mode splice: click into a body row, type, escape back to normal +fn edit(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "edit"); + defer t.deinit(); + try t.file("e.txt", "x"); + try t.start(31, 100, &.{ "-n", "3" }); + try t.wait(8000, "e.txt"); + try t.stable(700, 20000); + try t.press("left", "5", 11); + try t.release("left", "5", 11); + try t.stable(400, 8000); + try t.key("i"); + try t.send("hello-insert"); + try t.key("esc"); + try t.settle(100); + try t.stable(500, 8000); + try t.snap("inserted"); + try t.style("inserted"); + try t.done(); +} + +// file panes: modal editing on real content, undo, Save writes to disk +fn fileedit(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "fileedit"); + defer t.deinit(); + try t.lines("f.txt", 20, ""); + try t.start(31, 150, &.{ "-n", "3" }); + try t.wait(8000, "f.txt"); + try t.stable(700, 20000); + try t.press("left", "5", 9); + try t.release("left", "5", 9); + try t.stable(400, 5000); + try t.key("i"); + try t.send("f.txt"); + try t.key("esc"); + try t.settle(100); + try t.press("right", "6", 9); + try t.release("right", "6", 9); + try t.wait(10000, "line 3"); + try t.stable(700, 15000); + // edit line 1: click it, insert, esc + try t.press("left", "10", 8); + try t.release("left", "10", 8); + try t.stable(400, 5000); + try t.key("i"); + try t.send("EDIT''ME"); + try t.key("esc"); + try t.settle(100); + try t.stable(400, 5000); + try t.snap("edited"); + // x-select line 2 and delete it + try t.key("j g h"); + try t.stable(400, 5000); + try t.key("x d"); + try t.stable(400, 5000); + try t.snap("deleted"); + try t.key("u"); + try t.stable(400, 5000); + try t.snap("undone"); + // Save through the file pane's own tag: `:` focuses that same tag and `w` + // selects Save before the ordinary execute key runs it. + try t.key(":"); + try t.stable(400, 5000); + try t.key("w tab"); + try t.stable(600, 8000); + try t.snapFile("saved", "/tmp/pardes-snap/fileedit/cwd/f.txt"); + try t.done(); +} + +// helix-modal normal mode: motions, x/v selections, y/d, insert, undo/redo +fn modal(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "modal"); + defer t.deinit(); + try t.file("words.txt", "alpha beta"); + try t.start(31, 100, &.{ "-n", "3" }); + try t.wait(8000, "words.txt"); + try t.stable(700, 20000); + try t.key("c-b"); + try t.stable(600, 8000); + try t.send("printf 'one two three\\nfour five six\\nseven eight nine\\n'"); + try t.key("enter"); + try t.wait(8000, "seven"); + try t.stable(700, 10000); + try t.key("c-b"); + try t.stable(600, 8000); + try t.press("left", "5", 7); + try t.release("left", "5", 7); + try t.stable(400, 5000); + try t.key("g g"); + try t.stable(400, 5000); + try t.snap("top"); + try t.key("j j w"); + try t.stable(400, 5000); + try t.snap("moved"); + try t.key("x"); + try t.stable(400, 5000); + try t.snap("xsel"); + try t.style("xsel"); + try t.key("x"); + try t.stable(400, 5000); + try t.snap("xsel2"); + try t.key("y"); + try t.stable(400, 5000); + try t.snap("yanked"); + try t.key("v j l"); + try t.stable(400, 5000); + try t.snap("vsel"); + try t.style("vsel"); + try t.key("esc"); + try t.settle(100); + try t.key("i"); + try t.send("TYPED"); + try t.key("esc"); + try t.settle(100); + try t.stable(400, 5000); + try t.snap("typed"); + try t.key("u"); + try t.stable(400, 5000); + try t.snap("undone"); + try t.key("U"); + try t.stable(400, 5000); + try t.snap("redone"); + try t.key("g e"); + try t.stable(400, 5000); + try t.snap("bottom"); + try t.done(); +} + +// MULTIPLE CURSORS on a real file pane. The differential suite (hxdiff) proves +// the model against a real helix but is headless, so this is the part it cannot +// see: that every range is actually on screen, that the primary reads +// differently from the others, and that ONE keystroke edits at all of them. +fn multicursor(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "multicursor"); + defer t.deinit(); + try t.lines("f.txt", 12, ""); + try t.start(31, 150, &.{ "-n", "3" }); + try t.wait(8000, "f.txt"); + try t.stable(700, 20000); + // open f.txt in the left pane (type its name, right-click to Look) + try t.press("left", "5", 9); + try t.release("left", "5", 9); + try t.stable(400, 5000); + try t.key("i"); + try t.send("f.txt"); + try t.key("esc"); + try t.settle(100); + try t.press("right", "6", 9); + try t.release("right", "6", 9); + try t.wait(10000, "line 3"); + try t.stable(700, 15000); + // top of the file, then C C: three cursors, one per line, primary on line 3 + try t.key("g g"); + try t.stable(400, 5000); + try t.key("C C"); + try t.stable(400, 5000); + try t.snap("three-cursors"); + // the colours ARE the feature here: the primary's cell against the two dimmer + // ones, each with its own bright cursor cell + try t.style("three-cursors"); + // one keystroke, three edits + try t.key("i"); + try t.send(">>"); + try t.key("esc"); + try t.settle(100); + try t.stable(400, 5000); + try t.snap("edited-at-three"); + // a selection per cursor: e selects to the end of the first word at each + try t.key("g h w"); + try t.stable(400, 5000); + try t.snap("three-selections"); + try t.style("three-selections"); + // `,` drops back to the primary alone; the two dim highlights must vanish + try t.key(","); + try t.stable(400, 5000); + try t.snap("keep-primary"); + try t.style("keep-primary"); + try t.done(); +} + +// Interactive regex selection (`s` / `S`) and the comment toggle, on a real +// file pane. hxdiff pins what they DO against a real helix, but it is headless, +// so this is the half it cannot see: the prompt living in the TAG rather than a +// popup, the matches lighting up under a pattern as it is typed, Esc putting +// back what was there, and Ctrl-c using the token this file's EXTENSION asks +// for — `//`, where a buffer with no language would get `#`. +fn selregex(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "selregex"); + defer t.deinit(); + try t.file("m.zig", "const one = 1;\nconst two = 2;\nconst three = 3;\n"); + // wide on purpose: the whole point of this script is a tag long enough to hold + // the marker AND the pattern, and a narrow pane simply truncates it away + try t.start(25, 160, &.{"m.zig"}); + try t.wait(8000, "m.zig"); + try t.stable(700, 20000); + try t.key("g g"); + try t.stable(400, 5000); + // `%` takes the whole file, `s` arms the regex input: the marker goes into the + // tag tail after the path, and the pane is in insert mode ON THE TAG — the + // same one-line editor `/` and Find use, and nothing has moved in the body yet. + try t.key("%"); + try t.key("s"); + try t.stable(400, 5000); + try t.snap("prompt-armed"); + // ...and now the point: the selection follows the pattern as it is typed. Three + // `const` runs light up with Enter nowhere near, and the colours ARE the + // feature — the primary bright, the other two dim, each with its own cursor. + try t.send("const"); + try t.stable(400, 5000); + try t.snap("preview"); + try t.style("preview"); + try t.key("enter"); + try t.stable(400, 5000); + try t.snap("three-selected"); + try t.style("three-selected"); + // a second `s` narrows the three to one `t` apiece... + try t.key("s"); + try t.send("t"); + try t.stable(400, 5000); + try t.snap("narrowed"); + // the grid text cannot show a selection, so this is where the styles carry the + // whole point: three one-cell ranges here, three five-cell ones after the Esc + try t.style("narrowed"); + // ...and Esc throws that away for the selection the prompt opened on, which is + // free: the preview is re-derived from that snapshot on every keystroke, so + // cancelling is just applying the empty pattern. + try t.key("esc"); + try t.settle(100); + try t.stable(400, 5000); + try t.snap("esc-restores"); + try t.style("esc-restores"); + // Ctrl-c comments every line the three cursors touch — one decision for the + // whole selection, not one per cursor — and again to take it back off. + try t.key("c-c"); + try t.stable(400, 5000); + try t.snap("commented"); + try t.key("c-c"); + try t.stable(400, 5000); + try t.snap("uncommented"); + try t.done(); +} + +// y -> p round-trips through the core's own yank register (regression: p used +// to request the SYSTEM clipboard via OSC 52, which plain terminals — and this +// harness — never answer, so paste silently no-oped). Pins helix placement: +// a linewise yank (x) pastes as whole lines below (p) / above (P), a charwise +// yank (v) splices inline after the selection. +fn yankpaste(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "yankpaste"); + defer t.deinit(); + try t.lines("f.txt", 5, ""); + try t.start(31, 100, &.{"f.txt"}); + try t.wait(8000, "Newcol Joincol"); + try t.wait(8000, "line 5"); + try t.stable(700, 20000); + // linewise: x-select line 2, yank, move down, paste below line 3 + try t.press("left", "8", 5); + try t.release("left", "8", 5); + try t.stable(400, 5000); + try t.key("x y j p"); + try t.stable(400, 5000); + try t.snap("linewise-below"); + // P from the pasted line: its copy lands above + try t.key("x y P"); + try t.stable(400, 5000); + try t.snap("linewise-above"); + // charwise: v-select two chars of line 1, yank, paste splices after them + try t.press("left", "8", 4); + try t.release("left", "8", 4); + try t.stable(400, 5000); + try t.key("v l y p"); + try t.stable(400, 5000); + try t.snap("charwise-inline"); + // a BLANK line yanks as a bare "\n": the block is empty, lineCount says 0 + // lines, and every `n - 1` in the linewise paste used to underflow — panic on + // y then p. It pastes as one empty line. + try t.key("o"); + try t.key("esc"); + try t.settle(100); + try t.key("y p"); + try t.stable(400, 5000); + try t.snap("blankline"); + try t.done(); +} + +// `|`: visible tag prompt, native async shell filter, and one-step undo. +fn pipe(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "pipe"); + defer t.deinit(); + try t.file("pipe.txt", "alpha beta\ngamma delta"); + try t.start(13, 180, &.{"pipe.txt"}); + try t.wait(8000, "alpha beta"); + try t.stable(700, 20000); + try t.key("x |"); + try t.send("tr a-z A-Z"); + try t.stable(300, 5000); + try t.snap("prompt"); + try t.key("enter"); + try t.wait(8000, "ALPHA BETA"); + try t.stable(500, 8000); + try t.snap("filtered"); + try t.key("u"); + try t.stable(400, 5000); + try t.snap("undone"); + try t.done(); +} + +// acme 1-2/1-3 chords in a file pane: with the left button holding a drag +// selection, tapping middle Cuts it into the snarf (yank) register; tapping +// right Pastes the register (replacing the selection, or splicing at a bare +// click point); cut then paste in ONE hold nets out to copy/Snarf. The left +// release after a chord is inert (the cursor stays where the op left it). +// Also the cancel chords: tapping right during a middle (execute) drag or +// left during a right (look) drag cancels the gesture entirely. +fn chordcut(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "chordcut"); + defer t.deinit(); + try t.lines("f.txt", 5, ""); + try t.lines("g.txt", 2, ""); + // The narrow-window fallback splits below the source shell and leaves the + // unrelated right column untouched. Give the caller enough cells that the selected + // `echo B''OO g.txt` remains one displayed row; this test is about chords, not + // soft-wrap traversal. + try t.start(31, 120, &.{ "-n", "3" }); + try t.wait(8000, "f.txt"); + try t.stable(700, 20000); + // open f.txt: click a body spot, type the name, look it + try t.press("left", "5", 9); + try t.release("left", "5", 9); + try t.stable(400, 5000); + try t.key("i"); + try t.send("f.txt"); + try t.key("esc"); + try t.settle(100); + try t.stable(400, 5000); + try t.press("right", "6", 9); + try t.release("right", "6", 9); + try t.wait(10000, "line 3"); + try t.stable(700, 15000); + try t.snap("opened"); + // 1-2 Cut: left-drag over "line" on line 2, tap middle while holding + try t.press("left", "8", 10); + try t.drag("left", "11", 10); + try t.press("middle", "11", 10); + try t.release("middle", "11", 10); + try t.release("left", "11", 10); + try t.stable(400, 5000); + try t.snap("cut"); + // 1-2 then 1-3 in one hold = copy: line 3 keeps its text, register loaded + try t.press("left", "8", 11); + try t.drag("left", "11", 11); + try t.press("middle", "11", 11); + try t.release("middle", "11", 11); + try t.press("right", "11", 11); + try t.release("right", "11", 11); + try t.release("left", "11", 11); + try t.stable(400, 5000); + try t.snap("copied"); + // 1-3 at a bare click point: hold left past the end of line 4, tap right — + // the register splices in at the click + try t.press("left", "14", 12); + try t.press("right", "14", 12); + try t.release("right", "14", 12); + try t.release("left", "14", 12); + try t.stable(400, 5000); + try t.snap("pointpaste"); + // 1-3 over a fresh selection replaces it with the register + try t.press("left", "9", 13); + try t.drag("left", "11", 13); + try t.press("right", "11", 13); + try t.release("right", "11", 13); + try t.release("left", "11", 13); + try t.stable(400, 5000); + try t.snap("replaced"); + // arm the cancel tests: append `echo B''OO g.txt` to line 2 + try t.press("left", "10", 10); + try t.release("left", "10", 10); + try t.stable(400, 5000); + try t.key("i"); + try t.send("echo B''OO g.txt"); + try t.key("esc"); + try t.settle(100); + try t.stable(400, 5000); + // 2-3 cancel (acme textselect2): tap right during the middle execute-drag + // over `echo B''OO` — the command never runs (no BOO anywhere) + try t.press("middle", "10", 10); + try t.drag("middle", "19", 10); + try t.press("right", "19", 10); + try t.release("right", "19", 10); + try t.release("middle", "19", 10); + try t.stable(700, 8000); + try t.snap("cancelexec"); + // the same drag released clean proves the word was live: BOO appears + try t.press("middle", "10", 10); + try t.drag("middle", "19", 10); + try t.release("middle", "19", 10); + try t.wait(10000, "BOO"); + try t.stable(700, 10000); + try t.snap("execafter"); + // 3-1 cancel (acme textselect3): tap left during the right look-drag over + // g.txt — no pane opens + try t.press("right", "21", 10); + try t.drag("right", "25", 10); + try t.press("left", "25", 10); + try t.release("left", "25", 10); + try t.release("right", "25", 10); + try t.stable(700, 8000); + try t.snap("cancellook"); + // the same look released clean opens g.txt + try t.press("right", "21", 10); + try t.drag("right", "25", 10); + try t.release("right", "25", 10); + try t.wait(10000, "line 2"); + try t.stable(700, 10000); + try t.snap("lookafter"); + // a fresh left click dismisses the chord's leftover selection instead of + // dragging the anchored span to the click: copy `line` on g.txt line 1 + // (styled snap shows the selection), then click the next row (it's gone) + try t.press("left", "8", 24); + try t.drag("left", "11", 24); + try t.press("middle", "11", 24); + try t.release("middle", "11", 24); + try t.press("right", "11", 24); + try t.release("right", "11", 24); + try t.release("left", "11", 24); + try t.stable(400, 5000); + try t.style("chordsel"); + try t.press("left", "8", 25); + try t.release("left", "8", 25); + try t.stable(400, 5000); + try t.style("clickdismiss"); + // g.txt opened under the lower shell's text and left it three rows: close it, + // and the shell grows back into its rows, for what follows to run in + try t.press("middle", "59", 23); + try t.release("middle", "59", 23); + try t.stable(700, 15000); + // tty paste chord: over a mouse-listening app B1 is the app's, so the + // chord's B1 holds Shift (B3 is pardes's either way); the app gets a click + // where the text goes (SGR, body-relative) then the register between + // bracketed-paste markers — cat -v prints the received bytes visibly + try t.press("left", "35", 23); + try t.release("left", "35", 23); + try t.stable(400, 5000); + try t.key("c-b"); + try t.stable(600, 8000); + try t.send("stty -icanon -echo; printf '\\x1b[?2004h\\x1b[?1000h\\x1b[?1006h'; cat -v"); + try t.key("enter"); + try t.stable(700, 8000); + try t.press("shift-left", "40", 25); + try t.press("right", "40", 25); + try t.release("right", "40", 25); + try t.release("shift-left", "40", 25); + try t.stable(700, 8000); + try t.snap("ttyprobe"); + // a plain prompt (mouse modes off) gets no click bytes — just the paste; + // readline's own 2004 strips the markers and inserts the register text + try t.key("c-c"); + try t.stable(600, 8000); + try t.send("stty sane; printf '\\x1b[?1000l\\x1b[?1006l'"); + try t.key("enter"); + try t.stable(600, 8000); + try t.press("left", "40", 25); + try t.press("right", "40", 25); + try t.release("right", "40", 25); + try t.release("left", "40", 25); + try t.stable(700, 8000); + try t.snap("ttyprompt"); + try t.done(); +} + +// 2-1 chord borrows the argument selection from ANOTHER pane: pane A (left) +// holds the selection, pane B (right) middle-drags the command with no +// selection of its own — the chord's left tap finds A's kept left selection, +// and later A's explicit v selection, and rides it as the argument. +fn selarg(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "selarg"); + defer t.deinit(); + try t.file("s.txt", "x"); + try t.start(31, 100, &.{ "-n", "3" }); + try t.wait(8000, "s.txt"); + try t.stable(700, 20000); + // pane A (left, active at boot): print the two argument words + try t.key("c-b"); + try t.stable(600, 8000); + try t.send("clear; printf 'ZZARG ZZVEE\\n'"); + try t.key("enter"); + try t.wait(8000, "ZZVEE"); + try t.stable(700, 15000); + try t.key("c-b"); + try t.stable(600, 8000); + // pane B (top right): create the arg-printing script and show its path + try t.press("left", "60", 7); + try t.release("left", "60", 7); + try t.stable(400, 5000); + try t.key("c-b"); + try t.stable(600, 8000); + try t.send("printf '#!/bin/sh\\necho CHORDARG:\"$1\"\\n' > c.sh; chmod +x c.sh; clear; printf './c.sh\\n'"); + try t.key("enter"); + try t.wait(10000, "./c.sh"); + try t.stable(700, 15000); + try t.key("c-b"); + try t.stable(600, 8000); + // keep a left selection over ZZARG in pane A (this also focuses A) + try t.press("left", "3", 5); + try t.drag("left", "7", 5); + try t.release("left", "7", 5); + try t.stable(400, 5000); + try t.snap("kept"); + // chord in pane B: middle on ./c.sh + left tap (B has NO selection: the + // argument comes from pane A's kept left selection) + middle release runs + try t.press("middle", "55", 5); + try t.press("left", "55", 5); + try t.release("middle", "55", 5); + try t.release("left", "55", 5); + try t.wait(10000, "CHORDARG:ZZARG"); + try t.stable(700, 10000); + try t.snap("crosspane"); + // now an explicit modal selection: plain-click ZZVEE in A (drops A's kept + // left selection), select it with v e, chord in B again + try t.press("left", "9", 5); + try t.release("left", "9", 5); + try t.stable(400, 5000); + try t.send("ve"); + try t.stable(400, 5000); + try t.press("middle", "55", 5); + try t.press("left", "55", 5); + try t.release("middle", "55", 5); + try t.release("left", "55", 5); + try t.wait(10000, "CHORDARG:ZZVEE"); + try t.stable(700, 10000); + try t.snap("vselarg"); + try t.done(); +} + +// SPC f f: a query pane under the pane (Query.zig), line 1 `Find `, typed +// into. The files below the pane's directory are listed once, on the disk +// engine's worker (rg --files when it is on PATH, else the sorted walk: both +// pass over .git), and each key scores them fuzzily (pick's scorer), the best +// first, the matched letters tinted. The current one is shown in the +// +Preview under the query pane, born with it so nothing moves later; +// Ctrl-n / Ctrl-p step it, never the pointer. Enter makes the preview the +// file's pane where it stands. Esc while typing closes the query pane and +// gives its rows back. A query that matches nothing is a count of 0, not an +// exit. B2 on `Find` with a selection asks with that word, the keyboard +// staying in the text. +fn find(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "find"); + defer t.deinit(); + try t.dir("sub"); + try t.dir("sub/nest"); + try t.dir(".git"); + try t.file("here.txt", "Find zqm"); + try t.file("zqmark-alpha.txt", "alpha body"); + try t.file("sub/ZQMARK-beta.txt", "beta body"); + try t.file("sub/nest/zqmark-gamma.txt", "gamma body"); + try t.file("other.txt", "nothing to match here"); + try t.file(".git/zqmark-hidden.txt", "hidden body"); + 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 + try t.key("space"); + try t.key("f"); + try t.stable(400, 5000); + try t.snap("group"); + // the second f opens the query pane: every file listed, line 1 `Find ` + try t.key("f"); + try t.wait(10000, "zqmark-alpha.txt"); + try t.stable(700, 15000); + try t.snap("armed"); + try t.send("zqm"); + try t.stable(700, 15000); + try t.snap("typing"); + // the next one current, its text in the preview + try t.key("c-n"); + try t.wait(10000, "beta body"); + try t.stable(700, 15000); + try t.snap("next"); + // Enter: the preview is that file's pane now, where it stood + try t.key("enter"); + try t.stable(700, 15000); + try t.snap("promoted"); + // a second Find from here.txt reuses its query pane; nothing found is 0 + try t.press("left", "8", 4); + try t.release("left", "8", 4); + try t.stable(400, 5000); + try t.key("space"); + try t.key("f"); + try t.key("f"); + try t.send("zzqq"); + try t.stable(700, 15000); + try t.snap("nomatch"); + // Esc: the kept rows of the last query are back + try t.key("esc"); + try t.settle(100); + try t.stable(700, 15000); + try t.snap("cancel"); + // B2 on Find with `zqm` selected in here.txt: the query pane under it, the + // keyboard still in here.txt + try t.press("left", "13", 4); + try t.drag("left", "15", 4); + try t.release("left", "15", 4); + try t.stable(400, 5000); + try t.press("middle", "@Find", 1); + try t.release("middle", "@Find", 1); + try t.wait(10000, "Find zqm"); + try t.stable(700, 15000); + try t.snap("topbar"); + try t.done(); +} + +// `/` in a file: its query pane under it (Query.zig), line 1 `/` and the +// pattern, typed into; nothing on the notice band. Each key searches the +// file again (a regex, any case unless it has a capital): every match is +// tinted and ticked on the scroll rail, the first at or after the cursor +// selected and in view, and the rows under line 1 are the lines holding a +// match, a line number in the gutter. Ctrl-n steps while typing; Enter puts +// the keyboard on the match, the pattern in `/`, and keeps the rows as text; +// n / N then step the matches in the file, round the end without a word. A +// later `/` reuses the pane; Esc while typing brings the kept rows back. A +// pattern that matches nothing is a count of 0, not an exit. +fn fsearch(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "fsearch"); + defer t.deinit(); + try t.file("g.txt", "l1\nMARK a\nl3\nl4\nl5\nMARK b\nl7\nl8\nl9\nMARK c\nl11\nl12"); + // Builtins announce themselves by default, and an announcement is a band at + // the top of the body -- which moves every row this script clicks. What the + // verbs do is what is under test, not the announcement. + try t.config("Verbose off"); + try t.start(31, 180, &.{ "-n", "3" }); + try t.wait(8000, "g.txt"); + try t.stable(700, 20000); + // open g.txt: type the name in the shell, look it (as in look-file.snap) + try t.press("left", "5", 9); + try t.release("left", "5", 9); + try t.stable(400, 5000); + try t.key("i"); + try t.send("g.txt"); + try t.key("esc"); + try t.settle(100); + try t.stable(400, 5000); + try t.press("right", "6", 9); + try t.release("right", "6", 9); + try t.wait(10000, "MARK a"); + try t.stable(700, 15000); + try t.snap("opened"); + try t.key("/"); + try t.stable(400, 5000); + try t.snap("slash"); + try t.send("MARK"); + try t.stable(400, 5000); + try t.snap("typing"); + try t.style("typing"); + try t.key("c-n"); + try t.stable(400, 5000); + try t.snap("ctrln"); + try t.key("enter"); + try t.stable(700, 10000); + try t.snap("landed"); + try t.send("n"); + try t.stable(400, 5000); + try t.snap("n"); + try t.send("N"); + try t.stable(400, 5000); + try t.snap("N"); + try t.key("/"); + try t.send("zz"); + try t.key("esc"); + try t.settle(100); + try t.stable(400, 5000); + try t.snap("cancel"); + try t.key("/"); + try t.send("zzqq"); + try t.stable(700, 10000); + try t.snap("nomatch"); + try t.done(); +} + +// The Grep builtin (topbar word, `SPC f g`): the query pane under the pane +// that asked, line 1 `Grep ` and the text, the lines of the files below its +// directory holding it (literally, any case unless it has a capital), on the +// disk engine's worker once the typing pauses: rg --json when it is on PATH, +// else the sorted walk. The rows sit under their file's name, a line number +// in the gutter. A hit in a file an open pane shows is shown there; one in a +// file nothing shows, in the +Preview under the query pane, which Enter makes +// the file's pane. A query that matches nothing is a count of 0, and Esc +// while typing brings the kept rows back. +fn grep(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "grep"); + defer t.deinit(); + try t.dir("sub"); + try t.file("a.txt", "hello TARGET one\nnothing here\nlast TARGET line"); + try t.file("sub/b.txt", "deep\nTARGET inside sub"); + try t.file("noise.txt", "nothing to see"); + try t.config("Verbose off"); + try t.start(31, 180, &.{ "-n", "3" }); + try t.wait(8000, "a.txt"); + try t.stable(700, 20000); + try t.press("left", "5", 9); + try t.release("left", "5", 9); + try t.stable(400, 5000); + try t.key("i"); + try t.send("a.txt"); + try t.key("esc"); + try t.settle(100); + try t.stable(400, 5000); + try t.press("right", "6", 9); + try t.release("right", "6", 9); + try t.wait(10000, "hello TARGET"); + try t.stable(700, 15000); + try t.snap("opened"); + // middle-click Grep on the topbar: the query pane under a.txt, typed into + try t.press("middle", "@Grep", 1); + try t.release("middle", "@Grep", 1); + try t.stable(400, 5000); + try t.send("TARGET"); + // three lines (the pane is short: its count says how many) + try t.wait(10000, "+Search 1/3"); + try t.stable(700, 15000); + try t.snap("typing"); + // a.txt's hits are shown in a.txt; sub/b.txt's in the preview + try t.key("c-n"); + try t.stable(700, 15000); + try t.snap("second"); + try t.key("c-n"); + try t.wait(10000, "deep"); + try t.stable(700, 15000); + try t.snap("preview"); + try t.key("enter"); + try t.stable(700, 15000); + try t.snap("opened-hit"); + try t.key("space"); + try t.key("f"); + try t.key("g"); + try t.stable(400, 5000); + try t.send("zzqq"); + try t.stable(700, 10000); + try t.snap("nomatch"); + try t.key("esc"); + try t.settle(100); + try t.stable(400, 5000); + try t.snap("esc"); + try t.done(); +} + +// ONE PRESS, ONE ROW. A query pane's rows are one a line with a hit, the +// hit's line under a gutter number, and Ctrl-n / Ctrl-p (typing on line 1) +// step them a row at a time, round the end: row 2 below matched on a line +// that mentions `sub/b.txt`, and the step does not stop on that word, as the +// old word-grained walk did; the fourth press wraps back to row 1. +// +// A path with a BLANK in it is one name: `two words.txt` is found whole by +// Find and Enter opens exactly it. +fn stepgrain(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "stepgrain"); + defer t.deinit(); + try t.dir("sub"); + try t.file("a.txt", "hello ZQMARK one\nsee also sub/b.txt for ZQMARK two"); + try t.file("sub/b.txt", "ZQMARK inside sub"); + try t.run("touch 'two words.txt'"); + try t.start(31, 150, &.{"a.txt"}); + try t.wait(8000, "hello ZQMARK"); + try t.stable(700, 20000); + // Grep from the leader: three hits, under their files, the empty file + // contributing none. Row 2 is the one whose TEXT holds a path. + try t.key("space"); + try t.key("f"); + try t.key("g"); + try t.stable(400, 5000); + try t.send("ZQMARK"); + try t.wait(10000, "ZQMARK inside sub"); + try t.stable(700, 15000); + try t.snap("results"); + try t.key("c-n"); + try t.stable(400, 5000); + try t.snap("step-row2"); + try t.style("step-row2"); + try t.key("c-n"); + try t.stable(400, 5000); + try t.snap("step-row3"); + try t.key("c-n"); + try t.stable(400, 5000); + try t.snap("step-wrap"); + try t.key("esc"); + try t.settle(100); + try t.stable(400, 5000); + // Find `words`: the name with a blank in it, whole + try t.key("space"); + try t.key("f"); + try t.key("f"); + try t.send("words"); + try t.wait(10000, "two words.txt"); + try t.stable(700, 15000); + try t.snap("blank-in-path"); + try t.style("blank-in-path"); + try t.key("enter"); + try t.stable(700, 15000); + try t.snap("blank-opened"); + try t.done(); +} + +// a look on path:NN opens the file with the target line CENTERED in the body +// (scroll = line - body/2): fresh open at a deep line, then dedup re-looks at +// the same path re-center the existing pane, and a look near line 1 clamps +// the scroll at 0 (no negative scroll) +fn look_center(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "look-center"); + defer t.deinit(); + try t.lines("big.txt", 200, ""); + try t.start(31, 150, &.{ "-n", "3" }); + try t.wait(8000, "big.txt"); + try t.stable(700, 20000); + try t.press("left", "5", 9); + try t.release("left", "5", 9); + try t.stable(400, 5000); + try t.key("i"); + try t.send("big.txt:100 big.txt:150 big.txt:2"); + try t.key("esc"); + try t.settle(100); + try t.stable(400, 5000); + try t.press("right", "7", 9); + try t.release("right", "7", 9); + try t.stable(700, 15000); + try t.snap("center-open"); + // The narrow-window split keeps the source shell above the new file. Use the + // unchanged right-hand shell for the remaining references, so they stay visible. + try t.press("left", "80", 9); + try t.release("left", "80", 9); + try t.key("i"); + try t.send("big.txt:150 big.txt:2"); + try t.key("esc"); + try t.stable(400, 5000); + try t.press("right", "82", 9); + try t.release("right", "82", 9); + try t.stable(700, 15000); + try t.snap("center-dedup"); + try t.press("right", "94", 9); + try t.release("right", "94", 9); + try t.stable(700, 15000); + try t.snap("center-clamp"); + try t.done(); +} + +// right-click look on a typed path:NN opens a file pane scrolled to the line; +// Enter chord on the same path focuses the existing pane (dedup) +fn look_file(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "look-file"); + defer t.deinit(); + try t.lines("big.txt", 60, ""); + try t.start(31, 150, &.{ "-n", "3" }); + try t.wait(8000, "big.txt"); + try t.stable(700, 20000); + try t.press("left", "5", 9); + try t.release("left", "5", 9); + try t.stable(400, 5000); + try t.key("i"); + try t.send("big.txt:40"); + try t.key("esc"); + try t.settle(100); + try t.stable(400, 5000); + try t.press("right", "7", 9); + try t.release("right", "7", 9); + try t.stable(700, 15000); + try t.snap("file-open"); + try t.style("file-open"); + try t.done(); +} + +// single narrow column (-n 1): the first document splits below its source +// shell, like Term. A new column would require at least 200 cells of width. +fn look_file_1col(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "look-file-1col"); + defer t.deinit(); + try t.lines("big.txt", 60, ""); + try t.start(31, 100, &.{ "-n", "1" }); + try t.wait(8000, "big.txt"); + try t.stable(700, 20000); + try t.press("left", "5", 9); + try t.release("left", "5", 9); + try t.stable(400, 5000); + try t.key("i"); + try t.send("big.txt:40"); + try t.key("esc"); + try t.settle(100); + try t.stable(400, 5000); + try t.press("right", "7", 9); + try t.release("right", "7", 9); + try t.stable(700, 15000); + try t.snap("file-open-1col"); + try t.done(); +} + +// a look matches an already-LOADED pane before touching the filesystem: open +// big.txt:40 from a look, rm the file on disk, then look big.txt:10 — the +// loaded pane focuses and recenters even though realpath now fails. (This +// fs-last ordering is what lets the fs-less web build focus dump panes.) +fn lookloaded(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "lookloaded"); + defer t.deinit(); + try t.lines("big.txt", 60, ""); + try t.start(31, 100, &.{ "-n", "3" }); + try t.wait(8000, "big.txt"); + try t.stable(700, 20000); + try t.press("left", "5", 9); + try t.release("left", "5", 9); + try t.stable(400, 5000); + try t.key("i"); + try t.send("big.txt:40 big.txt:10"); + try t.key("esc"); + try t.settle(100); + try t.stable(400, 5000); + try t.press("right", "7", 9); + try t.release("right", "7", 9); + try t.stable(700, 15000); + try t.snap("file-open"); + // Use the unrelated right-hand shell to remove the file: the source shell now + // stays above its file and is only a few rows tall. + try t.press("left", "70", 12); + try t.release("left", "70", 12); + try t.stable(400, 5000); + try t.key("c-b"); + try t.stable(600, 8000); + try t.send("rm big.txt; echo GO''NE"); + try t.key("enter"); + try t.wait(8000, "GONE"); + try t.stable(700, 15000); + try t.key("c-b"); + try t.stable(600, 8000); + try t.snap("removed"); + // look big.txt:10: nothing on disk, but the pane is loaded — it focuses and + // recenters on line 10 (before this change: realpath fails, look no-ops) + // Put a fresh reference in the right-hand shell, then look it. This ensures the + // gesture hits the missing path rather than empty space after source resizing. + try t.press("left", "55", 9); + try t.release("left", "55", 9); + try t.key("i"); + try t.send("big.txt:10"); + try t.key("esc"); + try t.stable(400, 5000); + try t.press("right", "57", 9); + try t.release("right", "57", 9); + try t.stable(700, 15000); + try t.snap("look-noFS"); + try t.done(); +} + +// a look resolves against EVERY open pane's directory, in access order: the +// pane the click came from first, then the rest most-recently-focused first, +// and only a word NO directory holds falls through to a search. Two dirs +// (alpha, beta) hold same-named files and the shell's own cwd holds none of +// them, so every look below would have been a search before. alpha's pane +// is its directory window (a look at a directory opens a pane listing it), +// whose directory is alpha. +fn lookpanes(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "lookpanes"); + defer t.deinit(); + try t.dir("alpha"); + try t.dir("beta"); + try t.file("zzboot.txt", "x"); + try t.file("alpha/amark.txt", "a"); + try t.file("alpha/zqonly.txt", "ONLY-IN-ALPHA"); + try t.file("alpha/pick.txt", "PICK-FROM-ALPHA"); + try t.file("alpha/twin.txt", "TWIN-FROM-ALPHA"); + try t.file("alpha/both.txt", "BOTH-FROM-ALPHA"); + try t.file("beta/pick.txt", "PICK-FROM-BETA"); + try t.file("beta/twin.txt", "TWIN-FROM-BETA"); + try t.file("beta/both.txt", "BOTH-FROM-BETA"); + // the file argument opens a pane whose directory is beta's, and nothing else — + // so the workdir shell every look below falls through is opened with Alt-n + // (`New`/`Newcol` open an empty +New scratch now, and one inheriting beta's + // directory at that) and Alt-c puts it in a column of its own on the right; + // its first line is a word to look FROM that pane + try t.file("beta/bmark.txt", "both.txt\nb-marker"); + // Builtins announce themselves by default, and an announcement is a band at + // the top of the body -- which moves every row this script clicks. What the + // verbs do is what is under test, not the announcement. + try t.config("Verbose off"); + try t.start(51, 130, &.{"beta/bmark.txt"}); + try t.wait(8000, "b-marker"); + try t.stable(700, 20000); + try t.key("a-n"); + try t.key("a-c"); + try t.wait(8000, "zzboot.txt"); + try t.stable(700, 20000); + try t.key("space w h"); + try t.stable(400, 5000); + // an ordinary dir look on the shell's own ls output: alpha's directory pane, + // split below it, which takes the keyboard + try t.press("right", "@alpha", 6); + try t.release("right", "@alpha", 6); + try t.wait(10000, "amark.txt"); + try t.stable(700, 20000); + // type the words to look into what is left of the workdir shell (past its own + // ls output, on the same row: its last row is the resize handle) + try t.press("left", "95", 5); + try t.release("left", "95", 5); + try t.stable(400, 5000); + try t.key("i"); + try t.send("zqonly.txt pick.txt twin.txt"); + try t.key("esc"); + try t.settle(100); + try t.stable(400, 5000); + try t.snap("shells"); + // make the beta pane the most recently focused, so the walk has to pass it + try t.press("left", "10", 5); + try t.release("left", "10", 5); + try t.stable(700, 10000); + // zqonly.txt is only under alpha: the clicked shell's cwd fails, beta fails, + // alpha's directory pane answers. Before, this word became a search. + try t.press("right", "@zqonly.txt", 5); + try t.release("right", "@zqonly.txt", 5); + try t.wait(10000, "ONLY-IN-ALPHA"); + try t.stable(700, 20000); + try t.snap("other-dir"); + // both.txt is in BOTH dirs and alpha is now the most recent (its file pane + // just opened), but the CLICK still wins: looked inside the beta pane it + // opens beta's copy + try t.press("right", "10", 5); + try t.release("right", "10", 5); + try t.wait(10000, "BOTH-FROM-BETA"); + try t.stable(700, 20000); + try t.snap("clicked-wins"); + // from a pane whose own dir holds neither copy the access order decides: + // focus alpha's directory pane (a click on its first row), look pick.txt (in + // both dirs) from the workdir shell -> alpha's + try t.press("left", "@amark.txt", 9); + try t.release("left", "@amark.txt", 9); + try t.stable(700, 10000); + try t.press("right", "@pick.txt", 5); + try t.release("right", "@pick.txt", 5); + try t.wait(10000, "PICK-FROM-ALPHA"); + try t.stable(700, 20000); + try t.snap("mru-alpha"); + // focus the beta pane instead and the same look flips: twin.txt is in both + // dirs, beta is most recent, beta's copy opens + try t.press("left", "10", 5); + try t.release("left", "10", 5); + try t.stable(700, 10000); + try t.press("right", "@twin.txt", 5); + try t.release("right", "@twin.txt", 5); + try t.wait(10000, "TWIN-FROM-BETA"); + try t.stable(700, 20000); + try t.snap("mru-beta"); + try t.style("mru-beta"); + try t.done(); +} + +// RANGED LOOK PATHS. `path:LINE:COL` says where to PARK; a range says what to +// SELECT, and it belongs to the PATH (config.range_sep) rather than to the +// search that is merely the first thing writing one. So this script right- +// clicks the three spellings as ordinary words sitting in a file: +// r.txt:3-5 whole lines 3 through 5 +// r.txt:7:4-9 line 7, columns 4 through 9 +// r.txt:3:2-5:3 line 3 column 2 through line 5 column 3 +// ...and only then presses `/`, whose result rows are exactly this syntax — +// which is how n/N select a hit and Enter lands on it with the matched text +// selected. +// +// `snapstyle` is the assertion that matters: the grid TEXT after a ranged look +// is the same text a plain `:LINE:COL` look leaves, so the selection only shows +// in the styles. +fn lookrange(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "lookrange"); + defer t.deinit(); + try t.file("r.txt", "aaaa\nbbbb\ncccc dccc\ndddd\neeee\nffff\ngg NEEDLE gg\nhhhh NEEDLE\niiii"); + try t.file("look.txt", "r.txt:3-5\nr.txt:7:4-9\nr.txt:3:2-5:3\nr.txt:8:6-99:9"); + // Builtins announce themselves by default, and an announcement is a band at + // the top of the body -- which moves every row this script clicks. What the + // verbs do is what is under test, not the announcement. + try t.config("Verbose off"); + try t.start(31, 150, &.{"look.txt"}); + try t.wait(8000, "r.txt:3-5"); + try t.stable(700, 20000); + try t.snap("opened"); + // --- form 1: whole lines. r.txt opens BELOW look.txt (an ordinary look) with + // lines 3, 4 and 5 selected whole, terminators included — helix's own `x`. + try t.press("right", "10", 4); + try t.release("right", "10", 4); + try t.wait(10000, "cccc dccc"); + try t.stable(700, 15000); + try t.snap("wholelines"); + try t.style("wholelines"); + // --- form 2: one line, a column span. r.txt is open now, so this re-uses that + // pane (focusPaneByPath) — the same route a `/` result row takes. + try t.press("right", "12", 5); + try t.release("right", "12", 5); + try t.stable(700, 15000); + try t.snap("onelinespan"); + try t.style("onelinespan"); + // --- form 3: the general one, across both lines and columns + try t.press("right", "12", 6); + try t.release("right", "12", 6); + try t.stable(700, 15000); + try t.snap("fullspan"); + try t.style("fullspan"); + // --- a STALE range: line 99 of a nine-line file, which is what a result row + // looks like once the file has changed underneath it. It must CLAMP — no crash, + // no garbage highlight — landing on the last cell that really exists. + try t.press("right", "12", 7); + try t.release("right", "12", 7); + try t.stable(700, 15000); + try t.snap("stale"); + try t.style("stale"); + // --- and `/`: its query pane under r.txt, line 1 the pattern, the lines + // holding it as rows (a line number in the gutter, the match tinted); Enter + // puts the keyboard on the match after the cursor, the word itself selected. + try t.key("/"); + try t.send("NEEDLE"); + try t.wait(10000, "gg NEEDLE gg"); + try t.stable(700, 15000); + try t.key("enter"); + try t.stable(700, 15000); + try t.snap("hit1"); + try t.style("hit1"); + // n: the next match in the text, selected + try t.send("n"); + try t.stable(700, 15000); + try t.snap("hit2"); + try t.style("hit2"); + // N walks back onto the first, still selected + try t.send("N"); + try t.stable(700, 15000); + try t.snap("back"); + try t.style("back"); + try t.done(); +} + +// RULE: there is ONE focus history and it is a stack of LOCATIONS — a pane and +// a spot in it. Ctrl-o walks it back, Ctrl-i walks it forward again, `SPC j j` +// (Last) hops to the newest OTHER pane, and `SPC j l` (Jumplist) writes the +// same stack out as an output buffer whose rows are ordinary look targets, so +// n/N step them. What gets ONTO the stack is decided in one place (trackJump): +// focus ended the update in a different pane, or more than a bodyful of rows +// away in the same one — which is why `100G` below leaves a location behind +// and the j/k that follow it do not. +// +// Focus and position both show in the golden's `cursor=` header: that is the +// ACTIVE pane's cursor, so each snap is named by where it should land. +fn jumps(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "jumps"); + defer t.deinit(); + try t.lines("big.txt", 200, ""); + try t.start(31, 150, &.{"big.txt"}); + try t.wait(8000, "big.txt"); + try t.stable(700, 20000); + // a FILE boots alone now, so this is one column holding big.txt, focused, and + // the stack is one entry deep + try t.snap("start"); + // two focus moves. The shell has to be opened before it can be walked to + // (`New`/`Newcol` open an empty +New scratch now, so the shell is asked for by + // name): Alt-n opens it AND focuses it, Alt-c moves it into a column of its + // own on the right — so opening it IS the first of the two moves, and the + // stack below is the same one a shell at boot left. Walking straight back to + // the file does NOT leave `file -> shell -> file` behind: a hop to the entry + // under the top one is the same two places again, so trackJump swaps them + // rather than appending, and the stack is `shell -> file` with the file on top + // (see trackJump). + try t.key("a-n"); + try t.key("a-c"); + try t.stable(700, 15000); + try t.snap("to-shell"); + try t.key("space w h enter"); + try t.stable(400, 5000); + try t.snap("to-file"); + // a FAR motion inside one pane: 100G is a jump, so the line we left is + // remembered and Ctrl-o can come back to it + try t.send("100"); + try t.key("G"); + try t.stable(400, 5000); + try t.snap("goto-100"); + // Ctrl-o: back to line 1 of the same pane — a stack of panes could not do this + try t.key("c-o"); + try t.stable(400, 5000); + try t.snap("back-in-file"); + // ...and back again into the shell + try t.key("c-o"); + try t.stable(400, 5000); + try t.snap("back-to-shell"); + // Ctrl-i forward, twice: back to line 1 of the file, then line 100 again. Sent as the + // kitty-protocol CSI u (`CSI 105;5u`) because on the wire Ctrl-i IS Tab — + // see config.jump_keys. + try t.send("\x1b[105;5u"); + try t.stable(400, 5000); + try t.snap("forward-file"); + try t.send("\x1b[105;5u"); + try t.stable(400, 5000); + try t.snap("forward-100"); + // SPC j j — the newest OTHER pane, and pressing it again comes straight back + try t.key("space j j"); + try t.stable(400, 5000); + try t.snap("last"); + try t.key("space j j"); + try t.stable(400, 5000); + try t.snap("last-back"); + // SPC j l — the stack as text: `location text` rows, the file naming itself + // and the shell spelled @pN because it has no path + try t.key("space j l"); + try t.stable(700, 15000); + try t.snap("jumplist"); + // n/N select the next/prev row and Enter looks it, exactly as they do a + // +Search: the stepped span is selected in the buffer (snapstyle) and the Enter + // after it moves the pane the row names. Row 1 is the shell (no path, so + // `@pN`), row 2 the file at line 1, row 4 the file at line 100 — so the body + // visibly rides the list. + // + // ONE PRESS PER ROW, and this buffer is where that rule earns itself: an `@pN` + // row's trailing text is the pane's DIRECTORY, which is a look-able word of its + // own, so rows 1 and 3 used to hold TWO stops each and reaching the next row + // took two steps. A results buffer is a LIST — its rows are locations, and the + // text after one says what is THERE rather than naming another place to go — so + // the walk takes the location at the head of a row and moves on to the next row + // (output_pane.Grain.line). Free text still steps every word. + // + // An `@pN` row moves focus like any other, which it did not use to: the STEP + // only selects now, and the look Enter runs goes to the pane by the same route + // a path takes. + try t.key("space j n"); + try t.key("enter"); + try t.stable(700, 15000); + try t.snap("step1-shell"); + try t.style("step1-shell"); + // on to row 2 — one press, the directory on row 1 is no longer a stop of its own + try t.key("space j n"); + try t.key("enter"); + try t.stable(700, 15000); + try t.snap("step2-file"); + // row 3 is the shell again, then row 4 + try t.key("space j n"); + try t.stable(400, 5000); + try t.key("space j n"); + try t.key("enter"); + try t.stable(700, 15000); + try t.snap("step4-line100"); + // N is the exact inverse: one press back onto row 3's location, and Enter + // follows it to the shell + try t.key("space j p"); + try t.key("enter"); + try t.stable(700, 15000); + try t.snap("step-back"); + // and an ordinary LOOK on a row goes there too — the leading word IS a + // location, so the right-click look resolves it like any other path. Row 4 + // again, this time by clicking it: the list shows every row, and its row 4 is + // screen row 21. + try t.press("right", "16", 21); + try t.release("right", "16", 21); + try t.stable(700, 15000); + try t.snap("look-row"); + try t.done(); +} + +// `@`...`` — a word that names a COMMAND instead of a file to open. The +// delimiters are config.cmd_open/cmd_close and nothing else in the editor knows +// how one is spelled. +// +// A backtick is not a file char, so the ordinary word expansion would stop dead +// inside one and hand a look the fragment `echo`. config.wordBounds takes the +// whole run instead, which is what makes a single CLICK the way you invoke one +// (acme does the same for its own `<`/`|`/`>` command words). +// +// EXECUTE runs it, as a command pane, and leaves you where you were; LOOK runs +// it and lands you in the pane that answered — looking at a thing means being +// shown it, and a directory's look is a pane listing it, as acme's directory +// window is. +// +// And Look and Exec are ORDINARY BUILTINS now, so their names are executable +// words like Save or Grep: `Look p.txt` run off the page is the same look a +// right click on `p.txt` is. Which is also what makes `@`Look .`` nest — Exec +// unwraps it and the contents go straight back through the one dispatcher. +fn cmdword(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "cmdword"); + defer t.deinit(); + try t.file("cmds.txt", "@`echo ZZ''E` @`echo ZZ''L` Look p.txt @`Look .`"); + try t.file("p.txt", "just text"); + try t.file("zzmark.txt", "x"); + // Builtins announce themselves by default, and an announcement is a band at + // the top of the body -- which would move every row this script clicks. The + // verbs are what is under test here, not the announcement. + try t.config("Verbose off"); + try t.start(31, 120, &.{"cmds.txt"}); + try t.wait(8000, "Newcol Joincol"); + try t.wait(8000, "cmds.txt"); + try t.stable(700, 20000); + try t.snap("opened"); + // a single middle CLICK inside the run (col 11 is inside `echo`) expands to the + // whole `@`echo ZZ''E`` and runs it as a command pane; focus stays on the file + try t.press("middle", "11", 4); + try t.release("middle", "11", 4); + try t.wait(10000, "ZZE"); + try t.stable(700, 15000); + try t.snap("atexec"); + // LOOK on the second one (col 24, inside its `echo`) runs it too, in the same + // command pane now its first is done, below it, AND focuses it — that is the + // whole difference between the two verbs + try t.press("right", "24", 4); + try t.release("right", "24", 4); + try t.wait(10000, "ZZL"); + try t.stable(700, 15000); + try t.snap("atlook"); + // `Look p.txt` middle-dragged: the builtin by NAME, with an argument + try t.press("middle", "36", 4); + try t.drag("middle", "45", 4); + try t.release("middle", "45", 4); + try t.wait(10000, "just text"); + try t.stable(700, 15000); + try t.snap("lookword"); + // nesting: `@`Look .`` — Exec unwraps it, `Look .` is parsed as the ordinary + // Look builtin with an argument, and Look opens the directory: a pane named + // for it with a trailing /, listing it (zzmark.txt is only ever in that + // listing: no pane here shows it otherwise), which takes the keyboard + try t.press("middle", "49", 4); + try t.release("middle", "49", 4); + try t.wait(10000, "zzmark.txt"); + try t.stable(700, 15000); + try t.snap("nested"); + // the same syntax typed into a TAG — the other place the expansion has to know + // about backticks. The look above left the directory pane focused, so `:` + // opens ITS tag; `A` appends at the end of it, Esc and `h` put the + // normal-mode cursor on the last character typed, and the execute key runs + // the word under it exactly as the body's does. + try t.key(":"); + try t.key("A"); + try t.key("space"); + try t.send("Exec"); + try t.key("esc"); + try t.settle(100); + try t.key("h"); + try t.key("tab"); + try t.stable(700, 8000); + // ...except that word is `Exec` ITSELF, with nothing to execute. This is the + // case that must not hang a re-entrant dispatcher: it runs out of argument + // immediately and does nothing at all. Executing gave the keyboard back to the + // body, and `:` finds the tag's cursor where it was left. + try t.snap("execword"); + // a command word run from that tag runs as a command pane in the directory + // the pane lists, as a word run from any text pane's tag does + try t.key(":"); + try t.key("A"); + try t.key("space"); + try t.send("@`echo ZZ''T`"); + try t.key("esc"); + try t.settle(100); + try t.key("h"); + try t.key("tab"); + try t.wait(10000, "ZZT"); + try t.stable(700, 15000); + try t.snap("tagcmd"); + try t.done(); +} + +// Language intelligence end to end: the helix keymap, the async round trip and +// the two dispositions of an answer. +// +// The backend behind the seam here is zls, run as a child process by the +// protocol client (it must be on PATH): `gd` is a request on a worker thread +// whose result comes back as an ordinary event, the same shape a pty read +// already had. Nothing in this script knows that: it presses keys and reads +// the grid, which is the point of the seam. +// +// a.zig is deliberately self-contained — a definition, a call site, and not one +// symbol from std — so these goldens do not encode this machine's stdlib +// version or its install path. +fn lsp(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "lsp"); + defer t.deinit(); + try t.file("a.zig", "const std = @import(\"std\");\n\nfn helper(x: u32) u32 {\n return x + 1;\n}\n\npub fn main() void {\n _ = helper(41);\n}\n"); + try t.start(41, 120, &.{"a.zig"}); + try t.wait(8000, "helper"); + try t.stable(700, 20000); + try t.snap("opened"); + // park the cursor inside the CALL `helper(41)` (file line 8, grid row 9) + try t.press("left", "18", 11); + try t.release("left", "18", 11); + try t.stable(400, 5000); + try t.snap("cursor"); + // gd on a call: exactly one location comes back, so it JUMPS rather than + // opening a picker — and lands SELECTING the definition's name token on line 3, + // because ZLS answers with a range and a ranged row is one a look selects. + // The jumplist is pinned first, so ctrl-o comes back. + try t.key("g"); + try t.key("d"); + try t.stable(700, 15000); + try t.snap("definition"); + // SPC l k is hover (K is keep_selections in helix and stays that way). The answer + // is prose, not locations, so it opens +Hover and does NOT arm the n/N stepper. + try t.key("space"); + try t.key("l"); + try t.key("k"); + try t.stable(700, 15000); + try t.snap("hover"); + // SPC l s lists the file's own symbols. Several rows, so it opens a +Search + // buffer — which IS the picker: n selects a row and Enter looks it, exactly as + // the Find and `/` results already do, with no picker code of its own. + try t.key("space"); + try t.key("l"); + try t.key("s"); + try t.stable(700, 15000); + try t.snap("symbols"); + try t.key("space j n"); + try t.key("enter"); + try t.stable(700, 15000); + try t.snap("step"); + // gd on something with no declaration behind it (a keyword) answers nothing, + // and nothing is a legal answer: no buffer opens, no error is rendered. + try t.press("left", "8", 6); + try t.release("left", "8", 6); + try t.key("g"); + try t.key("d"); + try t.stable(700, 10000); + try t.snap("nothing"); + try t.done(); +} + +// The protocol client end to end, against the deterministic mock server the +// harness pins via PARDES_LSP_RS (test/lspmock.zig). What this exercises is +// everything BETWEEN the keymap and the analyser: spawn, handshake, the reader +// thread, $/progress narration onto the transient message row, and the +// location shapes coming back as +Search rows. +// gd on a cross-file Location -> a look: lib.rs opens with `add` selected, +// and the message row still carries the server's settled state +// ("lsp lspmock: ready") because nothing has cleared it yet. +// gr -> the text's query pane, line 1 `Refs`, rows under their files, +// the next occurrence current, the keyboard on it in normal mode +// (a list answered, not a query typed); n/N step the places. +fn lsp_client(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "lsp-client"); + defer t.deinit(); + try t.file("main.rs", "mod lib;\n\nfn main() {\n let x = add(1, 2);\n let y = add(3, 4);\n let _ = x + y;\n}\n"); + try t.file("lib.rs", "// mock fixture\npub fn add(a: i32, b: i32) -> i32 {\n a + b\n}\n"); + try t.start(25, 100, &.{"main.rs"}); + try t.wait(8000, "add(1, 2)"); + try t.stable(700, 20000); + // cursor into the first `add` call, then helix's goto-definition + try t.press("left", "13", 6); + try t.release("left", "13", 6); + try t.key("g"); + try t.key("d"); + try t.wait(10000, "pub fn add"); + try t.stable(700, 15000); + try t.snap("gd-jumped"); + // references from the definition the look landed on (cursor sits on `add`) + try t.key("g"); + try t.key("r"); + try t.wait(10000, "add(3, 4)"); + try t.stable(700, 15000); + try t.snap("gr-list"); + // the list opens in normal mode, the caret on the current row: n steps to + // the next hit, Enter lands there; N in the text goes back to the one + // before, round the places in main.rs + try t.key("n"); + try t.key("enter"); + try t.stable(700, 15000); + try t.snap("gr-opened"); + try t.send("N"); + try t.stable(700, 15000); + try t.snap("gr-back"); + try t.done(); +} + +// The protocol client's MUTATING answers, through the @put record path: a +// server TextEdit response becomes one atomic buffer edit with one undo step. +// = applies the mock's formatting edit (a header line) and narrates +// "formatted 1 range(s)" on the message row +// SPC l r renames both `add` calls via the server's WorkspaceEdit +// u reverses each as a single transaction +fn lsp_client_edit(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "lsp-client-edit"); + defer t.deinit(); + try t.file("main.rs", "mod lib;\n\nfn main() {\n let x = add(1, 2);\n let y = add(3, 4);\n let _ = x + y;\n}\n"); + try t.file("lib.rs", "// mock fixture\npub fn add(a: i32, b: i32) -> i32 {\n a + b\n}\n"); + try t.start(25, 100, &.{"main.rs"}); + try t.wait(8000, "add(1, 2)"); + try t.stable(700, 20000); + try t.key("="); + try t.wait(10000, "formatted by mock"); + try t.stable(700, 15000); + try t.snap("formatted"); + try t.key("u"); + try t.wait(8000, "mod lib;"); + try t.stable(700, 15000); + try t.snap("unformatted"); + // rename through the leader prompt: both call sites change in one step + try t.press("left", "13", 6); + try t.release("left", "13", 6); + try t.key("space"); + try t.key("l"); + try t.key("r"); + try t.stable(400, 5000); + try t.send("sum"); + try t.key("enter"); + try t.wait(10000, "sum(3, 4)"); + try t.stable(700, 15000); + try t.snap("renamed"); + try t.key("u"); + try t.wait(8000, "add(3, 4)"); + try t.stable(700, 15000); + try t.snap("unrenamed"); + try t.done(); +} + +// Tab after a dot in insert mode: "what could go here". +// +// Each wait for zls's answer allows a minute: it returns as soon as the answer +// is drawn (2 s alone), and a zls slowed by a loaded machine (the parallel +// snap run) took over 15 s, which failed the old wait. The answer is a +// `+Search` buffer of zls's candidates, one row each at the cursor (a +// completion item names no declaration) — nothing is inserted and nothing pops +// up. +// +// a.zig is std-free for the reason lsp.snap's is: these goldens must not encode +// this machine's stdlib version or its install path. Its enum members are +// nonsense words, and the dot is TYPED into an empty switch body, so a row +// naming line 2 or 3 can only have come from a member's declaration — the line +// the cursor is on is line 8 and holds nothing but the dot. +// +// Typing it is the point rather than pointing at one already there: the moment +// the dot lands the file STOPS PARSING (`switch (s) { . }` loses the whole +// switch to the parser's error recovery), and that is the normal input to a +// completion, not a corner case. +// +// The helix corpora cannot reach any of this — hxOpenFileContent names its pane +// `/hxcase.txt`, so lsp.speaks is false for all 1042 cases — which makes this +// script the only end-to-end coverage the feature has. +fn lspcomplete(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "lspcomplete"); + defer t.deinit(); + try t.file("a.zig", "const Shade = enum {\n verdigris,\n cinnabar,\n};\n\nfn pick(s: Shade) u8 {\n return switch (s) {\n \n };\n}\n\n// note. see below\n"); + try t.file("notes.txt", "abc.def ghi\n"); + try t.start(41, 120, &.{"a.zig"}); + try t.wait(8000, "verdigris"); + try t.stable(700, 20000); + try t.snap("opened"); + // Tab with no dot before it is still Tab: line 10 is the closing `}`, and this + // is the plain insert_tab path putting spaces in front of it. + try t.press("left", "8", 13); + try t.release("left", "8", 13); + try t.key("i"); + try t.key("tab"); + try t.stable(400, 5000); + try t.snap("indent"); + try t.key("esc"); + try t.settle(100); + // A dot the backend cannot answer must STILL indent. Line 12 is a comment, so + // the position context is `.comment` and no candidate can exist — and because + // Tab had already diverted to the backend, the indent has to happen + // retroactively when the empty answer arrives (lspResponse), on the condition + // that the cursor has not moved meanwhile. Four spaces go in after `// note.` + // and the keystroke is not eaten, which is the whole contract. + try t.press("left", "16", 15); + try t.release("left", "16", 15); + try t.stable(400, 5000); + try t.key("i"); + try t.key("tab"); + try t.stable(700, 15000); + try t.snap("commentindent"); + try t.key("esc"); + try t.settle(100); + // Line 8 (grid row 9, 1-based click row 10) is the switch's empty body. End + // puts the cursor past its indent, and then the dot is typed. + try t.press("left", "8", 11); + try t.release("left", "8", 11); + try t.stable(400, 5000); + try t.key("i"); + try t.key("end"); + try t.send("."); + try t.stable(400, 5000); + try t.snap("athedot"); + try t.key("tab"); + // The rows that prove it: `verdigris` and `cinnabar` can only have come from + // resolving the switch's condition to `Shade` and asking what it declares. + // Line 8 still reads `.` and nothing else — a completion INSERTS NOTHING. + try t.wait(60000, "+Search"); + try t.stable(700, 30000); + try t.snap("completion"); + // Two more Tabs. Every one of them answers, and every answer REFILLS the one + // `+Search` rather than opening its twin. The SECOND press is already the whole + // assertion: without the refill it leaves a second byte-identical `+Search` and + // this golden diverges. What TWENTY do is only worse in degree — fifteen + // stacked panes, the file crushed to one visible line, and from the sixteenth + // on freeSlot returns null and the keystroke is eaten for the rest of the + // session — and that story is told here rather than replayed in three seconds of + // every suite run. One file pane, one results pane, same as after the first. + try t.key("tab"); + try t.settle(150); + try t.key("tab"); + try t.settle(150); + try t.key("tab"); + try t.stable(700, 30000); + try t.snap("refill"); + // The pane is still in insert mode, which is right — the query answered beside + // the cursor and typing goes on — so walking the answer means leaving it first, + // the same as for any other results buffer. + try t.key("esc"); + try t.settle(100); + // Several rows, so the buffer IS the picker and n walks it; completion does not + // jump the way a goto with one row does. The first step selects row 1, and the + // Enter after it looks that row and lands SELECTING `verdigris` on line 2 of + // a.zig. + try t.key("space j n"); + try t.key("enter"); + try t.stable(700, 15000); + try t.snap("step"); + // A pane the backend does not speak: same keystrokes, same dot before the + // cursor, and Tab must still indent — synchronously this time, since the core + // never asks. The gate is lsp.speaks, which the core consults and the backend + // owns. + try t.start(41, 120, &.{"notes.txt"}); + try t.wait(8000, "abc.def"); + try t.stable(700, 20000); + try t.press("left", "12", 4); + try t.release("left", "12", 4); + try t.key("i"); + try t.key("tab"); + try t.stable(400, 5000); + try t.snap("txtindent"); + // ---- the two genuinely INCOMPLETE states ---- + // + // Everything above types its dot into syntax that is otherwise finished, which + // is the easy half and is why a repair chosen by parse-error count looked like + // it worked. Mid-typing, the line is short of its terminator too. + // + // `const z: Shade = .` is ONE parse error with or without a placeholder + // identifier spliced in, so the repair has to be chosen by whether it makes the + // dot reachable in the tree, never by counting errors. + try t.file("c.zig", "const Shade = enum {\n verdigris,\n cinnabar,\n};\n\npub fn nosemi() void {\n const z: Shade = \n}\n"); + try t.start(19, 100, &.{"c.zig"}); + try t.wait(8000, "nosemi"); + try t.stable(700, 20000); + try t.press("left", "8", 10); + try t.release("left", "8", 10); + try t.stable(400, 5000); + try t.key("i"); + try t.key("end"); + try t.send("."); + try t.stable(400, 5000); + try t.key("tab"); + try t.wait(60000, "+Search"); + try t.stable(700, 30000); + try t.snap("nosemi"); + // ...and a construct still hanging OPEN. The switch has no closing brace at + // all — the one `}` in the file closes it and leaves the function unclosed — + // which makes Zig's recovery throw the whole declaration away. No placeholder + // sitting at the dot can survive that, so the repair has to close the construct + // as well, on the same line (a spelling containing a newline would move every + // line number the rows are built from). + try t.file("d.zig", "const Shade = enum {\n verdigris,\n cinnabar,\n};\n\npub fn nobrace(s: Shade) void {\n switch (s) {\n \n}\n"); + try t.start(19, 100, &.{"d.zig"}); + try t.wait(8000, "nobrace"); + try t.stable(700, 20000); + try t.press("left", "8", 11); + try t.release("left", "8", 11); + try t.stable(400, 5000); + try t.key("i"); + try t.key("end"); + try t.send("."); + try t.stable(400, 5000); + try t.key("tab"); + try t.wait(60000, "+Search"); + try t.stable(700, 30000); + try t.snap("nobrace"); + try t.done(); +} + +// The guard that makes "an empty answer indents" safe to have at all. +// +// lspcomplete.snap pins the indent itself: Tab after a dot the backend cannot +// answer diverts, the answer comes back empty, and four spaces go in LATE so +// the keystroke is not eaten. That late write is the dangerous half — it lands +// a few hundred milliseconds after the key, by which time the hands have moved +// on — so lspResponse only performs it if nothing has: same pane, still insert, +// one cursor, cursor still on the cell the Tab was pressed at. Nothing covered +// the condition, only its happy side. +// +// Same file and same click as lspcomplete's `commentindent` arm — line 12 is a +// comment, so no candidate can exist and the answer is certainly empty — but +// here an `x` is typed straight after the Tab, in the same write, long before a +// ZLS analysis can finish. The buffer below is the assertion: `// note.x`, with +// neither `// note. x` (the indent landing under the typing) nor +// `// note.x ` (the indent landing on top of it). +fn lspcompletemoved(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "lspcompletemoved"); + defer t.deinit(); + try t.file("a.zig", "const Shade = enum {\n verdigris,\n cinnabar,\n};\n\nfn pick(s: Shade) u8 {\n return switch (s) {\n \n };\n}\n\n// note. see below\n"); + try t.start(21, 120, &.{"a.zig"}); + try t.wait(8000, "verdigris"); + try t.stable(700, 20000); + try t.press("left", "16", 15); + try t.release("left", "16", 15); + try t.stable(400, 5000); + try t.key("i"); + try t.key("tab"); + try t.send("x"); + try t.stable(700, 20000); + try t.snap("typedthrough"); + try t.key("esc"); + try t.settle(100); + try t.key("space f s"); + try t.stable(700, 15000); + try t.snapFile("buffer", "/tmp/pardes-snap/lspcompletemoved/cwd/a.zig"); + try t.done(); +} + +fn lspdebug(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "lspdebug"); + defer t.deinit(); + try t.file("z.zig", "const std = @import(\"std\");\n\nfn helper() u32 {\n return 3;\n}\n\npub fn main() void {\n const v = helper();\n _ = v;\n}\n"); + // Builtins announce themselves by default, and an announcement is a band at + // the top of the body -- which moves every row this script clicks. What the + // verbs do is what is under test, not the announcement. + try t.config("Verbose off"); + try t.start(45, 120, &.{"z.zig"}); + try t.wait(8000, "fn helper"); + try t.stable(700, 20000); + try t.snap("opened"); + + // Ctrl-click jumps to the definition; plain click only moves the cursor. + try t.press("ctrl-left", "22", 11); + try t.release("ctrl-left", "22", 11); + try t.stable(700, 15000); + try t.snap("ctrlclick"); + try t.press("left", "22", 11); + try t.release("left", "22", 11); + try t.stable(700, 15000); + try t.snap("plainclick"); + + try t.send("3gg1g|"); + try t.stable(400, 10000); + try t.key("space l w"); + try t.wait(10000, "lsp explain — the definition query"); + try t.wait(10000, "row(s)"); + try t.key("space w j enter"); + try t.key("space d"); + try t.stable(700, 15000); + try t.snap("why-closed"); + + // Check the report's answers, not installed compiler paths or dependency counts. + try t.key("space l i"); + try t.wait(10000, "language servers:"); + try t.wait(10000, "zls"); + try t.key("space w j enter"); + try t.key("/"); + try t.send("client queries"); + try t.key("enter"); + try t.wait(10000, "client queries"); + try t.wait(10000, "definition"); + // Enter left the keyboard in the report, on the match; its query pane is + // attached to it, so one Del closes both, their rows back to the source + try t.key("space d"); + try t.stable(700, 15000); + try t.snap("report-closed"); + try t.done(); +} + +// What a language row SPELLS its path as, and that both spellings still LOOK. +// +// A row spells its path the shortest way a Look from the query pane resolves +// (Query.lookPath): relative to the pane's directory, `../` included, when that +// is shorter than the absolute path, else absolute — a `gr` list was otherwise +// the same forty-character prefix repeated down the pane with the part you came +// to read pushed off the right edge. +// +// A row in the SAME directory shortens to a bare basename; the two that a +// careless shortening can get wrong are here, one app each, as `gr` rows +// (the file headers of the asking text's query pane, line 1 `Refs`): +// +// PARENT the enum is one level UP from the asking file, so the row +// climbs: `../shade.zig`, shorter than `/tmp/.../cwd/shade.zig`, +// and a Look from the pane still lands on it. +// SUBDIRECTORY the enum is one level DOWN, so the strip leaves a path with a +// separator still in it — `inner/tint.zig`, not `tint.zig`. A +// strip that took the basename instead would produce a row that +// resolves to nothing. +// +// `n` and the Enter after it are the assertion in both, not the row text: the +// step selects row 1, the look opens the right file with the member SELECTED +// on its own line, and focus follows what opened — so the snap header's cursor +// is that pane's, and the style capture is where the selection itself shows. +fn lsprelpath(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "lsprelpath"); + defer t.deinit(); + try t.dir("sub"); + try t.dir("sub/inner"); + try t.file("shade.zig", "pub const Shade = enum {\n verdigris,\n cinnabar,\n};\n"); + try t.file("sub/inner/tint.zig", "pub const Tint = enum {\n ochre,\n indigo,\n};\n"); + try t.file("sub/parent.zig", "const shade = @import(\"../shade.zig\");\n\npub fn pick(s: shade.Shade) u8 {\n return switch (s) {\n \n };\n}\n"); + try t.file("sub/subdir.zig", "const tint = @import(\"inner/tint.zig\");\n\npub fn hue(t: tint.Tint) u8 {\n return switch (t) {\n \n };\n}\n"); + // ---- PARENT: outside the asking file's tree, so the row climbs ---- + try t.start(35, 100, &.{"sub/parent.zig"}); + try t.wait(8000, "fn pick"); + try t.stable(700, 20000); + try t.press("left", "31", 6); + try t.release("left", "31", 6); + try t.stable(400, 5000); + try t.key("g"); + try t.key("r"); + // the query pane under parent.zig, line 1 `Refs`, the rows under each file: + // shade.zig's spelled from above, `../shade.zig` + try t.wait(15000, "../shade.zig:1"); + try t.stable(700, 15000); + try t.snap("absrow"); + // the current row is parent.zig's own; the one before it is shade.zig's, + // shown in the +Preview (N, the list in normal mode), which Enter makes + // shade.zig's pane + try t.key("N"); + try t.wait(10000, "verdigris"); + try t.stable(700, 15000); + try t.key("enter"); + try t.stable(700, 15000); + try t.snap("abslook"); + try t.style("abslook"); + try t.start(35, 100, &.{"sub/subdir.zig"}); + try t.wait(8000, "fn hue"); + try t.stable(700, 20000); + try t.press("left", "29", 6); + try t.release("left", "29", 6); + try t.stable(400, 5000); + try t.key("g"); + try t.key("r"); + try t.wait(15000, "inner/tint.zig"); + try t.stable(700, 15000); + try t.snap("subrow"); + try t.key("N"); + try t.wait(10000, "ochre"); + try t.stable(700, 15000); + try t.key("enter"); + try t.stable(700, 15000); + try t.snap("sublook"); + try t.style("sublook"); + try t.press("right", "12", 13); + try t.release("right", "12", 13); + try t.stable(700, 15000); + try t.snap("clicked"); + try t.done(); +} + +// Rename end to end: the leader prompt, async ZLS resolution, atomic file edit, +// shadow filtering, and one-step undo/redo. The source has a same-spelled local +// which must not be changed when the top-level helper is renamed. +fn lsp_rename(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "lsp-rename"); + defer t.deinit(); + try t.file("rename.zig", "const std = @import(\"std\");\n\nfn helper(x: u32) u32 {\n return x + 1;\n}\n\npub fn main() void {\n _ = helper(41);\n}\n\nfn shadowed() void {\n const helper: u32 = 7;\n _ = helper;\n}\n"); + try t.start(25, 110, &.{"rename.zig"}); + try t.wait(8000, "helper(41)"); + try t.stable(700, 20000); + // Put the cursor inside the top-level call, then use the helix rename binding. + try t.press("left", "18", 11); + try t.release("left", "18", 11); + try t.key("space"); + try t.key("l"); + try t.key("r"); + try t.stable(400, 5000); + try t.send("renamed_helper"); + try t.key("enter"); + try t.wait(10000, "renamed_helper(41)"); + try t.stable(700, 15000); + try t.snap("renamed"); + // Both resolved top-level occurrences changed; the shadowed local stayed helper. + // The whole asynchronous rename is one history transaction. + try t.key("u"); + try t.stable(400, 5000); + try t.snap("undone"); + try t.key("U"); + try t.stable(400, 5000); + try t.snap("redone"); + try t.done(); +} + +// A Rename reaches the other files open in the editor. A server renames in +// the documents it has seen (zls's store), so before a query whose answer can +// reach other files the client tells it of every open file of its language. +// Here main.rs is opened by a look, asking the server nothing, and the rename +// is asked from lib.rs: the mock answers in each document it was told of, so +// the preview lists main.rs's two calls and lib.rs's definition. +fn lsp_rename_files(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "lsp-rename-files"); + defer t.deinit(); + try t.file("lib.rs", "// main.rs\npub fn add(a: i32, b: i32) -> i32 {\n a + b\n}\n"); + try t.file("main.rs", "mod lib;\n\nfn main() {\n let x = add(1, 2);\n let y = add(3, 4);\n let _ = x + y;\n}\n"); + try t.start(25, 100, &.{"lib.rs"}); + try t.wait(8000, "pub fn add"); + try t.stable(700, 20000); + try t.press("right", "@main.rs", 4); + try t.release("right", "@main.rs", 4); + try t.wait(8000, "let x = add"); + try t.stable(700, 15000); + try t.snap("opened"); + // into lib.rs's `add`, and rename it from there + try t.press("left", "@add", 5); + try t.release("left", "@add", 5); + try t.stable(400, 5000); + try t.key("space"); + try t.key("l"); + try t.key("r"); + try t.stable(400, 5000); + try t.send("sum"); + try t.key("enter"); + try t.wait(10000, "sum"); + try t.stable(700, 15000); + try t.snap("previewed"); + try t.done(); +} + +// Static call hierarchy in a dedicated pane; sites and declarations are Look +// targets, the source's colours on them. +fn callstack(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "callstack"); + defer t.deinit(); + try t.file("main.rs", "mod lib;\n\nfn main() {\n let x = add(1, 2);\n let y = add(3, 4);\n let _ = x + y;\n}\n"); + try t.file("lib.rs", "// mock fixture\npub fn add(a: i32, b: i32) -> i32 {\n a + b\n}\n"); + try t.start(40, 110, &.{"main.rs"}); + try t.wait(8000, "add(1, 2)"); + try t.stable(700, 20000); + try t.press("left", "13", 6); + try t.release("left", "13", 6); + try t.key("g c"); + try t.wait(10000, "Callstack"); + try t.wait(10000, "recursion"); + try t.stable(700, 15000); + try t.snap("hierarchy"); + try t.style("hierarchy"); + // LookNext selects the caller signature; Enter opens it in the source pane. + try t.key("space j n"); + try t.key("enter"); + try t.wait(10000, "fn main"); + try t.stable(700, 15000); + try t.snap("caller"); + try t.done(); +} + +// A diff pane, for reviewing a change: each hunk's code coloured as Zig (a +// multi-line string over three lines, `defer` inside it no keyword), added and +// removed rows tinted to the pane's edge with their prefix in the tint's hue, +// headers muted. Then a right click on an added line's `+` opens the new file +// at that line: the path is the repository's (a `.git` above the diff), b/ +// dropped. +fn diffview(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "diffview"); + defer t.deinit(); + try t.dir(".git"); + try t.dir("src"); + try t.file("src/shape.zig", "const std = @import(\"std\");\n\npub const Shape = union(enum) {\n circle: f32,\n square: f32,\n triangle: struct { base: f32, height: f32 },\n\n const note =\n \\\\areas, defer\n \\\\summed\n ;\n};\n"); + try t.file("change.diff", "diff --git a/src/shape.zig b/src/shape.zig\nindex 1111111..2222222 100644\n--- a/src/shape.zig\n+++ b/src/shape.zig\n@@ -1,10 +1,12 @@\n const std = @import(\"std\");\n \n pub const Shape = union(enum) {\n circle: f32,\n- square: u8 = 7,\n+ square: f32,\n+ triangle: struct { base: f32, height: f32 },\n \n const note =\n- \\\\areas\n+ \\\\areas, defer\n+ \\\\summed\n ;\n };\n"); + try t.start(31, 100, &.{"change.diff"}); + try t.wait(8000, "Newcol Joincol"); + try t.stable(700, 20000); + try t.snap("diff-pane"); + try t.style("diff-colours"); + try t.press("right", "8", 15); + try t.release("right", "8", 15); + try t.stable(700, 15000); + try t.snap("look-added-line"); + // The same diff printed by a command (`git diff`, here `cat`) into a command + // pane: its output is told for a diff and coloured the same, over the colours + // the program printed, and a right click on a `+` there opens the file too. + try t.file("cmds.txt", "cat change.diff\n"); + try t.start(31, 100, &.{"cmds.txt"}); + try t.wait(8000, "cmds.txt"); + try t.stable(700, 20000); + try t.press("middle", "7", 4); + try t.drag("middle", "22", 4); + try t.release("middle", "22", 4); + try t.wait(10000, "exit 0"); + try t.stable(700, 15000); + try t.snap("command-pane"); + try t.style("command-colours"); + try t.press("right", "3", 21); + try t.release("right", "3", 21); + try t.stable(700, 15000); + try t.snap("command-look"); + try t.done(); +} + +// a look at a directory opens a pane named for it with a trailing /, its +// entries in columns as acme's directory window lays them out: down each +// column first, a directory's marked /, dotfiles shown. A look at an entry +// opens it from that directory. No shell anywhere: nothing here races a prompt. +fn dirpane(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "dirpane"); + defer t.deinit(); + try t.dir("sub"); + try t.dir("sub/deeper"); + try t.file("sub/inner.txt", "inner-marker"); + try t.file("sub/.hidden", "x"); + try t.file("sub/alpha.txt", "x"); + try t.file("sub/beta-gamma.txt", "x"); + try t.file("sub/zeta", "x"); + try t.file("top.txt", "sub"); + try t.config("Verbose off"); + try t.start(24, 80, &.{"top.txt"}); + try t.wait(8000, "top.txt"); + try t.stable(700, 20000); + try t.press("right", "@sub", 4); + try t.release("right", "@sub", 4); + try t.wait(8000, "inner.txt"); + try t.stable(700, 20000); + try t.snap("dir-open"); + // an entry, by its name alone: sub's inner.txt + try t.press("right", "@inner.txt", 7); + try t.release("right", "@inner.txt", 7); + try t.wait(8000, "inner-marker"); + try t.stable(700, 20000); + try t.snap("entry-open"); + try t.done(); +} + +// scrolloff: keyboard motion keeps 3 context rows above/below the cursor, +// clamped at file boundaries (cursor may reach the top/bottom body row there) +fn scrolloff(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "scrolloff"); + defer t.deinit(); + try t.lines("g.txt", 40, ""); + try t.start(16, 210, &.{ "-n", "1" }); + try t.wait(8000, "g.txt"); + try t.stable(700, 20000); + // right-click the g.txt name in the greeting ls -> file pane under the shell's + // text, 9 body rows + try t.press("right", "4", 5); + try t.release("right", "4", 5); + try t.wait(10000, "line 3"); + try t.stable(700, 15000); + try t.press("left", "10", 9); + try t.release("left", "10", 9); + try t.stable(400, 5000); + // (b) gg: cursor CAN sit on the top body row, no forced scroll + try t.key("g g"); + try t.stable(400, 5000); + try t.snap("top"); + // (a) five j's reach the bottom margin (visual row 5 of 9) without scrolling... + try t.key("j j j j j"); + try t.stable(400, 5000); + try t.snap("edge"); + // ...the sixth j scrolls: view slides one line, cursor holds the margin + try t.key("j"); + try t.stable(400, 5000); + try t.snap("scrolled1"); + try t.key("j j j j"); + try t.stable(400, 5000); + try t.snap("jdown"); + // (d) ge (goto last line; bare G is a helix no-op): bottom clamp, view stops + // at EOF-at-bottom, cursor on the bottom row + try t.key("g e"); + try t.stable(400, 5000); + try t.snap("end"); + // (c) k-walk up: cursor climbs to the top margin, then the view scrolls + try t.key("k k k k k k k k"); + try t.stable(400, 5000); + try t.snap("kup"); + // (b) again from deep in the file: gg puts the cursor back on the top row + try t.key("g g"); + try t.stable(400, 5000); + try t.snap("top2"); + try t.done(); +} + +// Soft line breaks: ON by default, off with the Wrap builtin (`SPC t w`). A +// file line too long for the pane renders across several body rows instead of +// running off the right edge. +// +// Three rules pinned here. The break is at the PANE'S OWN content width and +// nothing else — there is no upper bound, a wide window breaks wide. A +// continuation row carries a BLANK gutter (the number belongs to the LINE, and +// a number repeated down a wrapped line would read as several lines) and the +// row it broke out of ends in `↩`, in the one column the wrap keeps free for +// it — a break is otherwise invisible, and an absent line number is a poor +// thing to read a document by. And the mouse follows the render: a click on a +// continuation row lands on the character under the pointer, which only works +// if the click resolves through the same row->line map the body was drawn from. +// +// The line is 20 decades, each headed by its own column marker: `0` at column +// 0, `4` at 40, `A` at 100. So the first character of a continuation row NAMES +// the column it broke at, and the width rule is readable straight off the grid. +fn wrap(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "wrap"); + defer t.deinit(); + try t.file("long.txt", "0---------1---------2---------3---------4---------5---------6---------7---------8---------9---------A---------B---------C---------D---------E---------F---------G---------H---------I---------J---------\nsecond line\nthird line\n"); + // 48 columns: the 2-column chrome gutter, the 5-column line-number gutter and + // the 1 column the `↩` sits in leave 40 for content. + try t.start(15, 48, &.{"long.txt"}); + try t.wait(8000, "Newcol Joincol"); + try t.stable(700, 20000); + // the default: five rows for line 1 (200 bytes / 40), the four continuations + // gutterless and starting at `4` `8` `C` `G` — the columns 40, 80, 120, 160 — + // and each of the first four rows ending in the break marker + try t.snap("on-narrow"); + // a click on the SECOND row of line 1, on the `5` marker at column 50. The + // cursor must come back to the cell that was clicked (grid 17,3): the click + // resolved to line 1 column 50, and the render put line 1 column 50 back where + // the finger was. Off by one row and it would land in line 2. + try t.press("left", "18", 5); + try t.release("left", "18", 5); + try t.stable(400, 5000); + try t.snap("clicked"); + // motions stay LOGICAL: one `j` from line 1 leaves the whole wrapped line + // behind and lands on line 2, four screen rows down at once. + try t.key("j"); + try t.stable(400, 5000); + try t.snap("logical-j"); + // ...while `gj`/`gk` are the VISUAL pair. `gg` puts the cursor back at line 1 + // column 0 with no goal column left over, `3l` moves three in, and from there + // each `gj` steps ONE screen row: still line 1, the column kept INSIDE the row, + // so the cursor stays in grid column 10 while the row walks 2 -> 3 -> 4. `gk` + // steps back onto the row it came from. This is the only motion that reads the + // wrap map's own arithmetic, so it is the one that can silently become `j`. + try t.key("g g"); + try t.stable(400, 5000); + try t.key("3 l"); + try t.stable(400, 5000); + try t.key("g j"); + try t.stable(400, 5000); + try t.snap("visual-gj"); + try t.key("g j"); + try t.stable(400, 5000); + try t.snap("visual-gj-again"); + try t.key("g k"); + try t.stable(400, 5000); + try t.snap("visual-gk"); + // a count is counted in ROWS too, and two of them are still inside line 1 + try t.key("2 g j"); + try t.stable(400, 5000); + try t.snap("visual-count-gj"); + // SPC t w turns it off: line 1 back on ONE row, clipped at the right edge with + // no marker, lines 2 and 3 under it — the render this pane had before soft + // breaks existed, because the map the readers consult goes back to empty and + // every one of them falls back to the row arithmetic it used before any of it + try t.key("space t w"); + try t.stable(400, 5000); + try t.snap("off"); + // ...and on again is on + try t.key("space t w"); + try t.stable(400, 5000); + try t.snap("on-again"); + // 128 columns: 120 for content, and the break is at the `C` — column 120, the + // window's own width. The old 100-column cap would have broken at the `A`. + try t.start(15, 128, &.{"long.txt"}); + try t.wait(8000, "Newcol Joincol"); + try t.stable(700, 20000); + try t.snap("on-wide"); + try t.done(); +} + +// horizontal scroll, file panes only (terminals wrap at pty width): the +// horizontal wheel shifts the content window (gutter stays put, no scrollbar), +// and keyboard movement keeps the scrolloff margin sideways — $ on a long +// line pulls the view right, 0 snaps it back. Overscroll right is allowed; +// a cursor move reels it in. +fn hscroll(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "hscroll"); + defer t.deinit(); + try t.file("wide.txt", "short1 END_A_MARKER_WAY_OUT_RIGHT_padpadpadpadpadpadpadpadpadpadpadpadpadpad_TAIL"); + try t.start(31, 90, &.{ "-n", "3" }); + try t.wait(8000, "wide.txt"); + try t.stable(700, 20000); + // soft wrap is ON by default and a wrapped body has nothing to scroll sideways + // — hscroll is what you get when you turn it OFF, so this whole script runs + // with it off. SPC t w is global, so it is spent once, before the file exists. + try t.key("space t w"); + try t.stable(400, 5000); + // open wide.txt: click a body spot, type the name, look it + try t.press("left", "5", 9); + try t.release("left", "5", 9); + try t.stable(400, 5000); + try t.key("i"); + try t.send("wide.txt"); + try t.key("esc"); + try t.settle(100); + try t.stable(400, 5000); + try t.press("right", "7", 9); + try t.release("right", "7", 9); + try t.stable(700, 15000); + try t.snap("opened"); + // wheel right over the file pane: content shifts, line numbers stay + try t.send("\x1b[<66;10;8M"); + try t.send("\x1b[<66;10;8M"); + try t.stable(400, 5000); + try t.snap("wheeled"); + // wheel back left past the start clamps at column 0 + try t.send("\x1b[<67;10;8M"); + try t.send("\x1b[<67;10;8M"); + try t.send("\x1b[<67;10;8M"); + try t.stable(400, 5000); + try t.snap("clamped"); + // gl walks the cursor to the line end: the view follows with the margin + try t.key("g g"); + try t.stable(400, 5000); + try t.key("g l"); + try t.stable(400, 5000); + try t.snap("dollar"); + // 0 back to column zero: the view snaps home + try t.key("0"); + try t.stable(400, 5000); + try t.snap("zero"); + try t.done(); +} + +// Follow (SPC c f) twice on a 300-line file: three pages in three columns, +// each going on the line after the one before ends; Unfollow on the two +// followers' tags only. Then j past the first page's last row takes the +// keyboard to the second page without scrolling, and a wheel notch in the +// last page moves all three. +fn follow(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "follow"); + defer t.deinit(); + try t.lines("big.txt", 300, ""); + try t.start(30, 150, &.{"big.txt"}); + try t.wait(8000, "big.txt"); + try t.stable(500, 15000); + try t.key("space c f"); + try t.stable(500, 8000); + try t.key("space c f"); + try t.stable(500, 8000); + try t.snap("three-pages"); + try t.send("27j"); + try t.stable(500, 8000); + try t.snap("hop"); + try t.wheel("down", "120", 12); + try t.stable(500, 8000); + try t.snap("wheel"); + try t.done(); +} + +// `:` — vim's command line with acme's vocabulary. It focuses the pane's OWN +// tag in NORMAL mode (block cursor; the layout box shows the pane's BODY mode, +// which for this file pane is normal either way). The tag remembers where its +// cursor was; the first time there is nothing to remember and it starts on +// Save. The tag's normal mode is the body's: w selects the "Save" span exactly +// as a body word motion does, and the execute key runs the word under the +// cursor and hands the body back — same keys as the body, so Tab by default +// (see config.look_key/exec_key). `:` again backs out instead, leaving the tag +// as it was. +fn tagcmd(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "tagcmd"); + defer t.deinit(); + try t.lines("c.txt", 6, ""); + try t.start(31, 100, &.{"c.txt"}); + try t.wait(8000, "Newcol Joincol"); + try t.wait(8000, "c.txt"); + try t.stable(700, 20000); + // edit line 1 so Save has something to write + try t.key("i"); + try t.send("ZZEDIT"); + try t.key("esc"); + try t.settle(100); + try t.stable(400, 5000); + try t.snap("edited"); + // `:` -> the tag, in normal mode, cursor on Save + try t.key(":"); + try t.stable(400, 5000); + try t.snap("colon"); + // w -> the "Save" span (selected, like the body's word motion) + try t.key("w"); + try t.stable(400, 5000); + try t.snap("word"); + // Tab executes it: c.txt is written and focus is back in the body + try t.key("tab"); + try t.stable(600, 8000); + try t.stable(400, 5000); + try t.snap("saved"); + try t.snapFile("written", "/tmp/pardes-snap/tagcmd/cwd/c.txt"); + // `:` then `:`: back to the body with the tag untouched, nothing run + try t.key(":"); + try t.stable(400, 5000); + try t.key(":"); + try t.stable(400, 5000); + try t.snap("escaped"); + try t.done(); +} + +// A tag's normal mode is the body's: h/l/w move in the tag's own text, and +// moving between panes is the window keys' job from a tag as from a body -- +// there are no tag-only hops. `:` is the one key a tag and a body do not +// share: from the body it focuses the pane's own tag, from the tag it hands the +// keyboard back to the body. Each tag remembers its cursor; the first time +// there is nothing to remember and it starts on Save. +// +// Evidence is the `cursor=` header (the ACTIVE pane's cursor, which while a tag +// is focused sits on THAT pane's tag row) plus each pane's layout box, which +// carries its BODY mode as one character: ` ` normal, `^` insert, `$` tty. The +// tag has a mode of its own, so the box never changes while a tag is used. +fn tagnav(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "tagnav"); + defer t.deinit(); + try t.file("w.txt", "alpha\nbeta\ngamma"); + try t.start(31, 100, &.{"w.txt"}); + try t.wait(8000, "Newcol Joincol"); + try t.wait(8000, "w.txt"); + try t.stable(700, 20000); + // A FILE boots alone, so the launch shell is opened here: Alt-n opens it and + // focuses it, Alt-c puts it in a column of its own on the right, SPC w h Enter + // comes back to the file. + try t.key("a-n"); + try t.key("a-c"); + try t.stable(700, 15000); + try t.key("space w h enter"); + try t.stable(400, 5000); + // Alt-n: a shell below the file, so the left column has two rows and every + // direction has somewhere to go + try t.key("a-n"); + try t.stable(700, 15000); + try t.key("space w k enter"); + try t.stable(400, 5000); + try t.snap("start"); + // `:` -> the file's OWN tagline, normal mode, on Save + try t.key(":"); + try t.stable(400, 5000); + try t.snap("colon"); + // w selects in the tag the way it selects in a body + try t.key("w"); + try t.stable(400, 5000); + try t.snap("word"); + // l is a motion in the tag, not a hop to the next pane + try t.key("l l"); + try t.stable(400, 5000); + try t.snap("in-tag"); + // the window keys move between panes from a tag as from a body: the tag lets + // go and the neighbour's BODY takes the keyboard + try t.key("c-w l enter"); + try t.stable(400, 5000); + try t.snap("right"); + // `:` there -> that pane's own tag, on its Save the first time + try t.key(":"); + try t.stable(400, 5000); + try t.snap("right-tag"); + // back left, and `:` finds the file's tag cursor where l left it + try t.key("c-w h enter"); + try t.stable(400, 5000); + try t.key(":"); + try t.stable(400, 5000); + try t.snap("left-tag"); + // `:` in the tag's normal mode: back to the body + try t.key(":"); + try t.stable(400, 5000); + try t.snap("back-to-body"); + // A TERMINAL KEEPS ITS TTY MODE. Put the launch shell in raw tty mode (Ctrl-b), + // click its tagline and come back: its box reads `$` throughout, because the + // tag's mode is the tag's own. + try t.key("c-w l enter"); + try t.stable(400, 5000); + try t.key("c-b"); + try t.stable(700, 15000); + try t.snap("tty-on"); + try t.press("left", "@Mode", 3); + try t.release("left", "@Mode", 3); + try t.stable(400, 5000); + try t.snap("tty-tag"); + try t.key(":"); + try t.stable(400, 5000); + try t.snap("tty-restored"); + // The column and workspace tags are Texts in the same layout, with the same + // keys: Up from a pane with nothing above it reaches its column's tag, in + // normal mode, then the workspace's; Down comes back the same way. + try t.key("c-b"); + try t.stable(700, 15000); + try t.key("c-w h enter"); + try t.stable(400, 5000); + try t.key("c-w k"); + try t.stable(400, 5000); + try t.snap("column-tag"); + try t.key("w"); + try t.stable(400, 5000); + try t.snap("column-word"); + try t.key("c-w k"); + try t.stable(400, 5000); + try t.snap("workspace-tag"); + // `$` is the last cell; five long-word steps back land on `Dump`, and the + // execute key runs it and gives the keyboard back to the body FIRST -- `Exit` + // lives up here too, so a builtin that frees the session must never return + // into a focused header. Dump grows a `Restore ` word, which is also the + // case where the line gets longer than the column you were parked on. + try t.key("g l"); + try t.stable(400, 5000); + try t.snap("topbar-dollar"); + try t.key("B B B B B"); + try t.stable(400, 5000); + try t.snap("topbar-dump-word"); + try t.key("tab"); + try t.stable(700, 15000); + try t.snap("topbar-exec"); + // THE DELETION HAZARD, from the bar itself: `Restore` frees every pane and + // swaps the core out from under the caller. Walk back up onto the word the + // Dump just grew -- B twice off the tail, because the LONG word motions are the + // ones that step over a path in one go -- and run it. + try t.key("c-w k"); + try t.key("c-w k"); + try t.stable(400, 5000); + try t.key("g l B B"); + try t.stable(400, 5000); + try t.snap("topbar-restore-word"); + try t.key("tab"); + try t.stable(900, 15000); + try t.snap("topbar-restored"); + try t.done(); +} + +// The path is part of the tag's text for the keyboard as for the mouse: `0` +// goes to its start, `E` selects it and `y` yanks it. It is read-only, but +// typing into it drafts a new name there, as a click on it does. Escape +// cancels; Enter changes buffer identity, never renames a disk file. +fn tagpath(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "tagpath"); + defer t.deinit(); + try t.lines("c.txt", 4, ""); + try t.start(31, 100, &.{"c.txt"}); + try t.wait(8000, "Newcol Joincol"); + try t.wait(8000, "c.txt"); + try t.stable(700, 20000); + try t.snap("start"); + try t.key(":"); + try t.stable(400, 5000); + try t.snap("colon"); + try t.key("0"); + try t.stable(400, 5000); + try t.snap("col0"); + try t.key("E"); + try t.stable(400, 5000); + try t.snap("sel-path"); + try t.style("sel-path"); + try t.key("y"); + // `:` gives the keyboard back to the body, and `p` puts the path there + try t.key(":"); + try t.key("p"); + try t.stable(400, 5000); + try t.snap("yanked-path"); + // Sweep across the path / command boundary without injected padding. + try t.press("left", "12", 3); + try t.drag("left", "30", 3); + try t.drag("left", "42", 3); + try t.release("left", "42", 3); + try t.stable(400, 5000); + try t.snap("drag-cross"); + try t.style("drag-cross"); + // Esc is the tag's normal mode; typed at the path's start, `/renamed` drafts + // a name + try t.key("esc"); + try t.settle(100); + try t.key("0"); + try t.key("i"); + try t.send("/renamed"); + try t.stable(400, 5000); + try t.snap("name-draft"); + // Esc keeps the draft pending; a second drops it + try t.key("esc"); + try t.settle(100); + try t.key("esc"); + try t.stable(400, 5000); + try t.snap("name-cancelled"); + try t.key(":"); + try t.key("0"); + try t.key("i"); + try t.send("/renamed"); + try t.key("enter"); + try t.stable(400, 5000); + try t.snap("name-committed"); + try t.done(); +} + +// a CLICKED tag is in normal mode, its cursor where it was clicked: `i` types +// there (`:` is the door back to the body, see tagcmd); backspace edits; Esc drops to the tag's normal mode, which is +// the body's normal mode, and `:` there hands the keyboard back to the body; +// Enter looks the word at the cursor (Tab executes it). Multi-word execution +// from the tag stays the mouse's job (middle-drag), like anywhere else. +fn tag(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "tag"); + defer t.deinit(); + try t.file("t.txt", "ZZLOOKED"); + try t.start(31, 150, &.{ "-n", "3" }); + try t.wait(8000, "t.txt"); + try t.stable(700, 20000); + // Click the one editable separator before Save, directly after the cwd. + // The former generated alignment gap no longer exists. + // The layout box shows + // the pane's BODY mode, not the tag's; `i` then types into the tag where it + // was clicked. + try t.press("left", "@Save-1", 3); + try t.release("left", "@Save-1", 3); + try t.stable(400, 5000); + try t.snap("tag-focus"); + try t.key("i"); + try t.send(" t.txt"); + try t.stable(600, 8000); + try t.stable(400, 5000); + try t.snap("tag-typed"); + try t.key("bs"); + try t.key("bs"); + try t.key("bs"); + try t.key("bs"); + try t.stable(400, 5000); + try t.snap("tag-del"); + try t.send(".txt"); + try t.stable(600, 8000); + try t.stable(400, 5000); + // Esc: the tag's normal mode; `:` then gives the keyboard back to the body, + // which is in normal mode, and the typed text stays + try t.key("esc"); + try t.settle(100); + try t.key(":"); + try t.stable(400, 5000); + try t.snap("tag-exit"); + // re-enter the tag and look the typed word: Enter in normal mode opens t.txt + // as a file pane. Click the inserted word itself; filename, separator and + // commands are compact. + try t.press("left", "@t.txt", 3); + try t.release("left", "@t.txt", 3); + try t.stable(400, 5000); + try t.key("enter"); + try t.wait(10000, "ZZLOOKED"); + try t.stable(700, 15000); + try t.snap("tag-look"); + try t.done(); +} diff --git a/test/snapshots/callstack.snap b/test/snapshots/callstack.snap deleted file mode 100644 index c0adb909..00000000 --- a/test/snapshots/callstack.snap +++ /dev/null @@ -1,21 +0,0 @@ -# Static call hierarchy in a dedicated pane; sites and declarations are Look -# targets, the source's colours on them. -file main.rs mod lib;\n\nfn main() {\n let x = add(1, 2);\n let y = add(3, 4);\n let _ = x + y;\n}\n -file lib.rs // mock fixture\npub fn add(a: i32, b: i32) -> i32 {\n a + b\n}\n -start 40 110 main.rs -wait 8000 add(1, 2) -stable 700 20000 -press left 13 6 -release left 13 6 -key g c -wait 10000 Callstack -wait 10000 recursion -stable 700 15000 -snap hierarchy -snapstyle hierarchy -# LookNext selects the caller signature; Enter opens it in the source pane. -key space j n -key enter -wait 10000 fn main -stable 700 15000 -snap caller diff --git a/test/snapshots/chordcut.snap b/test/snapshots/chordcut.snap deleted file mode 100644 index b1f164a2..00000000 --- a/test/snapshots/chordcut.snap +++ /dev/null @@ -1,157 +0,0 @@ -# acme 1-2/1-3 chords in a file pane: with the left button holding a drag -# selection, tapping middle Cuts it into the snarf (yank) register; tapping -# right Pastes the register (replacing the selection, or splicing at a bare -# click point); cut then paste in ONE hold nets out to copy/Snarf. The left -# release after a chord is inert (the cursor stays where the op left it). -# Also the cancel chords: tapping right during a middle (execute) drag or -# left during a right (look) drag cancels the gesture entirely. -lines f.txt 5 -lines g.txt 2 -# The narrow-window fallback splits below the source shell and leaves the -# unrelated right column untouched. Give the caller enough cells that the selected -# `echo B''OO g.txt` remains one displayed row; this test is about chords, not -# soft-wrap traversal. -start 31 120 -n 3 -wait 8000 f.txt -stable 700 20000 -# open f.txt: click a body spot, type the name, look it -press left 5 9 -release left 5 9 -stable 400 5000 -key i -text f.txt -key esc -settle 100 -stable 400 5000 -press right 6 9 -release right 6 9 -wait 10000 line 3 -stable 700 15000 -snap opened -# 1-2 Cut: left-drag over "line" on line 2, tap middle while holding -press left 8 10 -drag left 11 10 -press middle 11 10 -release middle 11 10 -release left 11 10 -stable 400 5000 -snap cut -# 1-2 then 1-3 in one hold = copy: line 3 keeps its text, register loaded -press left 8 11 -drag left 11 11 -press middle 11 11 -release middle 11 11 -press right 11 11 -release right 11 11 -release left 11 11 -stable 400 5000 -snap copied -# 1-3 at a bare click point: hold left past the end of line 4, tap right — -# the register splices in at the click -press left 14 12 -press right 14 12 -release right 14 12 -release left 14 12 -stable 400 5000 -snap pointpaste -# 1-3 over a fresh selection replaces it with the register -press left 9 13 -drag left 11 13 -press right 11 13 -release right 11 13 -release left 11 13 -stable 400 5000 -snap replaced -# arm the cancel tests: append `echo B''OO g.txt` to line 2 -press left 10 10 -release left 10 10 -stable 400 5000 -key i -text echo B''OO g.txt -key esc -settle 100 -stable 400 5000 -# 2-3 cancel (acme textselect2): tap right during the middle execute-drag -# over `echo B''OO` — the command never runs (no BOO anywhere) -press middle 10 10 -drag middle 19 10 -press right 19 10 -release right 19 10 -release middle 19 10 -stable 700 8000 -snap cancelexec -# the same drag released clean proves the word was live: BOO appears -press middle 10 10 -drag middle 19 10 -release middle 19 10 -wait 10000 BOO -stable 700 10000 -snap execafter -# 3-1 cancel (acme textselect3): tap left during the right look-drag over -# g.txt — no pane opens -press right 21 10 -drag right 25 10 -press left 25 10 -release left 25 10 -release right 25 10 -stable 700 8000 -snap cancellook -# the same look released clean opens g.txt -press right 21 10 -drag right 25 10 -release right 25 10 -wait 10000 line 2 -stable 700 10000 -snap lookafter -# a fresh left click dismisses the chord's leftover selection instead of -# dragging the anchored span to the click: copy `line` on g.txt line 1 -# (styled snap shows the selection), then click the next row (it's gone) -press left 8 24 -drag left 11 24 -press middle 11 24 -release middle 11 24 -press right 11 24 -release right 11 24 -release left 11 24 -stable 400 5000 -snapstyle chordsel -press left 8 25 -release left 8 25 -stable 400 5000 -snapstyle clickdismiss -# g.txt opened under the lower shell's text and left it three rows: close it, -# and the shell grows back into its rows, for what follows to run in -press middle 59 23 -release middle 59 23 -stable 700 15000 -# tty paste chord: over a mouse-listening app B1 is the app's, so the -# chord's B1 holds Shift (B3 is pardes's either way); the app gets a click -# where the text goes (SGR, body-relative) then the register between -# bracketed-paste markers — cat -v prints the received bytes visibly -press left 35 23 -release left 35 23 -stable 400 5000 -key c-b -stable 600 8000 -text stty -icanon -echo; printf '\x1b[?2004h\x1b[?1000h\x1b[?1006h'; cat -v -key enter -stable 700 8000 -press shift-left 40 25 -press right 40 25 -release right 40 25 -release shift-left 40 25 -stable 700 8000 -snap ttyprobe -# a plain prompt (mouse modes off) gets no click bytes — just the paste; -# readline's own 2004 strips the markers and inserts the register text -key c-c -stable 600 8000 -text stty sane; printf '\x1b[?1000l\x1b[?1006l' -key enter -stable 600 8000 -press left 40 25 -press right 40 25 -release right 40 25 -release left 40 25 -stable 700 8000 -snap ttyprompt diff --git a/test/snapshots/cmdword.snap b/test/snapshots/cmdword.snap deleted file mode 100644 index 34554d6d..00000000 --- a/test/snapshots/cmdword.snap +++ /dev/null @@ -1,93 +0,0 @@ -# `@`...`` — a word that names a COMMAND instead of a file to open. The -# delimiters are config.cmd_open/cmd_close and nothing else in the editor knows -# how one is spelled. -# -# A backtick is not a file char, so the ordinary word expansion would stop dead -# inside one and hand a look the fragment `echo`. config.wordBounds takes the -# whole run instead, which is what makes a single CLICK the way you invoke one -# (acme does the same for its own `<`/`|`/`>` command words). -# -# EXECUTE runs it, as a command pane, and leaves you where you were; LOOK runs -# it and lands you in the pane that answered — looking at a thing means being -# shown it, and a directory's look is a pane listing it, as acme's directory -# window is. -# -# And Look and Exec are ORDINARY BUILTINS now, so their names are executable -# words like Save or Grep: `Look p.txt` run off the page is the same look a -# right click on `p.txt` is. Which is also what makes `@`Look .`` nest — Exec -# unwraps it and the contents go straight back through the one dispatcher. -file cmds.txt @`echo ZZ''E` @`echo ZZ''L` Look p.txt @`Look .` -file p.txt just text -file zzmark.txt x -# Builtins announce themselves by default, and an announcement is a band at -# the top of the body -- which would move every row this script clicks. The -# verbs are what is under test here, not the announcement. -config Verbose off -start 31 120 cmds.txt -wait 8000 Newcol Joincol -wait 8000 cmds.txt -stable 700 20000 -snap opened -# a single middle CLICK inside the run (col 11 is inside `echo`) expands to the -# whole `@`echo ZZ''E`` and runs it as a command pane; focus stays on the file -press middle 11 4 -release middle 11 4 -wait 10000 ZZE -stable 700 15000 -snap atexec -# LOOK on the second one (col 24, inside its `echo`) runs it too, in the same -# command pane now its first is done, below it, AND focuses it — that is the -# whole difference between the two verbs -press right 24 4 -release right 24 4 -wait 10000 ZZL -stable 700 15000 -snap atlook -# `Look p.txt` middle-dragged: the builtin by NAME, with an argument -press middle 36 4 -drag middle 45 4 -release middle 45 4 -wait 10000 just text -stable 700 15000 -snap lookword -# nesting: `@`Look .`` — Exec unwraps it, `Look .` is parsed as the ordinary -# Look builtin with an argument, and Look opens the directory: a pane named -# for it with a trailing /, listing it (zzmark.txt is only ever in that -# listing: no pane here shows it otherwise), which takes the keyboard -press middle 49 4 -release middle 49 4 -wait 10000 zzmark.txt -stable 700 15000 -snap nested -# the same syntax typed into a TAG — the other place the expansion has to know -# about backticks. The look above left the directory pane focused, so `:` -# opens ITS tag; `A` appends at the end of it, Esc and `h` put the -# normal-mode cursor on the last character typed, and the execute key runs -# the word under it exactly as the body's does. -key : -key A -key space -text Exec -key esc -settle 100 -key h -key tab -stable 700 8000 -# ...except that word is `Exec` ITSELF, with nothing to execute. This is the -# case that must not hang a re-entrant dispatcher: it runs out of argument -# immediately and does nothing at all. Executing gave the keyboard back to the -# body, and `:` finds the tag's cursor where it was left. -snap execword -# a command word run from that tag runs as a command pane in the directory -# the pane lists, as a word run from any text pane's tag does -key : -key A -key space -text @`echo ZZ''T` -key esc -settle 100 -key h -key tab -wait 10000 ZZT -stable 700 15000 -snap tagcmd diff --git a/test/snapshots/diffview.snap b/test/snapshots/diffview.snap deleted file mode 100644 index 23d060b7..00000000 --- a/test/snapshots/diffview.snap +++ /dev/null @@ -1,37 +0,0 @@ -# A diff pane, for reviewing a change: each hunk's code coloured as Zig (a -# multi-line string over three lines, `defer` inside it no keyword), added and -# removed rows tinted to the pane's edge with their prefix in the tint's hue, -# headers muted. Then a right click on an added line's `+` opens the new file -# at that line: the path is the repository's (a `.git` above the diff), b/ -# dropped. -dirmk .git -dirmk src -file src/shape.zig const std = @import("std");\n\npub const Shape = union(enum) {\n circle: f32,\n square: f32,\n triangle: struct { base: f32, height: f32 },\n\n const note =\n \\\\areas, defer\n \\\\summed\n ;\n};\n -file change.diff diff --git a/src/shape.zig b/src/shape.zig\nindex 1111111..2222222 100644\n--- a/src/shape.zig\n+++ b/src/shape.zig\n@@ -1,10 +1,12 @@\n const std = @import("std");\n \n pub const Shape = union(enum) {\n circle: f32,\n- square: u8 = 7,\n+ square: f32,\n+ triangle: struct { base: f32, height: f32 },\n \n const note =\n- \\\\areas\n+ \\\\areas, defer\n+ \\\\summed\n ;\n };\n -start 31 100 change.diff -wait 8000 Newcol Joincol -stable 700 20000 -snap diff-pane -snapstyle diff-colours -press right 8 15 -release right 8 15 -stable 700 15000 -snap look-added-line -# The same diff printed by a command (`git diff`, here `cat`) into a command -# pane: its output is told for a diff and coloured the same, over the colours -# the program printed, and a right click on a `+` there opens the file too. -file cmds.txt cat change.diff\n -start 31 100 cmds.txt -wait 8000 cmds.txt -stable 700 20000 -press middle 7 4 -drag middle 22 4 -release middle 22 4 -wait 10000 exit 0 -stable 700 15000 -snap command-pane -snapstyle command-colours -press right 3 21 -release right 3 21 -stable 700 15000 -snap command-look diff --git a/test/snapshots/dirpane.snap b/test/snapshots/dirpane.snap deleted file mode 100644 index a884b12e..00000000 --- a/test/snapshots/dirpane.snap +++ /dev/null @@ -1,27 +0,0 @@ -# a look at a directory opens a pane named for it with a trailing /, its -# entries in columns as acme's directory window lays them out: down each -# column first, a directory's marked /, dotfiles shown. A look at an entry -# opens it from that directory. No shell anywhere: nothing here races a prompt. -dirmk sub -dirmk sub/deeper -file sub/inner.txt inner-marker -file sub/.hidden x -file sub/alpha.txt x -file sub/beta-gamma.txt x -file sub/zeta x -file top.txt sub -config Verbose off -start 24 80 top.txt -wait 8000 top.txt -stable 700 20000 -press right @sub 4 -release right @sub 4 -wait 8000 inner.txt -stable 700 20000 -snap dir-open -# an entry, by its name alone: sub's inner.txt -press right @inner.txt 7 -release right @inner.txt 7 -wait 8000 inner-marker -stable 700 20000 -snap entry-open diff --git a/test/snapshots/edit.snap b/test/snapshots/edit.snap deleted file mode 100644 index f1234741..00000000 --- a/test/snapshots/edit.snap +++ /dev/null @@ -1,15 +0,0 @@ -# insert-mode splice: click into a body row, type, escape back to normal -file e.txt x -start 31 100 -n 3 -wait 8000 e.txt -stable 700 20000 -press left 5 11 -release left 5 11 -stable 400 8000 -key i -text hello-insert -key esc -settle 100 -stable 500 8000 -snap inserted -snapstyle inserted diff --git a/test/snapshots/fileedit.snap b/test/snapshots/fileedit.snap deleted file mode 100644 index 8b924ebd..00000000 --- a/test/snapshots/fileedit.snap +++ /dev/null @@ -1,42 +0,0 @@ -# file panes: modal editing on real content, undo, Save writes to disk -lines f.txt 20 -start 31 150 -n 3 -wait 8000 f.txt -stable 700 20000 -press left 5 9 -release left 5 9 -stable 400 5000 -key i -text f.txt -key esc -settle 100 -press right 6 9 -release right 6 9 -wait 10000 line 3 -stable 700 15000 -# edit line 1: click it, insert, esc -press left 10 8 -release left 10 8 -stable 400 5000 -key i -text EDIT''ME -key esc -settle 100 -stable 400 5000 -snap edited -# x-select line 2 and delete it -key j g h -stable 400 5000 -key x d -stable 400 5000 -snap deleted -key u -stable 400 5000 -snap undone -# Save through the file pane's own tag: `:` focuses that same tag and `w` -# selects Save before the ordinary execute key runs it. -key : -stable 400 5000 -key w tab -stable 600 8000 -snapfile saved /tmp/pardes-snap/fileedit/cwd/f.txt diff --git a/test/snapshots/find.snap b/test/snapshots/find.snap deleted file mode 100644 index 17470040..00000000 --- a/test/snapshots/find.snap +++ /dev/null @@ -1,71 +0,0 @@ -# SPC f f: a query pane under the pane (Query.zig), line 1 `Find `, typed -# into. The files below the pane's directory are listed once, on the disk -# engine's worker (rg --files when it is on PATH, else the sorted walk: both -# pass over .git), and each key scores them fuzzily (pick's scorer), the best -# first, the matched letters tinted. The current one is shown in the -# +Preview under the query pane, born with it so nothing moves later; -# Ctrl-n / Ctrl-p step it, never the pointer. Enter makes the preview the -# file's pane where it stands. Esc while typing closes the query pane and -# gives its rows back. A query that matches nothing is a count of 0, not an -# exit. B2 on `Find` with a selection asks with that word, the keyboard -# staying in the text. -dirmk sub -dirmk sub/nest -dirmk .git -file here.txt Find zqm -file zqmark-alpha.txt alpha body -file sub/ZQMARK-beta.txt beta body -file sub/nest/zqmark-gamma.txt gamma body -file other.txt nothing to match here -file .git/zqmark-hidden.txt hidden body -start 41 120 here.txt -wait 8000 here.txt -stable 700 20000 -# SPC f is a group (Find, New, Save, Recent, Grep): the indicator waits -key space -key f -stable 400 5000 -snap group -# the second f opens the query pane: every file listed, line 1 `Find ` -key f -wait 10000 zqmark-alpha.txt -stable 700 15000 -snap armed -text zqm -stable 700 15000 -snap typing -# the next one current, its text in the preview -key c-n -wait 10000 beta body -stable 700 15000 -snap next -# Enter: the preview is that file's pane now, where it stood -key enter -stable 700 15000 -snap promoted -# a second Find from here.txt reuses its query pane; nothing found is 0 -press left 8 4 -release left 8 4 -stable 400 5000 -key space -key f -key f -text zzqq -stable 700 15000 -snap nomatch -# Esc: the kept rows of the last query are back -key esc -settle 100 -stable 700 15000 -snap cancel -# B2 on Find with `zqm` selected in here.txt: the query pane under it, the -# keyboard still in here.txt -press left 13 4 -drag left 15 4 -release left 15 4 -stable 400 5000 -press middle @Find 1 -release middle @Find 1 -wait 10000 Find zqm -stable 700 15000 -snap topbar diff --git a/test/snapshots/follow.snap b/test/snapshots/follow.snap deleted file mode 100644 index 0e5d23a2..00000000 --- a/test/snapshots/follow.snap +++ /dev/null @@ -1,20 +0,0 @@ -# Follow (SPC c f) twice on a 300-line file: three pages in three columns, -# each going on the line after the one before ends; Unfollow on the two -# followers' tags only. Then j past the first page's last row takes the -# keyboard to the second page without scrolling, and a wheel notch in the -# last page moves all three. -lines big.txt 300 -start 30 150 big.txt -wait 8000 big.txt -stable 500 15000 -key space c f -stable 500 8000 -key space c f -stable 500 8000 -snap three-pages -text 27j -stable 500 8000 -snap hop -wheel down 120 12 -stable 500 8000 -snap wheel diff --git a/test/snapshots/fsearch.snap b/test/snapshots/fsearch.snap deleted file mode 100644 index fbb9baeb..00000000 --- a/test/snapshots/fsearch.snap +++ /dev/null @@ -1,61 +0,0 @@ -# `/` in a file: its query pane under it (Query.zig), line 1 `/` and the -# pattern, typed into; nothing on the notice band. Each key searches the -# file again (a regex, any case unless it has a capital): every match is -# tinted and ticked on the scroll rail, the first at or after the cursor -# selected and in view, and the rows under line 1 are the lines holding a -# match, a line number in the gutter. Ctrl-n steps while typing; Enter puts -# the keyboard on the match, the pattern in `/`, and keeps the rows as text; -# n / N then step the matches in the file, round the end without a word. A -# later `/` reuses the pane; Esc while typing brings the kept rows back. A -# pattern that matches nothing is a count of 0, not an exit. -file g.txt l1\nMARK a\nl3\nl4\nl5\nMARK b\nl7\nl8\nl9\nMARK c\nl11\nl12 -# Builtins announce themselves by default, and an announcement is a band at -# the top of the body -- which moves every row this script clicks. What the -# verbs do is what is under test, not the announcement. -config Verbose off -start 31 180 -n 3 -wait 8000 g.txt -stable 700 20000 -# open g.txt: type the name in the shell, look it (as in look-file.snap) -press left 5 9 -release left 5 9 -stable 400 5000 -key i -text g.txt -key esc -settle 100 -stable 400 5000 -press right 6 9 -release right 6 9 -wait 10000 MARK a -stable 700 15000 -snap opened -key / -stable 400 5000 -snap slash -text MARK -stable 400 5000 -snap typing -snapstyle typing -key c-n -stable 400 5000 -snap ctrln -key enter -stable 700 10000 -snap landed -text n -stable 400 5000 -snap n -text N -stable 400 5000 -snap N -key / -text zz -key esc -settle 100 -stable 400 5000 -snap cancel -key / -text zzqq -stable 700 10000 -snap nomatch diff --git a/test/snapshots/grep.snap b/test/snapshots/grep.snap deleted file mode 100644 index 16e61d20..00000000 --- a/test/snapshots/grep.snap +++ /dev/null @@ -1,61 +0,0 @@ -# The Grep builtin (topbar word, `SPC f g`): the query pane under the pane -# that asked, line 1 `Grep ` and the text, the lines of the files below its -# directory holding it (literally, any case unless it has a capital), on the -# disk engine's worker once the typing pauses: rg --json when it is on PATH, -# else the sorted walk. The rows sit under their file's name, a line number -# in the gutter. A hit in a file an open pane shows is shown there; one in a -# file nothing shows, in the +Preview under the query pane, which Enter makes -# the file's pane. A query that matches nothing is a count of 0, and Esc -# while typing brings the kept rows back. -dirmk sub -file a.txt hello TARGET one\nnothing here\nlast TARGET line -file sub/b.txt deep\nTARGET inside sub -file noise.txt nothing to see -config Verbose off -start 31 180 -n 3 -wait 8000 a.txt -stable 700 20000 -press left 5 9 -release left 5 9 -stable 400 5000 -key i -text a.txt -key esc -settle 100 -stable 400 5000 -press right 6 9 -release right 6 9 -wait 10000 hello TARGET -stable 700 15000 -snap opened -# middle-click Grep on the topbar: the query pane under a.txt, typed into -press middle @Grep 1 -release middle @Grep 1 -stable 400 5000 -text TARGET -# three lines (the pane is short: its count says how many) -wait 10000 +Search 1/3 -stable 700 15000 -snap typing -# a.txt's hits are shown in a.txt; sub/b.txt's in the preview -key c-n -stable 700 15000 -snap second -key c-n -wait 10000 deep -stable 700 15000 -snap preview -key enter -stable 700 15000 -snap opened-hit -key space -key f -key g -stable 400 5000 -text zzqq -stable 700 10000 -snap nomatch -key esc -settle 100 -stable 400 5000 -snap esc diff --git a/test/snapshots/hscroll.snap b/test/snapshots/hscroll.snap deleted file mode 100644 index 05366323..00000000 --- a/test/snapshots/hscroll.snap +++ /dev/null @@ -1,48 +0,0 @@ -# horizontal scroll, file panes only (terminals wrap at pty width): the -# horizontal wheel shifts the content window (gutter stays put, no scrollbar), -# and keyboard movement keeps the scrolloff margin sideways — $ on a long -# line pulls the view right, 0 snaps it back. Overscroll right is allowed; -# a cursor move reels it in. -file wide.txt short1 END_A_MARKER_WAY_OUT_RIGHT_padpadpadpadpadpadpadpadpadpadpadpadpadpad_TAIL -start 31 90 -n 3 -wait 8000 wide.txt -stable 700 20000 -# soft wrap is ON by default and a wrapped body has nothing to scroll sideways -# — hscroll is what you get when you turn it OFF, so this whole script runs -# with it off. SPC t w is global, so it is spent once, before the file exists. -key space t w -stable 400 5000 -# open wide.txt: click a body spot, type the name, look it -press left 5 9 -release left 5 9 -stable 400 5000 -key i -text wide.txt -key esc -settle 100 -stable 400 5000 -press right 7 9 -release right 7 9 -stable 700 15000 -snap opened -# wheel right over the file pane: content shifts, line numbers stay -send \x1b[<66;10;8M -send \x1b[<66;10;8M -stable 400 5000 -snap wheeled -# wheel back left past the start clamps at column 0 -send \x1b[<67;10;8M -send \x1b[<67;10;8M -send \x1b[<67;10;8M -stable 400 5000 -snap clamped -# gl walks the cursor to the line end: the view follows with the margin -key g g -stable 400 5000 -key g l -stable 400 5000 -snap dollar -# 0 back to column zero: the view snaps home -key 0 -stable 400 5000 -snap zero diff --git a/test/snapshots/jumps.snap b/test/snapshots/jumps.snap deleted file mode 100644 index 0c8919e6..00000000 --- a/test/snapshots/jumps.snap +++ /dev/null @@ -1,117 +0,0 @@ -# RULE: there is ONE focus history and it is a stack of LOCATIONS — a pane and -# a spot in it. Ctrl-o walks it back, Ctrl-i walks it forward again, `SPC j j` -# (Last) hops to the newest OTHER pane, and `SPC j l` (Jumplist) writes the -# same stack out as an output buffer whose rows are ordinary look targets, so -# n/N step them. What gets ONTO the stack is decided in one place (trackJump): -# focus ended the update in a different pane, or more than a bodyful of rows -# away in the same one — which is why `100G` below leaves a location behind -# and the j/k that follow it do not. -# -# Focus and position both show in the golden's `cursor=` header: that is the -# ACTIVE pane's cursor, so each snap is named by where it should land. -lines big.txt 200 -start 31 150 big.txt -wait 8000 big.txt -stable 700 20000 -# a FILE boots alone now, so this is one column holding big.txt, focused, and -# the stack is one entry deep -snap start -# two focus moves. The shell has to be opened before it can be walked to -# (`New`/`Newcol` open an empty +New scratch now, so the shell is asked for by -# name): Alt-n opens it AND focuses it, Alt-c moves it into a column of its -# own on the right — so opening it IS the first of the two moves, and the -# stack below is the same one a shell at boot left. Walking straight back to -# the file does NOT leave `file -> shell -> file` behind: a hop to the entry -# under the top one is the same two places again, so trackJump swaps them -# rather than appending, and the stack is `shell -> file` with the file on top -# (see trackJump). -key a-n -key a-c -stable 700 15000 -snap to-shell -key space w h enter -stable 400 5000 -snap to-file -# a FAR motion inside one pane: 100G is a jump, so the line we left is -# remembered and Ctrl-o can come back to it -text 100 -key G -stable 400 5000 -snap goto-100 -# Ctrl-o: back to line 1 of the same pane — a stack of panes could not do this -key c-o -stable 400 5000 -snap back-in-file -# ...and back again into the shell -key c-o -stable 400 5000 -snap back-to-shell -# Ctrl-i forward, twice: back to line 1 of the file, then line 100 again. Sent as the -# kitty-protocol CSI u (`CSI 105;5u`) because on the wire Ctrl-i IS Tab — -# see config.jump_keys. -send \e[105;5u -stable 400 5000 -snap forward-file -send \e[105;5u -stable 400 5000 -snap forward-100 -# SPC j j — the newest OTHER pane, and pressing it again comes straight back -key space j j -stable 400 5000 -snap last -key space j j -stable 400 5000 -snap last-back -# SPC j l — the stack as text: `location text` rows, the file naming itself -# and the shell spelled @pN because it has no path -key space j l -stable 700 15000 -snap jumplist -# n/N select the next/prev row and Enter looks it, exactly as they do a -# +Search: the stepped span is selected in the buffer (snapstyle) and the Enter -# after it moves the pane the row names. Row 1 is the shell (no path, so -# `@pN`), row 2 the file at line 1, row 4 the file at line 100 — so the body -# visibly rides the list. -# -# ONE PRESS PER ROW, and this buffer is where that rule earns itself: an `@pN` -# row's trailing text is the pane's DIRECTORY, which is a look-able word of its -# own, so rows 1 and 3 used to hold TWO stops each and reaching the next row -# took two steps. A results buffer is a LIST — its rows are locations, and the -# text after one says what is THERE rather than naming another place to go — so -# the walk takes the location at the head of a row and moves on to the next row -# (output_pane.Grain.line). Free text still steps every word. -# -# An `@pN` row moves focus like any other, which it did not use to: the STEP -# only selects now, and the look Enter runs goes to the pane by the same route -# a path takes. -key space j n -key enter -stable 700 15000 -snap step1-shell -snapstyle step1-shell -# on to row 2 — one press, the directory on row 1 is no longer a stop of its own -key space j n -key enter -stable 700 15000 -snap step2-file -# row 3 is the shell again, then row 4 -key space j n -stable 400 5000 -key space j n -key enter -stable 700 15000 -snap step4-line100 -# N is the exact inverse: one press back onto row 3's location, and Enter -# follows it to the shell -key space j p -key enter -stable 700 15000 -snap step-back -# and an ordinary LOOK on a row goes there too — the leading word IS a -# location, so the right-click look resolves it like any other path. Row 4 -# again, this time by clicking it: the list shows every row, and its row 4 is -# screen row 21. -press right 16 21 -release right 16 21 -stable 700 15000 -snap look-row diff --git a/test/snapshots/look-center.snap b/test/snapshots/look-center.snap deleted file mode 100644 index 25fb64b0..00000000 --- a/test/snapshots/look-center.snap +++ /dev/null @@ -1,36 +0,0 @@ -# a look on path:NN opens the file with the target line CENTERED in the body -# (scroll = line - body/2): fresh open at a deep line, then dedup re-looks at -# the same path re-center the existing pane, and a look near line 1 clamps -# the scroll at 0 (no negative scroll) -lines big.txt 200 -start 31 150 -n 3 -wait 8000 big.txt -stable 700 20000 -press left 5 9 -release left 5 9 -stable 400 5000 -key i -text big.txt:100 big.txt:150 big.txt:2 -key esc -settle 100 -stable 400 5000 -press right 7 9 -release right 7 9 -stable 700 15000 -snap center-open -# The narrow-window split keeps the source shell above the new file. Use the -# unchanged right-hand shell for the remaining references, so they stay visible. -press left 80 9 -release left 80 9 -key i -text big.txt:150 big.txt:2 -key esc -stable 400 5000 -press right 82 9 -release right 82 9 -stable 700 15000 -snap center-dedup -press right 94 9 -release right 94 9 -stable 700 15000 -snap center-clamp diff --git a/test/snapshots/look-file-1col.snap b/test/snapshots/look-file-1col.snap deleted file mode 100644 index 1b23e054..00000000 --- a/test/snapshots/look-file-1col.snap +++ /dev/null @@ -1,18 +0,0 @@ -# single narrow column (-n 1): the first document splits below its source -# shell, like Term. A new column would require at least 200 cells of width. -lines big.txt 60 -start 31 100 -n 1 -wait 8000 big.txt -stable 700 20000 -press left 5 9 -release left 5 9 -stable 400 5000 -key i -text big.txt:40 -key esc -settle 100 -stable 400 5000 -press right 7 9 -release right 7 9 -stable 700 15000 -snap file-open-1col diff --git a/test/snapshots/look-file.snap b/test/snapshots/look-file.snap deleted file mode 100644 index a6140155..00000000 --- a/test/snapshots/look-file.snap +++ /dev/null @@ -1,19 +0,0 @@ -# right-click look on a typed path:NN opens a file pane scrolled to the line; -# Enter chord on the same path focuses the existing pane (dedup) -lines big.txt 60 -start 31 150 -n 3 -wait 8000 big.txt -stable 700 20000 -press left 5 9 -release left 5 9 -stable 400 5000 -key i -text big.txt:40 -key esc -settle 100 -stable 400 5000 -press right 7 9 -release right 7 9 -stable 700 15000 -snap file-open -snapstyle file-open diff --git a/test/snapshots/lookloaded.snap b/test/snapshots/lookloaded.snap deleted file mode 100644 index 1f920a93..00000000 --- a/test/snapshots/lookloaded.snap +++ /dev/null @@ -1,48 +0,0 @@ -# a look matches an already-LOADED pane before touching the filesystem: open -# big.txt:40 from a look, rm the file on disk, then look big.txt:10 — the -# loaded pane focuses and recenters even though realpath now fails. (This -# fs-last ordering is what lets the fs-less web build focus dump panes.) -lines big.txt 60 -start 31 100 -n 3 -wait 8000 big.txt -stable 700 20000 -press left 5 9 -release left 5 9 -stable 400 5000 -key i -text big.txt:40 big.txt:10 -key esc -settle 100 -stable 400 5000 -press right 7 9 -release right 7 9 -stable 700 15000 -snap file-open -# Use the unrelated right-hand shell to remove the file: the source shell now -# stays above its file and is only a few rows tall. -press left 70 12 -release left 70 12 -stable 400 5000 -key c-b -stable 600 8000 -text rm big.txt; echo GO''NE -key enter -wait 8000 GONE -stable 700 15000 -key c-b -stable 600 8000 -snap removed -# look big.txt:10: nothing on disk, but the pane is loaded — it focuses and -# recenters on line 10 (before this change: realpath fails, look no-ops) -# Put a fresh reference in the right-hand shell, then look it. This ensures the -# gesture hits the missing path rather than empty space after source resizing. -press left 55 9 -release left 55 9 -key i -text big.txt:10 -key esc -stable 400 5000 -press right 57 9 -release right 57 9 -stable 700 15000 -snap look-noFS diff --git a/test/snapshots/lookpanes.snap b/test/snapshots/lookpanes.snap deleted file mode 100644 index 4bbc37d6..00000000 --- a/test/snapshots/lookpanes.snap +++ /dev/null @@ -1,95 +0,0 @@ -# a look resolves against EVERY open pane's directory, in access order: the -# pane the click came from first, then the rest most-recently-focused first, -# and only a word NO directory holds falls through to a search. Two dirs -# (alpha, beta) hold same-named files and the shell's own cwd holds none of -# them, so every look below would have been a search before. alpha's pane -# is its directory window (a look at a directory opens a pane listing it), -# whose directory is alpha. -dirmk alpha -dirmk beta -file zzboot.txt x -file alpha/amark.txt a -file alpha/zqonly.txt ONLY-IN-ALPHA -file alpha/pick.txt PICK-FROM-ALPHA -file alpha/twin.txt TWIN-FROM-ALPHA -file alpha/both.txt BOTH-FROM-ALPHA -file beta/pick.txt PICK-FROM-BETA -file beta/twin.txt TWIN-FROM-BETA -file beta/both.txt BOTH-FROM-BETA -# the file argument opens a pane whose directory is beta's, and nothing else — -# so the workdir shell every look below falls through is opened with Alt-n -# (`New`/`Newcol` open an empty +New scratch now, and one inheriting beta's -# directory at that) and Alt-c puts it in a column of its own on the right; -# its first line is a word to look FROM that pane -file beta/bmark.txt both.txt\nb-marker -# Builtins announce themselves by default, and an announcement is a band at -# the top of the body -- which moves every row this script clicks. What the -# verbs do is what is under test, not the announcement. -config Verbose off -start 51 130 beta/bmark.txt -wait 8000 b-marker -stable 700 20000 -key a-n -key a-c -wait 8000 zzboot.txt -stable 700 20000 -key space w h -stable 400 5000 -# an ordinary dir look on the shell's own ls output: alpha's directory pane, -# split below it, which takes the keyboard -press right @alpha 6 -release right @alpha 6 -wait 10000 amark.txt -stable 700 20000 -# type the words to look into what is left of the workdir shell (past its own -# ls output, on the same row: its last row is the resize handle) -press left 95 5 -release left 95 5 -stable 400 5000 -key i -text zqonly.txt pick.txt twin.txt -key esc -settle 100 -stable 400 5000 -snap shells -# make the beta pane the most recently focused, so the walk has to pass it -press left 10 5 -release left 10 5 -stable 700 10000 -# zqonly.txt is only under alpha: the clicked shell's cwd fails, beta fails, -# alpha's directory pane answers. Before, this word became a search. -press right @zqonly.txt 5 -release right @zqonly.txt 5 -wait 10000 ONLY-IN-ALPHA -stable 700 20000 -snap other-dir -# both.txt is in BOTH dirs and alpha is now the most recent (its file pane -# just opened), but the CLICK still wins: looked inside the beta pane it -# opens beta's copy -press right 10 5 -release right 10 5 -wait 10000 BOTH-FROM-BETA -stable 700 20000 -snap clicked-wins -# from a pane whose own dir holds neither copy the access order decides: -# focus alpha's directory pane (a click on its first row), look pick.txt (in -# both dirs) from the workdir shell -> alpha's -press left @amark.txt 9 -release left @amark.txt 9 -stable 700 10000 -press right @pick.txt 5 -release right @pick.txt 5 -wait 10000 PICK-FROM-ALPHA -stable 700 20000 -snap mru-alpha -# focus the beta pane instead and the same look flips: twin.txt is in both -# dirs, beta is most recent, beta's copy opens -press left 10 5 -release left 10 5 -stable 700 10000 -press right @twin.txt 5 -release right @twin.txt 5 -wait 10000 TWIN-FROM-BETA -stable 700 20000 -snap mru-beta -snapstyle mru-beta diff --git a/test/snapshots/lookrange.snap b/test/snapshots/lookrange.snap deleted file mode 100644 index 5133e911..00000000 --- a/test/snapshots/lookrange.snap +++ /dev/null @@ -1,74 +0,0 @@ -# RANGED LOOK PATHS. `path:LINE:COL` says where to PARK; a range says what to -# SELECT, and it belongs to the PATH (config.range_sep) rather than to the -# search that is merely the first thing writing one. So this script right- -# clicks the three spellings as ordinary words sitting in a file: -# r.txt:3-5 whole lines 3 through 5 -# r.txt:7:4-9 line 7, columns 4 through 9 -# r.txt:3:2-5:3 line 3 column 2 through line 5 column 3 -# ...and only then presses `/`, whose result rows are exactly this syntax — -# which is how n/N select a hit and Enter lands on it with the matched text -# selected. -# -# `snapstyle` is the assertion that matters: the grid TEXT after a ranged look -# is the same text a plain `:LINE:COL` look leaves, so the selection only shows -# in the styles. -file r.txt aaaa\nbbbb\ncccc dccc\ndddd\neeee\nffff\ngg NEEDLE gg\nhhhh NEEDLE\niiii -file look.txt r.txt:3-5\nr.txt:7:4-9\nr.txt:3:2-5:3\nr.txt:8:6-99:9 -# Builtins announce themselves by default, and an announcement is a band at -# the top of the body -- which moves every row this script clicks. What the -# verbs do is what is under test, not the announcement. -config Verbose off -start 31 150 look.txt -wait 8000 r.txt:3-5 -stable 700 20000 -snap opened -# --- form 1: whole lines. r.txt opens BELOW look.txt (an ordinary look) with -# lines 3, 4 and 5 selected whole, terminators included — helix's own `x`. -press right 10 4 -release right 10 4 -wait 10000 cccc dccc -stable 700 15000 -snap wholelines -snapstyle wholelines -# --- form 2: one line, a column span. r.txt is open now, so this re-uses that -# pane (focusPaneByPath) — the same route a `/` result row takes. -press right 12 5 -release right 12 5 -stable 700 15000 -snap onelinespan -snapstyle onelinespan -# --- form 3: the general one, across both lines and columns -press right 12 6 -release right 12 6 -stable 700 15000 -snap fullspan -snapstyle fullspan -# --- a STALE range: line 99 of a nine-line file, which is what a result row -# looks like once the file has changed underneath it. It must CLAMP — no crash, -# no garbage highlight — landing on the last cell that really exists. -press right 12 7 -release right 12 7 -stable 700 15000 -snap stale -snapstyle stale -# --- and `/`: its query pane under r.txt, line 1 the pattern, the lines -# holding it as rows (a line number in the gutter, the match tinted); Enter -# puts the keyboard on the match after the cursor, the word itself selected. -key / -text NEEDLE -wait 10000 gg NEEDLE gg -stable 700 15000 -key enter -stable 700 15000 -snap hit1 -snapstyle hit1 -# n: the next match in the text, selected -text n -stable 700 15000 -snap hit2 -snapstyle hit2 -# N walks back onto the first, still selected -text N -stable 700 15000 -snap back -snapstyle back diff --git a/test/snapshots/lsp-client-edit.snap b/test/snapshots/lsp-client-edit.snap deleted file mode 100644 index 456f5555..00000000 --- a/test/snapshots/lsp-client-edit.snap +++ /dev/null @@ -1,35 +0,0 @@ -# The protocol client's MUTATING answers, through the @put record path: a -# server TextEdit response becomes one atomic buffer edit with one undo step. -# = applies the mock's formatting edit (a header line) and narrates -# "formatted 1 range(s)" on the message row -# SPC l r renames both `add` calls via the server's WorkspaceEdit -# u reverses each as a single transaction -file main.rs mod lib;\n\nfn main() {\n let x = add(1, 2);\n let y = add(3, 4);\n let _ = x + y;\n}\n -file lib.rs // mock fixture\npub fn add(a: i32, b: i32) -> i32 {\n a + b\n}\n -start 25 100 main.rs -wait 8000 add(1, 2) -stable 700 20000 -key = -wait 10000 formatted by mock -stable 700 15000 -snap formatted -key u -wait 8000 mod lib; -stable 700 15000 -snap unformatted -# rename through the leader prompt: both call sites change in one step -press left 13 6 -release left 13 6 -key space -key l -key r -stable 400 5000 -text sum -key enter -wait 10000 sum(3, 4) -stable 700 15000 -snap renamed -key u -wait 8000 add(3, 4) -stable 700 15000 -snap unrenamed diff --git a/test/snapshots/lsp-client.snap b/test/snapshots/lsp-client.snap deleted file mode 100644 index 159bf80e..00000000 --- a/test/snapshots/lsp-client.snap +++ /dev/null @@ -1,40 +0,0 @@ -# The protocol client end to end, against the deterministic mock server the -# harness pins via PARDES_LSP_RS (test/lspmock.zig). What this exercises is -# everything BETWEEN the keymap and the analyser: spawn, handshake, the reader -# thread, $/progress narration onto the transient message row, and the -# location shapes coming back as +Search rows. -# gd on a cross-file Location -> a look: lib.rs opens with `add` selected, -# and the message row still carries the server's settled state -# ("lsp lspmock: ready") because nothing has cleared it yet. -# gr -> the text's query pane, line 1 `Refs`, rows under their files, -# the next occurrence current, the keyboard on it in normal mode -# (a list answered, not a query typed); n/N step the places. -file main.rs mod lib;\n\nfn main() {\n let x = add(1, 2);\n let y = add(3, 4);\n let _ = x + y;\n}\n -file lib.rs // mock fixture\npub fn add(a: i32, b: i32) -> i32 {\n a + b\n}\n -start 25 100 main.rs -wait 8000 add(1, 2) -stable 700 20000 -# cursor into the first `add` call, then helix's goto-definition -press left 13 6 -release left 13 6 -key g -key d -wait 10000 pub fn add -stable 700 15000 -snap gd-jumped -# references from the definition the look landed on (cursor sits on `add`) -key g -key r -wait 10000 add(3, 4) -stable 700 15000 -snap gr-list -# the list opens in normal mode, the caret on the current row: n steps to -# the next hit, Enter lands there; N in the text goes back to the one -# before, round the places in main.rs -key n -key enter -stable 700 15000 -snap gr-opened -text N -stable 700 15000 -snap gr-back diff --git a/test/snapshots/lsp-rename-files.snap b/test/snapshots/lsp-rename-files.snap deleted file mode 100644 index 0114c795..00000000 --- a/test/snapshots/lsp-rename-files.snap +++ /dev/null @@ -1,29 +0,0 @@ -# A Rename reaches the other files open in the editor. A server renames in -# the documents it has seen (zls's store), so before a query whose answer can -# reach other files the client tells it of every open file of its language. -# Here main.rs is opened by a look, asking the server nothing, and the rename -# is asked from lib.rs: the mock answers in each document it was told of, so -# the preview lists main.rs's two calls and lib.rs's definition. -file lib.rs // main.rs\npub fn add(a: i32, b: i32) -> i32 {\n a + b\n}\n -file main.rs mod lib;\n\nfn main() {\n let x = add(1, 2);\n let y = add(3, 4);\n let _ = x + y;\n}\n -start 25 100 lib.rs -wait 8000 pub fn add -stable 700 20000 -press right @main.rs 4 -release right @main.rs 4 -wait 8000 let x = add -stable 700 15000 -snap opened -# into lib.rs's `add`, and rename it from there -press left @add 5 -release left @add 5 -stable 400 5000 -key space -key l -key r -stable 400 5000 -text sum -key enter -wait 10000 sum -stable 700 15000 -snap previewed diff --git a/test/snapshots/lsp-rename.snap b/test/snapshots/lsp-rename.snap deleted file mode 100644 index 63ca21db..00000000 --- a/test/snapshots/lsp-rename.snap +++ /dev/null @@ -1,27 +0,0 @@ -# Rename end to end: the leader prompt, async ZLS resolution, atomic file edit, -# shadow filtering, and one-step undo/redo. The source has a same-spelled local -# which must not be changed when the top-level helper is renamed. -file rename.zig const std = @import("std");\n\nfn helper(x: u32) u32 {\n return x + 1;\n}\n\npub fn main() void {\n _ = helper(41);\n}\n\nfn shadowed() void {\n const helper: u32 = 7;\n _ = helper;\n}\n -start 25 110 rename.zig -wait 8000 helper(41) -stable 700 20000 -# Put the cursor inside the top-level call, then use the helix rename binding. -press left 18 11 -release left 18 11 -key space -key l -key r -stable 400 5000 -text renamed_helper -key enter -wait 10000 renamed_helper(41) -stable 700 15000 -snap renamed -# Both resolved top-level occurrences changed; the shadowed local stayed helper. -# The whole asynchronous rename is one history transaction. -key u -stable 400 5000 -snap undone -key U -stable 400 5000 -snap redone diff --git a/test/snapshots/lsp.snap b/test/snapshots/lsp.snap deleted file mode 100644 index 123fad93..00000000 --- a/test/snapshots/lsp.snap +++ /dev/null @@ -1,57 +0,0 @@ -# Language intelligence end to end: the helix keymap, the async round trip and -# the two dispositions of an answer. -# -# The backend behind the seam here is zls, run as a child process by the -# protocol client (it must be on PATH): `gd` is a request on a worker thread -# whose result comes back as an ordinary event, the same shape a pty read -# already had. Nothing in this script knows that: it presses keys and reads -# the grid, which is the point of the seam. -# -# a.zig is deliberately self-contained — a definition, a call site, and not one -# symbol from std — so these goldens do not encode this machine's stdlib -# version or its install path. -file a.zig const std = @import("std");\n\nfn helper(x: u32) u32 {\n return x + 1;\n}\n\npub fn main() void {\n _ = helper(41);\n}\n -start 41 120 a.zig -wait 8000 helper -stable 700 20000 -snap opened -# park the cursor inside the CALL `helper(41)` (file line 8, grid row 9) -press left 18 11 -release left 18 11 -stable 400 5000 -snap cursor -# gd on a call: exactly one location comes back, so it JUMPS rather than -# opening a picker — and lands SELECTING the definition's name token on line 3, -# because ZLS answers with a range and a ranged row is one a look selects. -# The jumplist is pinned first, so ctrl-o comes back. -key g -key d -stable 700 15000 -snap definition -# SPC l k is hover (K is keep_selections in helix and stays that way). The answer -# is prose, not locations, so it opens +Hover and does NOT arm the n/N stepper. -key space -key l -key k -stable 700 15000 -snap hover -# SPC l s lists the file's own symbols. Several rows, so it opens a +Search -# buffer — which IS the picker: n selects a row and Enter looks it, exactly as -# the Find and `/` results already do, with no picker code of its own. -key space -key l -key s -stable 700 15000 -snap symbols -key space j n -key enter -stable 700 15000 -snap step -# gd on something with no declaration behind it (a keyword) answers nothing, -# and nothing is a legal answer: no buffer opens, no error is rendered. -press left 8 6 -release left 8 6 -key g -key d -stable 700 10000 -snap nothing diff --git a/test/snapshots/lspcomplete.snap b/test/snapshots/lspcomplete.snap deleted file mode 100644 index 5c76aac8..00000000 --- a/test/snapshots/lspcomplete.snap +++ /dev/null @@ -1,157 +0,0 @@ -# Tab after a dot in insert mode: "what could go here". -# -# Each wait for zls's answer allows a minute: it returns as soon as the answer -# is drawn (2 s alone), and a zls slowed by a loaded machine (the parallel -# snap run) took over 15 s, which failed the old wait. The answer is a -# `+Search` buffer of zls's candidates, one row each at the cursor (a -# completion item names no declaration) — nothing is inserted and nothing pops -# up. -# -# a.zig is std-free for the reason lsp.snap's is: these goldens must not encode -# this machine's stdlib version or its install path. Its enum members are -# nonsense words, and the dot is TYPED into an empty switch body, so a row -# naming line 2 or 3 can only have come from a member's declaration — the line -# the cursor is on is line 8 and holds nothing but the dot. -# -# Typing it is the point rather than pointing at one already there: the moment -# the dot lands the file STOPS PARSING (`switch (s) { . }` loses the whole -# switch to the parser's error recovery), and that is the normal input to a -# completion, not a corner case. -# -# The helix corpora cannot reach any of this — hxOpenFileContent names its pane -# `/hxcase.txt`, so lsp.speaks is false for all 1042 cases — which makes this -# script the only end-to-end coverage the feature has. -file a.zig const Shade = enum {\n verdigris,\n cinnabar,\n};\n\nfn pick(s: Shade) u8 {\n return switch (s) {\n \n };\n}\n\n// note. see below\n -file notes.txt abc.def ghi\n -start 41 120 a.zig -wait 8000 verdigris -stable 700 20000 -snap opened -# Tab with no dot before it is still Tab: line 10 is the closing `}`, and this -# is the plain insert_tab path putting spaces in front of it. -press left 8 13 -release left 8 13 -key i -key tab -stable 400 5000 -snap indent -key esc -settle 100 -# A dot the backend cannot answer must STILL indent. Line 12 is a comment, so -# the position context is `.comment` and no candidate can exist — and because -# Tab had already diverted to the backend, the indent has to happen -# retroactively when the empty answer arrives (lspResponse), on the condition -# that the cursor has not moved meanwhile. Four spaces go in after `// note.` -# and the keystroke is not eaten, which is the whole contract. -press left 16 15 -release left 16 15 -stable 400 5000 -key i -key tab -stable 700 15000 -snap commentindent -key esc -settle 100 -# Line 8 (grid row 9, 1-based click row 10) is the switch's empty body. End -# puts the cursor past its indent, and then the dot is typed. -press left 8 11 -release left 8 11 -stable 400 5000 -key i -key end -text . -stable 400 5000 -snap athedot -key tab -# The rows that prove it: `verdigris` and `cinnabar` can only have come from -# resolving the switch's condition to `Shade` and asking what it declares. -# Line 8 still reads `.` and nothing else — a completion INSERTS NOTHING. -wait 60000 +Search -stable 700 30000 -snap completion -# Two more Tabs. Every one of them answers, and every answer REFILLS the one -# `+Search` rather than opening its twin. The SECOND press is already the whole -# assertion: without the refill it leaves a second byte-identical `+Search` and -# this golden diverges. What TWENTY do is only worse in degree — fifteen -# stacked panes, the file crushed to one visible line, and from the sixteenth -# on freeSlot returns null and the keystroke is eaten for the rest of the -# session — and that story is told here rather than replayed in three seconds of -# every suite run. One file pane, one results pane, same as after the first. -key tab -settle 150 -key tab -settle 150 -key tab -stable 700 30000 -snap refill -# The pane is still in insert mode, which is right — the query answered beside -# the cursor and typing goes on — so walking the answer means leaving it first, -# the same as for any other results buffer. -key esc -settle 100 -# Several rows, so the buffer IS the picker and n walks it; completion does not -# jump the way a goto with one row does. The first step selects row 1, and the -# Enter after it looks that row and lands SELECTING `verdigris` on line 2 of -# a.zig. -key space j n -key enter -stable 700 15000 -snap step -# A pane the backend does not speak: same keystrokes, same dot before the -# cursor, and Tab must still indent — synchronously this time, since the core -# never asks. The gate is lsp.speaks, which the core consults and the backend -# owns. -start 41 120 notes.txt -wait 8000 abc.def -stable 700 20000 -press left 12 4 -release left 12 4 -key i -key tab -stable 400 5000 -snap txtindent -# ---- the two genuinely INCOMPLETE states ---- -# -# Everything above types its dot into syntax that is otherwise finished, which -# is the easy half and is why a repair chosen by parse-error count looked like -# it worked. Mid-typing, the line is short of its terminator too. -# -# `const z: Shade = .` is ONE parse error with or without a placeholder -# identifier spliced in, so the repair has to be chosen by whether it makes the -# dot reachable in the tree, never by counting errors. -file c.zig const Shade = enum {\n verdigris,\n cinnabar,\n};\n\npub fn nosemi() void {\n const z: Shade = \n}\n -start 19 100 c.zig -wait 8000 nosemi -stable 700 20000 -press left 8 10 -release left 8 10 -stable 400 5000 -key i -key end -text . -stable 400 5000 -key tab -wait 60000 +Search -stable 700 30000 -snap nosemi -# ...and a construct still hanging OPEN. The switch has no closing brace at -# all — the one `}` in the file closes it and leaves the function unclosed — -# which makes Zig's recovery throw the whole declaration away. No placeholder -# sitting at the dot can survive that, so the repair has to close the construct -# as well, on the same line (a spelling containing a newline would move every -# line number the rows are built from). -file d.zig const Shade = enum {\n verdigris,\n cinnabar,\n};\n\npub fn nobrace(s: Shade) void {\n switch (s) {\n \n}\n -start 19 100 d.zig -wait 8000 nobrace -stable 700 20000 -press left 8 11 -release left 8 11 -stable 400 5000 -key i -key end -text . -stable 400 5000 -key tab -wait 60000 +Search -stable 700 30000 -snap nobrace diff --git a/test/snapshots/lspcompletemoved.snap b/test/snapshots/lspcompletemoved.snap deleted file mode 100644 index 8351b310..00000000 --- a/test/snapshots/lspcompletemoved.snap +++ /dev/null @@ -1,33 +0,0 @@ -# The guard that makes "an empty answer indents" safe to have at all. -# -# lspcomplete.snap pins the indent itself: Tab after a dot the backend cannot -# answer diverts, the answer comes back empty, and four spaces go in LATE so -# the keystroke is not eaten. That late write is the dangerous half — it lands -# a few hundred milliseconds after the key, by which time the hands have moved -# on — so lspResponse only performs it if nothing has: same pane, still insert, -# one cursor, cursor still on the cell the Tab was pressed at. Nothing covered -# the condition, only its happy side. -# -# Same file and same click as lspcomplete's `commentindent` arm — line 12 is a -# comment, so no candidate can exist and the answer is certainly empty — but -# here an `x` is typed straight after the Tab, in the same write, long before a -# ZLS analysis can finish. The buffer below is the assertion: `// note.x`, with -# neither `// note. x` (the indent landing under the typing) nor -# `// note.x ` (the indent landing on top of it). -file a.zig const Shade = enum {\n verdigris,\n cinnabar,\n};\n\nfn pick(s: Shade) u8 {\n return switch (s) {\n \n };\n}\n\n// note. see below\n -start 21 120 a.zig -wait 8000 verdigris -stable 700 20000 -press left 16 15 -release left 16 15 -stable 400 5000 -key i -key tab -text x -stable 700 20000 -snap typedthrough -key esc -settle 100 -key space f s -stable 700 15000 -snapfile buffer /tmp/pardes-snap/lspcompletemoved/cwd/a.zig diff --git a/test/snapshots/lspdebug.snap b/test/snapshots/lspdebug.snap deleted file mode 100644 index c66a5d67..00000000 --- a/test/snapshots/lspdebug.snap +++ /dev/null @@ -1,45 +0,0 @@ -file z.zig const std = @import("std");\n\nfn helper() u32 {\n return 3;\n}\n\npub fn main() void {\n const v = helper();\n _ = v;\n}\n -# Builtins announce themselves by default, and an announcement is a band at -# the top of the body -- which moves every row this script clicks. What the -# verbs do is what is under test, not the announcement. -config Verbose off -start 45 120 z.zig -wait 8000 fn helper -stable 700 20000 -snap opened - -# Ctrl-click jumps to the definition; plain click only moves the cursor. -press ctrl-left 22 11 -release ctrl-left 22 11 -stable 700 15000 -snap ctrlclick -press left 22 11 -release left 22 11 -stable 700 15000 -snap plainclick - -text 3gg1g| -stable 400 10000 -key space l w -wait 10000 lsp explain — the definition query -wait 10000 row(s) -key space w j enter -key space d -stable 700 15000 -snap why-closed - -# Check the report's answers, not installed compiler paths or dependency counts. -key space l i -wait 10000 language servers: -wait 10000 zls -key space w j enter -key / -text client queries -key enter -wait 10000 client queries -wait 10000 definition -# Enter left the keyboard in the report, on the match; its query pane is -# attached to it, so one Del closes both, their rows back to the source -key space d -stable 700 15000 -snap report-closed diff --git a/test/snapshots/lsprelpath.snap b/test/snapshots/lsprelpath.snap deleted file mode 100644 index 152a13a3..00000000 --- a/test/snapshots/lsprelpath.snap +++ /dev/null @@ -1,76 +0,0 @@ -# What a language row SPELLS its path as, and that both spellings still LOOK. -# -# A row spells its path the shortest way a Look from the query pane resolves -# (Query.lookPath): relative to the pane's directory, `../` included, when that -# is shorter than the absolute path, else absolute — a `gr` list was otherwise -# the same forty-character prefix repeated down the pane with the part you came -# to read pushed off the right edge. -# -# A row in the SAME directory shortens to a bare basename; the two that a -# careless shortening can get wrong are here, one app each, as `gr` rows -# (the file headers of the asking text's query pane, line 1 `Refs`): -# -# PARENT the enum is one level UP from the asking file, so the row -# climbs: `../shade.zig`, shorter than `/tmp/.../cwd/shade.zig`, -# and a Look from the pane still lands on it. -# SUBDIRECTORY the enum is one level DOWN, so the strip leaves a path with a -# separator still in it — `inner/tint.zig`, not `tint.zig`. A -# strip that took the basename instead would produce a row that -# resolves to nothing. -# -# `n` and the Enter after it are the assertion in both, not the row text: the -# step selects row 1, the look opens the right file with the member SELECTED -# on its own line, and focus follows what opened — so the snap header's cursor -# is that pane's, and the style capture is where the selection itself shows. -dirmk sub -dirmk sub/inner -file shade.zig pub const Shade = enum {\n verdigris,\n cinnabar,\n};\n -file sub/inner/tint.zig pub const Tint = enum {\n ochre,\n indigo,\n};\n -file sub/parent.zig const shade = @import("../shade.zig");\n\npub fn pick(s: shade.Shade) u8 {\n return switch (s) {\n \n };\n}\n -file sub/subdir.zig const tint = @import("inner/tint.zig");\n\npub fn hue(t: tint.Tint) u8 {\n return switch (t) {\n \n };\n}\n -# ---- PARENT: outside the asking file's tree, so the row climbs ---- -start 35 100 sub/parent.zig -wait 8000 fn pick -stable 700 20000 -press left 31 6 -release left 31 6 -stable 400 5000 -key g -key r -# the query pane under parent.zig, line 1 `Refs`, the rows under each file: -# shade.zig's spelled from above, `../shade.zig` -wait 15000 ../shade.zig:1 -stable 700 15000 -snap absrow -# the current row is parent.zig's own; the one before it is shade.zig's, -# shown in the +Preview (N, the list in normal mode), which Enter makes -# shade.zig's pane -key N -wait 10000 verdigris -stable 700 15000 -key enter -stable 700 15000 -snap abslook -snapstyle abslook -start 35 100 sub/subdir.zig -wait 8000 fn hue -stable 700 20000 -press left 29 6 -release left 29 6 -stable 400 5000 -key g -key r -wait 15000 inner/tint.zig -stable 700 15000 -snap subrow -key N -wait 10000 ochre -stable 700 15000 -key enter -stable 700 15000 -snap sublook -snapstyle sublook -press right 12 13 -release right 12 13 -stable 700 15000 -snap clicked diff --git a/test/snapshots/modal.snap b/test/snapshots/modal.snap deleted file mode 100644 index 9d82f0a3..00000000 --- a/test/snapshots/modal.snap +++ /dev/null @@ -1,53 +0,0 @@ -# helix-modal normal mode: motions, x/v selections, y/d, insert, undo/redo -file words.txt alpha beta -start 31 100 -n 3 -wait 8000 words.txt -stable 700 20000 -key c-b -stable 600 8000 -text printf 'one two three\nfour five six\nseven eight nine\n' -key enter -wait 8000 seven -stable 700 10000 -key c-b -stable 600 8000 -press left 5 7 -release left 5 7 -stable 400 5000 -key g g -stable 400 5000 -snap top -key j j w -stable 400 5000 -snap moved -key x -stable 400 5000 -snap xsel -snapstyle xsel -key x -stable 400 5000 -snap xsel2 -key y -stable 400 5000 -snap yanked -key v j l -stable 400 5000 -snap vsel -snapstyle vsel -key esc -settle 100 -key i -text TYPED -key esc -settle 100 -stable 400 5000 -snap typed -key u -stable 400 5000 -snap undone -key U -stable 400 5000 -snap redone -key g e -stable 400 5000 -snap bottom diff --git a/test/snapshots/multicursor.snap b/test/snapshots/multicursor.snap deleted file mode 100644 index ebd97ec5..00000000 --- a/test/snapshots/multicursor.snap +++ /dev/null @@ -1,46 +0,0 @@ -# MULTIPLE CURSORS on a real file pane. The differential suite (hxdiff) proves -# the model against a real helix but is headless, so this is the part it cannot -# see: that every range is actually on screen, that the primary reads -# differently from the others, and that ONE keystroke edits at all of them. -lines f.txt 12 -start 31 150 -n 3 -wait 8000 f.txt -stable 700 20000 -# open f.txt in the left pane (type its name, right-click to Look) -press left 5 9 -release left 5 9 -stable 400 5000 -key i -text f.txt -key esc -settle 100 -press right 6 9 -release right 6 9 -wait 10000 line 3 -stable 700 15000 -# top of the file, then C C: three cursors, one per line, primary on line 3 -key g g -stable 400 5000 -key C C -stable 400 5000 -snap three-cursors -# the colours ARE the feature here: the primary's cell against the two dimmer -# ones, each with its own bright cursor cell -snapstyle three-cursors -# one keystroke, three edits -key i -text >> -key esc -settle 100 -stable 400 5000 -snap edited-at-three -# a selection per cursor: e selects to the end of the first word at each -key g h w -stable 400 5000 -snap three-selections -snapstyle three-selections -# `,` drops back to the primary alone; the two dim highlights must vanish -key , -stable 400 5000 -snap keep-primary -snapstyle keep-primary diff --git a/test/snapshots/pipe.snap b/test/snapshots/pipe.snap deleted file mode 100644 index 0df76864..00000000 --- a/test/snapshots/pipe.snap +++ /dev/null @@ -1,16 +0,0 @@ -# `|`: visible tag prompt, native async shell filter, and one-step undo. -file pipe.txt alpha beta\ngamma delta -start 13 180 pipe.txt -wait 8000 alpha beta -stable 700 20000 -key x | -text tr a-z A-Z -stable 300 5000 -snap prompt -key enter -wait 8000 ALPHA BETA -stable 500 8000 -snap filtered -key u -stable 400 5000 -snap undone diff --git a/test/snapshots/scrolloff.snap b/test/snapshots/scrolloff.snap deleted file mode 100644 index 3dbad2b8..00000000 --- a/test/snapshots/scrolloff.snap +++ /dev/null @@ -1,43 +0,0 @@ -# scrolloff: keyboard motion keeps 3 context rows above/below the cursor, -# clamped at file boundaries (cursor may reach the top/bottom body row there) -lines g.txt 40 -start 16 210 -n 1 -wait 8000 g.txt -stable 700 20000 -# right-click the g.txt name in the greeting ls -> file pane under the shell's -# text, 9 body rows -press right 4 5 -release right 4 5 -wait 10000 line 3 -stable 700 15000 -press left 10 9 -release left 10 9 -stable 400 5000 -# (b) gg: cursor CAN sit on the top body row, no forced scroll -key g g -stable 400 5000 -snap top -# (a) five j's reach the bottom margin (visual row 5 of 9) without scrolling... -key j j j j j -stable 400 5000 -snap edge -# ...the sixth j scrolls: view slides one line, cursor holds the margin -key j -stable 400 5000 -snap scrolled1 -key j j j j -stable 400 5000 -snap jdown -# (d) ge (goto last line; bare G is a helix no-op): bottom clamp, view stops -# at EOF-at-bottom, cursor on the bottom row -key g e -stable 400 5000 -snap end -# (c) k-walk up: cursor climbs to the top margin, then the view scrolls -key k k k k k k k k -stable 400 5000 -snap kup -# (b) again from deep in the file: gg puts the cursor back on the top row -key g g -stable 400 5000 -snap top2 diff --git a/test/snapshots/selarg.snap b/test/snapshots/selarg.snap deleted file mode 100644 index 8aa59bbd..00000000 --- a/test/snapshots/selarg.snap +++ /dev/null @@ -1,58 +0,0 @@ -# 2-1 chord borrows the argument selection from ANOTHER pane: pane A (left) -# holds the selection, pane B (right) middle-drags the command with no -# selection of its own — the chord's left tap finds A's kept left selection, -# and later A's explicit v selection, and rides it as the argument. -file s.txt x -start 31 100 -n 3 -wait 8000 s.txt -stable 700 20000 -# pane A (left, active at boot): print the two argument words -key c-b -stable 600 8000 -text clear; printf 'ZZARG ZZVEE\n' -key enter -wait 8000 ZZVEE -stable 700 15000 -key c-b -stable 600 8000 -# pane B (top right): create the arg-printing script and show its path -press left 60 7 -release left 60 7 -stable 400 5000 -key c-b -stable 600 8000 -text printf '#!/bin/sh\necho CHORDARG:"$1"\n' > c.sh; chmod +x c.sh; clear; printf './c.sh\n' -key enter -wait 10000 ./c.sh -stable 700 15000 -key c-b -stable 600 8000 -# keep a left selection over ZZARG in pane A (this also focuses A) -press left 3 5 -drag left 7 5 -release left 7 5 -stable 400 5000 -snap kept -# chord in pane B: middle on ./c.sh + left tap (B has NO selection: the -# argument comes from pane A's kept left selection) + middle release runs -press middle 55 5 -press left 55 5 -release middle 55 5 -release left 55 5 -wait 10000 CHORDARG:ZZARG -stable 700 10000 -snap crosspane -# now an explicit modal selection: plain-click ZZVEE in A (drops A's kept -# left selection), select it with v e, chord in B again -press left 9 5 -release left 9 5 -stable 400 5000 -text ve -stable 400 5000 -press middle 55 5 -press left 55 5 -release middle 55 5 -release left 55 5 -wait 10000 CHORDARG:ZZVEE -stable 700 10000 -snap vselarg diff --git a/test/snapshots/selregex.snap b/test/snapshots/selregex.snap deleted file mode 100644 index b4a042f8..00000000 --- a/test/snapshots/selregex.snap +++ /dev/null @@ -1,56 +0,0 @@ -# Interactive regex selection (`s` / `S`) and the comment toggle, on a real -# file pane. hxdiff pins what they DO against a real helix, but it is headless, -# so this is the half it cannot see: the prompt living in the TAG rather than a -# popup, the matches lighting up under a pattern as it is typed, Esc putting -# back what was there, and Ctrl-c using the token this file's EXTENSION asks -# for — `//`, where a buffer with no language would get `#`. -file m.zig const one = 1;\nconst two = 2;\nconst three = 3;\n -# wide on purpose: the whole point of this script is a tag long enough to hold -# the marker AND the pattern, and a narrow pane simply truncates it away -start 25 160 m.zig -wait 8000 m.zig -stable 700 20000 -key g g -stable 400 5000 -# `%` takes the whole file, `s` arms the regex input: the marker goes into the -# tag tail after the path, and the pane is in insert mode ON THE TAG — the -# same one-line editor `/` and Find use, and nothing has moved in the body yet. -key % -key s -stable 400 5000 -snap prompt-armed -# ...and now the point: the selection follows the pattern as it is typed. Three -# `const` runs light up with Enter nowhere near, and the colours ARE the -# feature — the primary bright, the other two dim, each with its own cursor. -text const -stable 400 5000 -snap preview -snapstyle preview -key enter -stable 400 5000 -snap three-selected -snapstyle three-selected -# a second `s` narrows the three to one `t` apiece... -key s -text t -stable 400 5000 -snap narrowed -# the grid text cannot show a selection, so this is where the styles carry the -# whole point: three one-cell ranges here, three five-cell ones after the Esc -snapstyle narrowed -# ...and Esc throws that away for the selection the prompt opened on, which is -# free: the preview is re-derived from that snapshot on every keystroke, so -# cancelling is just applying the empty pattern. -key esc -settle 100 -stable 400 5000 -snap esc-restores -snapstyle esc-restores -# Ctrl-c comments every line the three cursors touch — one decision for the -# whole selection, not one per cursor — and again to take it back off. -key c-c -stable 400 5000 -snap commented -key c-c -stable 400 5000 -snap uncommented diff --git a/test/snapshots/stepgrain.snap b/test/snapshots/stepgrain.snap deleted file mode 100644 index e807981c..00000000 --- a/test/snapshots/stepgrain.snap +++ /dev/null @@ -1,50 +0,0 @@ -# ONE PRESS, ONE ROW. A query pane's rows are one a line with a hit, the -# hit's line under a gutter number, and Ctrl-n / Ctrl-p (typing on line 1) -# step them a row at a time, round the end: row 2 below matched on a line -# that mentions `sub/b.txt`, and the step does not stop on that word, as the -# old word-grained walk did; the fourth press wraps back to row 1. -# -# A path with a BLANK in it is one name: `two words.txt` is found whole by -# Find and Enter opens exactly it. -dirmk sub -file a.txt hello ZQMARK one\nsee also sub/b.txt for ZQMARK two -file sub/b.txt ZQMARK inside sub -run touch 'two words.txt' -start 31 150 a.txt -wait 8000 hello ZQMARK -stable 700 20000 -# Grep from the leader: three hits, under their files, the empty file -# contributing none. Row 2 is the one whose TEXT holds a path. -key space -key f -key g -stable 400 5000 -text ZQMARK -wait 10000 ZQMARK inside sub -stable 700 15000 -snap results -key c-n -stable 400 5000 -snap step-row2 -snapstyle step-row2 -key c-n -stable 400 5000 -snap step-row3 -key c-n -stable 400 5000 -snap step-wrap -key esc -settle 100 -stable 400 5000 -# Find `words`: the name with a blank in it, whole -key space -key f -key f -text words -wait 10000 two words.txt -stable 700 15000 -snap blank-in-path -snapstyle blank-in-path -key enter -stable 700 15000 -snap blank-opened diff --git a/test/snapshots/tag.snap b/test/snapshots/tag.snap deleted file mode 100644 index 133a041d..00000000 --- a/test/snapshots/tag.snap +++ /dev/null @@ -1,49 +0,0 @@ -# a CLICKED tag is in normal mode, its cursor where it was clicked: `i` types -# there (`:` is the door back to the body, see tagcmd); backspace edits; Esc drops to the tag's normal mode, which is -# the body's normal mode, and `:` there hands the keyboard back to the body; -# Enter looks the word at the cursor (Tab executes it). Multi-word execution -# from the tag stays the mouse's job (middle-drag), like anywhere else. -file t.txt ZZLOOKED -start 31 150 -n 3 -wait 8000 t.txt -stable 700 20000 -# Click the one editable separator before Save, directly after the cwd. -# The former generated alignment gap no longer exists. -# The layout box shows -# the pane's BODY mode, not the tag's; `i` then types into the tag where it -# was clicked. -press left @Save-1 3 -release left @Save-1 3 -stable 400 5000 -snap tag-focus -key i -send \x20t.txt -stable 600 8000 -stable 400 5000 -snap tag-typed -key bs -key bs -key bs -key bs -stable 400 5000 -snap tag-del -send .txt -stable 600 8000 -stable 400 5000 -# Esc: the tag's normal mode; `:` then gives the keyboard back to the body, -# which is in normal mode, and the typed text stays -key esc -settle 100 -key : -stable 400 5000 -snap tag-exit -# re-enter the tag and look the typed word: Enter in normal mode opens t.txt -# as a file pane. Click the inserted word itself; filename, separator and -# commands are compact. -press left @t.txt 3 -release left @t.txt 3 -stable 400 5000 -key enter -wait 10000 ZZLOOKED -stable 700 15000 -snap tag-look diff --git a/test/snapshots/tagcmd.snap b/test/snapshots/tagcmd.snap deleted file mode 100644 index 0e9047fb..00000000 --- a/test/snapshots/tagcmd.snap +++ /dev/null @@ -1,41 +0,0 @@ -# `:` — vim's command line with acme's vocabulary. It focuses the pane's OWN -# tag in NORMAL mode (block cursor; the layout box shows the pane's BODY mode, -# which for this file pane is normal either way). The tag remembers where its -# cursor was; the first time there is nothing to remember and it starts on -# Save. The tag's normal mode is the body's: w selects the "Save" span exactly -# as a body word motion does, and the execute key runs the word under the -# cursor and hands the body back — same keys as the body, so Tab by default -# (see config.look_key/exec_key). `:` again backs out instead, leaving the tag -# as it was. -lines c.txt 6 -start 31 100 c.txt -wait 8000 Newcol Joincol -wait 8000 c.txt -stable 700 20000 -# edit line 1 so Save has something to write -key i -text ZZEDIT -key esc -settle 100 -stable 400 5000 -snap edited -# `:` -> the tag, in normal mode, cursor on Save -key : -stable 400 5000 -snap colon -# w -> the "Save" span (selected, like the body's word motion) -key w -stable 400 5000 -snap word -# Tab executes it: c.txt is written and focus is back in the body -key tab -stable 600 8000 -stable 400 5000 -snap saved -snapfile written /tmp/pardes-snap/tagcmd/cwd/c.txt -# `:` then `:`: back to the body with the tag untouched, nothing run -key : -stable 400 5000 -key : -stable 400 5000 -snap escaped diff --git a/test/snapshots/tagnav.snap b/test/snapshots/tagnav.snap deleted file mode 100644 index ef202a08..00000000 --- a/test/snapshots/tagnav.snap +++ /dev/null @@ -1,120 +0,0 @@ -# A tag's normal mode is the body's: h/l/w move in the tag's own text, and -# moving between panes is the window keys' job from a tag as from a body -- -# there are no tag-only hops. `:` is the one key a tag and a body do not -# share: from the body it focuses the pane's own tag, from the tag it hands the -# keyboard back to the body. Each tag remembers its cursor; the first time -# there is nothing to remember and it starts on Save. -# -# Evidence is the `cursor=` header (the ACTIVE pane's cursor, which while a tag -# is focused sits on THAT pane's tag row) plus each pane's layout box, which -# carries its BODY mode as one character: ` ` normal, `^` insert, `$` tty. The -# tag has a mode of its own, so the box never changes while a tag is used. -file w.txt alpha\nbeta\ngamma -start 31 100 w.txt -wait 8000 Newcol Joincol -wait 8000 w.txt -stable 700 20000 -# A FILE boots alone, so the launch shell is opened here: Alt-n opens it and -# focuses it, Alt-c puts it in a column of its own on the right, SPC w h Enter -# comes back to the file. -key a-n -key a-c -stable 700 15000 -key space w h enter -stable 400 5000 -# Alt-n: a shell below the file, so the left column has two rows and every -# direction has somewhere to go -key a-n -stable 700 15000 -key space w k enter -stable 400 5000 -snap start -# `:` -> the file's OWN tagline, normal mode, on Save -key : -stable 400 5000 -snap colon -# w selects in the tag the way it selects in a body -key w -stable 400 5000 -snap word -# l is a motion in the tag, not a hop to the next pane -key l l -stable 400 5000 -snap in-tag -# the window keys move between panes from a tag as from a body: the tag lets -# go and the neighbour's BODY takes the keyboard -key c-w l enter -stable 400 5000 -snap right -# `:` there -> that pane's own tag, on its Save the first time -key : -stable 400 5000 -snap right-tag -# back left, and `:` finds the file's tag cursor where l left it -key c-w h enter -stable 400 5000 -key : -stable 400 5000 -snap left-tag -# `:` in the tag's normal mode: back to the body -key : -stable 400 5000 -snap back-to-body -# A TERMINAL KEEPS ITS TTY MODE. Put the launch shell in raw tty mode (Ctrl-b), -# click its tagline and come back: its box reads `$` throughout, because the -# tag's mode is the tag's own. -key c-w l enter -stable 400 5000 -key c-b -stable 700 15000 -snap tty-on -press left @Mode 3 -release left @Mode 3 -stable 400 5000 -snap tty-tag -key : -stable 400 5000 -snap tty-restored -# The column and workspace tags are Texts in the same layout, with the same -# keys: Up from a pane with nothing above it reaches its column's tag, in -# normal mode, then the workspace's; Down comes back the same way. -key c-b -stable 700 15000 -key c-w h enter -stable 400 5000 -key c-w k -stable 400 5000 -snap column-tag -key w -stable 400 5000 -snap column-word -key c-w k -stable 400 5000 -snap workspace-tag -# `$` is the last cell; five long-word steps back land on `Dump`, and the -# execute key runs it and gives the keyboard back to the body FIRST -- `Exit` -# lives up here too, so a builtin that frees the session must never return -# into a focused header. Dump grows a `Restore ` word, which is also the -# case where the line gets longer than the column you were parked on. -key g l -stable 400 5000 -snap topbar-dollar -key B B B B B -stable 400 5000 -snap topbar-dump-word -key tab -stable 700 15000 -snap topbar-exec -# THE DELETION HAZARD, from the bar itself: `Restore` frees every pane and -# swaps the core out from under the caller. Walk back up onto the word the -# Dump just grew -- B twice off the tail, because the LONG word motions are the -# ones that step over a path in one go -- and run it. -key c-w k -key c-w k -stable 400 5000 -key g l B B -stable 400 5000 -snap topbar-restore-word -key tab -stable 900 15000 -snap topbar-restored diff --git a/test/snapshots/tagpath.snap b/test/snapshots/tagpath.snap deleted file mode 100644 index 841d4fed..00000000 --- a/test/snapshots/tagpath.snap +++ /dev/null @@ -1,56 +0,0 @@ -# The path is part of the tag's text for the keyboard as for the mouse: `0` -# goes to its start, `E` selects it and `y` yanks it. It is read-only, but -# typing into it drafts a new name there, as a click on it does. Escape -# cancels; Enter changes buffer identity, never renames a disk file. -lines c.txt 4 -start 31 100 c.txt -wait 8000 Newcol Joincol -wait 8000 c.txt -stable 700 20000 -snap start -key : -stable 400 5000 -snap colon -key 0 -stable 400 5000 -snap col0 -key E -stable 400 5000 -snap sel-path -snapstyle sel-path -key y -# `:` gives the keyboard back to the body, and `p` puts the path there -key : -key p -stable 400 5000 -snap yanked-path -# Sweep across the path / command boundary without injected padding. -press left 12 3 -drag left 30 3 -drag left 42 3 -release left 42 3 -stable 400 5000 -snap drag-cross -snapstyle drag-cross -# Esc is the tag's normal mode; typed at the path's start, `/renamed` drafts -# a name -key esc -settle 100 -key 0 -key i -text /renamed -stable 400 5000 -snap name-draft -# Esc keeps the draft pending; a second drops it -key esc -settle 100 -key esc -stable 400 5000 -snap name-cancelled -key : -key 0 -key i -text /renamed -key enter -stable 400 5000 -snap name-committed diff --git a/test/snapshots/wrap.snap b/test/snapshots/wrap.snap deleted file mode 100644 index a818bc5f..00000000 --- a/test/snapshots/wrap.snap +++ /dev/null @@ -1,80 +0,0 @@ -# Soft line breaks: ON by default, off with the Wrap builtin (`SPC t w`). A -# file line too long for the pane renders across several body rows instead of -# running off the right edge. -# -# Three rules pinned here. The break is at the PANE'S OWN content width and -# nothing else — there is no upper bound, a wide window breaks wide. A -# continuation row carries a BLANK gutter (the number belongs to the LINE, and -# a number repeated down a wrapped line would read as several lines) and the -# row it broke out of ends in `↩`, in the one column the wrap keeps free for -# it — a break is otherwise invisible, and an absent line number is a poor -# thing to read a document by. And the mouse follows the render: a click on a -# continuation row lands on the character under the pointer, which only works -# if the click resolves through the same row->line map the body was drawn from. -# -# The line is 20 decades, each headed by its own column marker: `0` at column -# 0, `4` at 40, `A` at 100. So the first character of a continuation row NAMES -# the column it broke at, and the width rule is readable straight off the grid. -file long.txt 0---------1---------2---------3---------4---------5---------6---------7---------8---------9---------A---------B---------C---------D---------E---------F---------G---------H---------I---------J---------\nsecond line\nthird line\n -# 48 columns: the 2-column chrome gutter, the 5-column line-number gutter and -# the 1 column the `↩` sits in leave 40 for content. -start 15 48 long.txt -wait 8000 Newcol Joincol -stable 700 20000 -# the default: five rows for line 1 (200 bytes / 40), the four continuations -# gutterless and starting at `4` `8` `C` `G` — the columns 40, 80, 120, 160 — -# and each of the first four rows ending in the break marker -snap on-narrow -# a click on the SECOND row of line 1, on the `5` marker at column 50. The -# cursor must come back to the cell that was clicked (grid 17,3): the click -# resolved to line 1 column 50, and the render put line 1 column 50 back where -# the finger was. Off by one row and it would land in line 2. -press left 18 5 -release left 18 5 -stable 400 5000 -snap clicked -# motions stay LOGICAL: one `j` from line 1 leaves the whole wrapped line -# behind and lands on line 2, four screen rows down at once. -key j -stable 400 5000 -snap logical-j -# ...while `gj`/`gk` are the VISUAL pair. `gg` puts the cursor back at line 1 -# column 0 with no goal column left over, `3l` moves three in, and from there -# each `gj` steps ONE screen row: still line 1, the column kept INSIDE the row, -# so the cursor stays in grid column 10 while the row walks 2 -> 3 -> 4. `gk` -# steps back onto the row it came from. This is the only motion that reads the -# wrap map's own arithmetic, so it is the one that can silently become `j`. -key g g -stable 400 5000 -key 3 l -stable 400 5000 -key g j -stable 400 5000 -snap visual-gj -key g j -stable 400 5000 -snap visual-gj-again -key g k -stable 400 5000 -snap visual-gk -# a count is counted in ROWS too, and two of them are still inside line 1 -key 2 g j -stable 400 5000 -snap visual-count-gj -# SPC t w turns it off: line 1 back on ONE row, clipped at the right edge with -# no marker, lines 2 and 3 under it — the render this pane had before soft -# breaks existed, because the map the readers consult goes back to empty and -# every one of them falls back to the row arithmetic it used before any of it -key space t w -stable 400 5000 -snap off -# ...and on again is on -key space t w -stable 400 5000 -snap on-again -# 128 columns: 120 for content, and the break is at the `C` — column 120, the -# window's own width. The old 100-column cap would have broken at the `A`. -start 15 128 long.txt -wait 8000 Newcol Joincol -stable 700 20000 -snap on-wide diff --git a/test/snapshots/yankpaste.snap b/test/snapshots/yankpaste.snap deleted file mode 100644 index ec0f8ca3..00000000 --- a/test/snapshots/yankpaste.snap +++ /dev/null @@ -1,37 +0,0 @@ -# y -> p round-trips through the core's own yank register (regression: p used -# to request the SYSTEM clipboard via OSC 52, which plain terminals — and this -# harness — never answer, so paste silently no-oped). Pins helix placement: -# a linewise yank (x) pastes as whole lines below (p) / above (P), a charwise -# yank (v) splices inline after the selection. -lines f.txt 5 -start 31 100 f.txt -wait 8000 Newcol Joincol -wait 8000 line 5 -stable 700 20000 -# linewise: x-select line 2, yank, move down, paste below line 3 -press left 8 5 -release left 8 5 -stable 400 5000 -key x y j p -stable 400 5000 -snap linewise-below -# P from the pasted line: its copy lands above -key x y P -stable 400 5000 -snap linewise-above -# charwise: v-select two chars of line 1, yank, paste splices after them -press left 8 4 -release left 8 4 -stable 400 5000 -key v l y p -stable 400 5000 -snap charwise-inline -# a BLANK line yanks as a bare "\n": the block is empty, lineCount says 0 -# lines, and every `n - 1` in the linewise paste used to underflow — panic on -# y then p. It pastes as one empty line. -key o -key esc -settle 100 -key y p -stable 400 5000 -snap blankline -- cgit v1.3