diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-26 00:03:50 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-26 02:04:52 -0300 |
| commit | 13d234f431a98bf97fcc1caec812f59eff711aa0 (patch) | |
| tree | db88980c1cd3fafb4e56e66ea6387f1f2bdd6eb4 /test/behaviour | |
| parent | 94f00e966c908d370e34ed5e0496a86b33de26d6 (diff) | |
| download | pardes-13d234f431a98bf97fcc1caec812f59eff711aa0.tar.gz pardes-13d234f431a98bf97fcc1caec812f59eff711aa0.zip | |
tagline, edit, dump, layout: a pane tag reads its path, then its computed words, the words that act now, read-only and made again from its state as the path is, then the user's text (UX DESIGN K'1, K'3, binding; the user: "pardes looked so cramped and full of information with the taglines compared to the other editors", "I liked C and D"); THE OLD WAY: a tag's words were its own text (`tag.own`, or until edited its kind's default `*_tail`: `Save Term Collapse Follow Del`, a speaking file's `Def Refs`, `TreeContext`, `LocationsConfig`, a terminal's `Term Save Mode Filter Collapse Del`), the same in every state, so a file tag held 5 to 9 command words, wrapped to a second row at 84 columns, and `Save` stood there clean; THE CHANGE: tagline.computedWords per K'3's table (a file reading `Keep Del`, `Keep` its walk's word after the path as before; held `Del`, `Undo` while its journal has a step back with something in it (insert mode's `i` alone marks a step of none: a behaviour test caught `Undo` coming, and a 24-column tag wrapping, before a key was typed), `Redo` while it has one forward; unsaved, gone from disk too, `Save Undo Del`; `Diff` first for a diff, a +Pager holding one and the Diff view; `Filter` for a +Pager; a +New never `Save` (the table's `Del; Undo once typed into`); a directory `Get Del`; a command pane `Kill Del` running, `Del` done; queries and the preview unchanged; a kind its own words then `Del` (Kind.reopen, `Term` and `Collapse` gone); a terminal `Del`, its shell's word after it as its text, `Term` until the shell says its name, then `Term+fish`, as before), a comptime table of the 32 file combinations, no allocation; restPrefix = path, computed words and a blank, the prefix every edit must leave as it is (edit.setEditTextSpan, which compared the path alone) and the 9P cleartag's caret goes after; `tag.own` holds only what the user typed (curTail: own, else a terminal's shell word, else none), shown after the computed words and never regenerated; enterTag puts the caret at the start of the user's text, no longer on `Save`; a question waiting at rest (TagState.asks, the test TagState.asking used) replaces the computed words with the own text, as out of rest (D13, D1 unchanged: prefixIn gives the path alone, sync keeps the tag's offsets at rest); `:` lists the computed words, then the own text's, `in the tag`; Follow's `Unfollow` goes in the new page's own text with no second blank; RESTORE: dump.dropOldTags drops an own text equal to its kind's tag before K' (tagline.kindTail, the old defaults kept for it) where a Restore, a start from a dump and an Upgrade load (loadAndRevive; a replica's join loads its authority's, dropped there; a Restore replays through the same path), any other kept whole as the user's text; THE LAYOUT (two faults the lean tags let the random placements find, ninep/tree.zig "random placements ... leave no pane under its tag and two rows"): (1) seed 273 (core-test): `Edit =` gave a full column's +Errors an undo step, `Undo` wrapped its 16-cell tag onto a 5th row, the pane under its minimum, no row to give: layout.minRows now counts a tag with the widest computed words its pane can come to show (tagline.widestWords: `Save Undo Redo` where it saves, a query's frozen words; a reading pane's own, its first edit holds it), so an edit never takes a row its placement did not leave; (2) seed 162 and 192 (shell-test): a walk step in a 12-cell tag whose basename did not fit beside its newest step (`test.txt:1 › …f.txt Keep Del`), the fold had nothing left to cut: tagline.folded then folds that step into the `+N` too (D2's basename stays whole; a hunk in the fold W4 touches); TESTS (FIRST): tagline.zig "a pane tag's computed words are the words that act now, its own text after them (UX K'1, K'3)" (reading, held, typed twice, undone, saved, a .patch, a pager, a pager's diff, a +New before and after typing, a kind), "typing in a tag goes after its computed words, and stays the user's text through a change of state" (`Mine` typed after `Del`, a Backspace on the blank before it refused, the body typed into: `Save Undo Del Mine`, the caret still on `M`), "a dump of a build before UX K' restores a tag's old default own text as none, any other as the user's"; TESTS CHANGED, each for a word gone from a tag: lsp/Ask.zig Def/Refs (the 2-1 chord now on `Def Refs` typed into the tag's own text, kindTail asserts the kind's words), Effect.zig "Save is a word of every pane with text behind it and no other" (kindTail, computedWords `Del` while clean), Core.zig TreeContext (kindTail, the tag holds no TreeContext), Filter (computedWords `Filter Del`), pane-tag Exec (`Term+sh` the text; `Theme dark` and the fallback word found where they are), compact tag commands (`Del Term`), Term+ paths (`Term+/bin/sh`, `Term+sh`), the command pane's and REPL's prefixes (pathPrefix), Dir (`Get Del`), Stream (`More Del`), jj At (pathPrefix), Pipe (`| tr` on the own text `Look here`), Command.zig `:` (typed into first: `Save Undo Del` its tag's rows, 14 commands), Trail.zig (W4's file: tags `/test.txt Del `, `rank.zig Del `; the Fixture 120 to 200 columns, as its 85-cell tmp paths beside a short tag folded the walks these tests read; "too short to halve" 24 to 20 rows), TagState and Band (a tag of two rows: own text given), Messages (the question test at 200 columns, the tag at rest one row), dev/tui/tui.zig (a terminal view's wrapped tag read on across its rows: the shorter prefix cut `w19`), test/mode.zig (`Mode` typed into the terminal tag's own text, kindTail has it), test/panes.zig (an image's pathPrefix); BEHAVIOUR (a helper's edits, each a word moved): tags.zig (a tag's keyboard starts on its own text, so `Save Term`, `Save`, `JumpTrail` are written into the own text where a test clicked or edited them; expected tags `/test.txt Del ...`), keys.zig (a scratch's Save prompt by `SPC f s`, was `::` Tab), modes.zig, mouse.zig (`Keep Del`, the own text swept), panes.zig ("an unsaved file's tag ... Save and Undo come into its words", Collapse by `C-w c`), placement.zig, terminals.zig (`Del Term`), addons_pdf.zig (`PdfSections PdfTint PdfFit Del`), columns_and_tags.zig; addons/fake/fake.out and addons/life/life.out re-recorded (a tag one row shorter: one more body row); PROCESS (a helper's edits): 11 cases clicked a word gone or a row a shorter tag moved (lookpanes, selarg, tagnav, tag, images, collapse, layout-open, ghostty-mid, look-fd-deep, respawn, ttylook: each to the word's new place, the own text or the row it moved to) and 5 more whose clicks had silently stopped doing what their comments say (shrinktag, windowops, ttyedit, tagcmd, chordcut); GOLDENS: 101 re-recorded, every change one of: a tag's words (`Term+bash Save Mode Filter Collapse Del` to `Del Term+bash`), a tag no longer wrapping (its body a row taller, the rows under it up one, one more line at the foot), splits a row smaller where a tag above stopped wrapping, a click at a fixed row landing a body row lower, the computed words' ink in style rows; three now do what their comments say where the old golden recorded a miss (chordcut's end, jumps' look-row, wrap's logical-j); ttyhelp.golden left as the merge's placeholder (M1's; this change moves it too); core-test 1126/1299 (173 skipped: +3), shell-test 1347/1350 (3 skipped), pane-test 183/184 (1 skipped), behaviour-test 280/280 and --replay 20 seeds of 70 steps 0 failures, process-test 1 of 147 failed (ttyhelp, the placeholder; 3 skipped), term-test 17/17, kitty-test 45/45, the gui unit-test 1949/1954 (4 skipped; its one failure colors.zig's whole-ring CPU timing at a load of 8.7, L1's, passing in core-test, and the known BaselineHarnessMismatch); the soak `replicas -- --clients 5 --rtt 30,80,207`: diverged 0, unequal 0, agree/differ 451/0 420/0 623/0, unlisted stops 0, the corpus 22 of 22 scenes the same, no leak; no dump field changes (no fuzz); no frame/perf gate (moved to the programme's end); load 2.6 to 10.5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'test/behaviour')
| -rw-r--r-- | test/behaviour/addons_pdf.zig | 4 | ||||
| -rw-r--r-- | test/behaviour/columns_and_tags.zig | 2 | ||||
| -rw-r--r-- | test/behaviour/keys.zig | 14 | ||||
| -rw-r--r-- | test/behaviour/modes.zig | 17 | ||||
| -rw-r--r-- | test/behaviour/mouse.zig | 17 | ||||
| -rw-r--r-- | test/behaviour/panes.zig | 23 | ||||
| -rw-r--r-- | test/behaviour/placement.zig | 5 | ||||
| -rw-r--r-- | test/behaviour/tags.zig | 82 | ||||
| -rw-r--r-- | test/behaviour/terminals.zig | 6 |
9 files changed, 101 insertions, 69 deletions
diff --git a/test/behaviour/addons_pdf.zig b/test/behaviour/addons_pdf.zig index 0c7982d1..dedf157a 100644 --- a/test/behaviour/addons_pdf.zig +++ b/test/behaviour/addons_pdf.zig @@ -45,10 +45,10 @@ test "addons: a PDF is the pdf addon's pane, its pages pictures, its page in its const first = try shown(&s, n); try std.testing.expect(first.len >= 1); // Its tag: its page, then the core's art words (it placed a picture), - // its path and its kind's words. + // its path and its kind's words, then Del (UX K'3). const tag = try s.read(s.at("/pane/{d}/tag", .{n})); try std.testing.expect(std.mem.startsWith(u8, tag, "[1/16] petscii:off palette:commodore ascii:on /")); - try std.testing.expect(has(tag, "/docs/design.pdf Term PdfSections PdfTint PdfFit Collapse Del")); + try std.testing.expect(has(tag, "/docs/design.pdf PdfSections PdfTint PdfFit Del")); try std.testing.expect(has(try ctlOf(&s, n), " fit:width tint:filtered mode:normal ")); // The words: bare they step, given a value they take it, any other // value refused; another pane's is refused and leaves the PDF alone. diff --git a/test/behaviour/columns_and_tags.zig b/test/behaviour/columns_and_tags.zig index 9abe64f4..e1257897 100644 --- a/test/behaviour/columns_and_tags.zig +++ b/test/behaviour/columns_and_tags.zig @@ -180,7 +180,7 @@ test "columns-and-tags: a click past a column tag's text types after it, a newli try expectEqualStrings("New Term Find Grep Joincol Delcol Snarf", try s.read(tag)); try std.testing.expect(std.mem.indexOf(u8, try s.screen(), rows ++ " Snarf ") != null); // The pane's tag on the row right under it: the column's is one row. - try std.testing.expectEqual((try s.where(rows))[1] + 1, (try s.where("/test.txt Save"))[1]); + try std.testing.expectEqual((try s.where(rows))[1] + 1, (try s.where("/test.txt Del"))[1]); // Wider than the screen: the tag scrolls to keep its caret drawn. try s.keys(" 界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界"); const col, const row = (try s.cursor()).?; diff --git a/test/behaviour/keys.zig b/test/behaviour/keys.zig index 6256a0b7..9eb33ac2 100644 --- a/test/behaviour/keys.zig +++ b/test/behaviour/keys.zig @@ -14,7 +14,7 @@ test "keys: a prompt's entry and cancellation leave the tag, the body and its cu const n = try s.focused(); const tag = s.at("/pane/{d}/tag", .{n}); const dot = s.at("/pane/{d}/dot", .{n}); - try s.replace(tag, " keep"); + try s.replace(tag, "keep"); for ([_]struct { keys: []const u8, shown: []const u8 }{ .{ .keys = "s", .shown = " s zq" }, .{ .keys = "|", .shown = " | zq" }, @@ -34,14 +34,15 @@ test "keys: a prompt's entry and cancellation leave the tag, the body and its cu try s.keys("\x1b"); try std.testing.expectError(error.NotOnScreen, s.where(case.shown)); try std.testing.expect(std.mem.endsWith(u8, try s.read(s.at("/pane/{d}/ctl", .{n})), " mode:normal ")); - try std.testing.expectEqualStrings("/test.txt keep", try s.read(tag)); + try std.testing.expectEqualStrings("/test.txt Del keep", try s.read(tag)); try std.testing.expectEqual(.{ 6, 6 }, try s.range(dot)); try s.expect(s.at("/pane/{d}/body", .{n}), "one\ntwo\n"); } - // Save on a scratch asks for a path, starting from its directory. + // Save on a scratch (SPC f s: no word of its tag, UX K'3) asks for a + // path, starting from its directory. const scratch = try s.newPane(); const scratch_tag = try s.read(s.at("/pane/{d}/tag", .{scratch})); - try s.keys("::\tzq"); + try s.keys(" fszq"); _ = try s.where("/zq"); try s.expect(s.at("/pane/{d}/tag", .{scratch}), scratch_tag); try s.keys("\x1b"); @@ -124,7 +125,7 @@ test "keys: a count or a prefix a click or a change of pane cancels leaves nothi .body => try s.click("abcdefghij", 3, 1), .tag => { // A clicked tag is in normal mode: `:` goes back. - try s.click("/test.txt Save", "/test.txt ".len + 3, 1); + try s.click("/test.txt Del", "/test.txt ".len + 2, 1); try s.keys(":"); }, .focus, .last => { @@ -273,7 +274,8 @@ test "keys: Save's prompt on a scratch starts from the scratch's directory, one // New from the file's pane: a scratch in its directory. try s.write(s.at("/pane/{d}/exec", .{n}), "New\n"); try std.testing.expect(try s.focused() != n); - try s.keys("::\tzq"); + // SPC f s: Save is no word of a scratch's tag (UX K'3). + try s.keys(" fszq"); _ = try s.where(c[1]); try s.keys("\x1b"); } diff --git a/test/behaviour/modes.zig b/test/behaviour/modes.zig index 0f7c9d26..47f2ccd2 100644 --- a/test/behaviour/modes.zig +++ b/test/behaviour/modes.zig @@ -98,7 +98,8 @@ test "modes: Esc back into a file leaves its view where it was, and a look centr // The other arm still centres: a look's `:NN`. const line = 60; try s.write(s.at("/pane/{d}/look", .{doc}), s.at(":{d}\n", .{line})); - const rows = (try s.where("Term Save Mode"))[1] - (try s.where("/test.txt"))[1] - 1; + // (The shell's tag: its computed Del, then its own text, Term.) + const rows = (try s.where("Del Term"))[1] - (try s.where("/test.txt"))[1] - 1; // Drawn mid-pane, a row either way. const drawn_at = line - try topLine(&s, "/test.txt"); try std.testing.expect(drawn_at + 1 >= rows / 2 and drawn_at <= rows / 2 + 1); @@ -163,7 +164,7 @@ test "modes: Ctrl-w outlines a pane, h j k l move the outline, and Enter, Esc, : // `:` gives the outlined pane's tag the keyboard. try s.keys("\x17l:"); try expectEqual(b, try s.focused()); - try expectEqual((try s.where("/b.txt Save"))[1], (try s.cursor()).?[1]); + try expectEqual((try s.where("/b.txt Del"))[1], (try s.cursor()).?[1]); try s.keys("\x1b"); // A letter goes straight there. try s.keys("\x17a"); @@ -190,11 +191,11 @@ test "modes: in window mode d deletes the outlined pane, asking k or j between t try s.write(s.at("/pane/{d}/name", .{mid}), "/mid\n"); try s.write(s.at("/pane/{d}/name", .{low}), "/low\n"); const names = &[_][]const u8{ "/test.txt", "/mid", "/low" }; - const row_top = (try s.where("/test.txt Save"))[1]; - const row_mid = (try s.where("/mid Save"))[1]; - const row_low = (try s.where("/low Save"))[1]; + const row_top = (try s.where("/test.txt Del"))[1]; + const row_mid = (try s.where("/mid Del"))[1]; + const row_low = (try s.where("/low Del"))[1]; // From the bottom pane, the outline up to the middle one. - const mx, const my = try s.where("/mid Save"); + const mx, const my = try s.where("/mid Del"); const plain = try s.bg(mx, my); try s.keys("\x17k"); const lit = try s.bg(mx, my); @@ -217,7 +218,7 @@ test "modes: in window mode d deletes the outlined pane, asking k or j between t // j: the pane below takes the rows, and the outline goes with them. try s.keys("dj"); try std.testing.expect(!try listed(&s, mid)); - try expectEqual(row_top, (try s.where("/test.txt Save"))[1]); + try expectEqual(row_top, (try s.where("/test.txt Del"))[1]); try expectEqual(row_mid, (try s.where("/low "))[1]); try std.testing.expectEqualStrings("/low", try outlined(&s, lit, &.{ "/test.txt", "/low" })); // With one neighbour nothing is asked: d closes it, the outline on the @@ -461,7 +462,7 @@ test "modes: hopping between two panes by Esc, window mode or a click makes no p try expectEqual(want, try s.focused()); } const doc_row = (try s.where("row"))[1]; - const shell_row = (try s.where("Term Save Mode"))[1] + 1; + const shell_row = (try s.where("Del Term"))[1] + 1; for (0..8) |_| { const other = if (try s.focused() == doc) shell else doc; const row = if (other == doc) doc_row else shell_row; diff --git a/test/behaviour/mouse.zig b/test/behaviour/mouse.zig index 951ab493..0e22416f 100644 --- a/test/behaviour/mouse.zig +++ b/test/behaviour/mouse.zig @@ -25,9 +25,10 @@ test "mouse: a double-click selects a word, a line, a bracketed or quoted text, try s.click(w.at, w.into, 1); try s.expect(sel, ""); } - // In the tag too: what it selected is what a yank takes. - try s.click("Follow Del", "Follow D".len, 1); - try s.click("Follow Del", "Follow D".len, 1); + // In the tag too: what it selected is what a yank takes (its computed + // Del, after Keep: the file is reading). + try s.click("Keep Del", "Keep D".len, 1); + try s.click("Keep Del", "Keep D".len, 1); try s.keys("\x1by:ggP"); try s.expect(s.at("/pane/{d}/body", .{n}), "Delcall foo_bar(a, b)\nsay \"hi there\"\n"); } @@ -120,13 +121,15 @@ test "mouse: a B1 sweep over several lines is a stream, as acme's, in a body and // Upward, the same text. try mouse(&s, "m {d} {d} 1\nm {d} {d} 1\nm {d} {d} 3\nm {d} {d} 0\n", .{ x + 1, y + 2, x + 2, y, x + 2, y, x + 2, y }); try s.expect(body, "alarlie\n"); - // A tag of several rows sweeps the same way. + // A tag of several rows sweeps the same way, in its own text (its + // computed words are read-only, UX K'1). const tag = s.at("/pane/{d}/tag", .{n}); - try s.write(tag, "\nLook Edit"); + try s.write(tag, "Collapse\nLook Edit"); + const was = try s.read(tag); const tx, const ty = try s.where("Collapse"); const lx, const ly = try s.where("Look Edit"); try mouse(&s, "m {d} {d} 1\nm {d} {d} 1\nm {d} {d} 3\nm {d} {d} 0\n", .{ tx + 3, ty, lx + 1, ly, lx + 1, ly, lx + 1, ly }); - try s.expect(tag, "/test.txt Save Term Colok Edit"); + try s.expect(tag, s.at("{s}Colok Edit", .{was[0 .. was.len - "Collapse\nLook Edit".len]})); } test "mouse: a click on either half of a wide character lands before it, in the text and on a tag's path, and the caret steps over it whole" { @@ -157,7 +160,7 @@ test "mouse: a click on either half of a wide character lands before it, in the // Typed past the tag's words, a two-byte λ goes in and one backspace // takes it out whole. const tag = try s.read(s.at("/pane/{d}/tag", .{n})); - try s.click("Follow Del", "Follow Del".len + 1, 1); + try s.click("Keep Del", "Keep Del".len + 1, 1); const caret = (try s.cursor()).?; // A clicked tag is in normal mode: `i` types at the caret. try s.keys("iλ"); diff --git a/test/behaviour/panes.zig b/test/behaviour/panes.zig index 4c76df25..11c2a0e6 100644 --- a/test/behaviour/panes.zig +++ b/test/behaviour/panes.zig @@ -167,7 +167,7 @@ test "panes: a second lock is refused until the holder unlocks or closes, and bi s.clunk(e); } -test "panes: an unsaved file's tag is its name alone, its dirty file says it is unsaved" { +test "panes: an unsaved file's tag marks nothing on its name, Save and Undo come into its words, its dirty file says it is unsaved" { var s = try Session.initFile(std.testing.allocator, "before\n"); defer s.deinit(); // A held pane (Keep): its tag as it was before the walk, no `Keep` word (SPEC §6.5). @@ -175,9 +175,13 @@ test "panes: an unsaved file's tag is its name alone, its dirty file says it is const n = try s.focused(); const tag = s.at("/pane/{d}/tag", .{n}); const clean = try s.read(tag); + try std.testing.expectEqualStrings("/test.txt Del ", clean); try s.write(s.at("/pane/{d}/body", .{n}), "after\n"); - try std.testing.expectEqualStrings(clean, try s.read(tag)); - try std.testing.expect(std.mem.indexOf(u8, clean, " *") == null); + // Its words say what acts now, Save and Undo (UX K'3); no mark after + // the name. + const unsaved = try s.read(tag); + try std.testing.expectEqualStrings("/test.txt Save Undo Del ", unsaved); + try std.testing.expect(std.mem.indexOf(u8, unsaved, " *") == null); try s.expect(s.at("/pane/{d}/dirty", .{n}), "1\n"); } @@ -237,14 +241,19 @@ test "panes: Collapse keeps the text and folds the pane to its tag, and again re var t = try Session.initTerm(std.testing.allocator); defer t.deinit(); const n = try s.focused(); + // Collapse is no word of a tag (UX K'3), a file's, a scratch's or a + // terminal's: its keys are C-w c and SPC w c, and it runs from ctl. for ([_][]const u8{ try s.read(s.at("/pane/{d}/tag", .{n})), try s.read(s.at("/pane/{d}/tag", .{try s.newPane()})), - }) |tag| try std.testing.expect(std.mem.endsWith(u8, tag, " Collapse Follow Del")); - try std.testing.expect(std.mem.endsWith(u8, try t.read(t.at("/pane/{d}/tag", .{try t.focused()})), " Collapse Del")); + try t.read(t.at("/pane/{d}/tag", .{try t.focused()})), + }) |tag| try std.testing.expect(std.mem.indexOf(u8, tag, "Collapse") == null); try s.write(s.at("/pane/{d}/ctl", .{try s.focused()}), "Del\n"); const ctl = s.at("/pane/{d}/ctl", .{n}); - try s.write(ctl, "Collapse\n"); + // C-w c folds the outlined pane, the keyboard's; Esc leaves window + // mode on it. + try std.testing.expectEqual(n, try s.focused()); + try s.keys("\x17c\x1b"); // Folded to its tag: no text drawn, no cursor in it, the text kept. try std.testing.expect(std.mem.indexOf(u8, try s.read(ctl), " collapsed ") != null); try std.testing.expect(std.mem.indexOf(u8, try s.screen(), "keep this text") == null); @@ -321,7 +330,7 @@ test "panes: PdfTint steps a PDF's tint, read in its ctl and never in its tag, a const n = try s.lookFile("docs/design.pdf"); const ctl = s.at("/pane/{d}/ctl", .{n}); const tag = try s.read(s.at("/pane/{d}/tag", .{n})); - try std.testing.expect(std.mem.endsWith(u8, tag, " PdfSections PdfTint PdfFit Collapse Del")); + try std.testing.expect(std.mem.endsWith(u8, tag, " PdfSections PdfTint PdfFit Del ")); for ([_][]const u8{ "full", "disabled", "filtered" }) |want| { try std.testing.expect(std.mem.indexOf(u8, try s.read(ctl), "fit:width ") != null); try s.write(ctl, "PdfTint\n"); diff --git a/test/behaviour/placement.zig b/test/behaviour/placement.zig index 467afd1b..c0bf6305 100644 --- a/test/behaviour/placement.zig +++ b/test/behaviour/placement.zig @@ -25,9 +25,10 @@ test "placement: an empty active column takes the new pane whole, a look from an try std.testing.expectEqualStrings(s.at("{d}:{d} {d}:{d}", .{ try s.column(0), first, try s.column(1), made }), try s.columns()); } -/// The screen row the tag starting `name` is drawn on. +/// The screen row the tag starting `name` is drawn on: the name, then a +/// blank before its computed words (Del at least, UX K'3). fn tagRow(s: *Session, name: []const u8) !usize { - return (try s.where(s.at("{s} Save", .{name})))[1]; + return (try s.where(s.at("{s} ", .{name})))[1]; } test "placement: New and 9P's new take the bottom half of the column's last pane" { diff --git a/test/behaviour/tags.zig b/test/behaviour/tags.zig index c8de115b..e7779b86 100644 --- a/test/behaviour/tags.zig +++ b/test/behaviour/tags.zig @@ -25,10 +25,11 @@ test "tags: s and S in a tag answer for the tag's own text; / still searches the // A held pane (Keep): its tag as it was before the walk, no `Keep` word (SPEC §6.5). try s.write(s.at("/pane/{d}/exec", .{try s.focused()}), "Keep\n"); const n = try s.focused(); - try s.replace(s.at("/pane/{d}/tag", .{n}), " Save Del Snarf"); + // Its own text, after its computed Del (UX K'1). + try s.replace(s.at("/pane/{d}/tag", .{n}), "Save Del Snarf"); // The tag's line, its S's selected, then changed: both are the tag's. try s.keys("::xsS\ncZ\x1b"); - try std.testing.expectEqualStrings("/test.txt Zave Del Znarf", try tag(&s, n)); + try std.testing.expectEqualStrings("/test.txt Del Zave Del Znarf", try tag(&s, n)); try s.expect(s.at("/pane/{d}/body", .{n}), "Some body\n"); // `/` from the tag is the body's search, as acme's Look from a tag is. // Its places list the body's match. @@ -42,10 +43,12 @@ test "tags: ms and md edit a tag's own text, and the text the edit made is read // A held pane (Keep): its tag as it was before the walk, no `Keep` word (SPEC §6.5). try s.write(s.at("/pane/{d}/exec", .{try s.focused()}), "Keep\n"); const n = try s.focused(); + // Its own text after its computed Del (UX K'1), where `:` lands. + try s.write(s.at("/pane/{d}/tag", .{n}), "Save Term"); try s.keys("::miwms("); - try std.testing.expectEqualStrings("/test.txt (Save) Term Collapse Follow Del", try tag(&s, n)); + try std.testing.expectEqualStrings("/test.txt Del (Save) Term", try tag(&s, n)); try s.keys("md("); - try std.testing.expectEqualStrings("/test.txt Save Term Collapse Follow Del", try tag(&s, n)); + try std.testing.expectEqualStrings("/test.txt Del Save Term", try tag(&s, n)); } test "tags: the keyboard reaches a tag's path, which it can select and yank but not edit" { @@ -70,27 +73,29 @@ test "tags: the keyboard reaches a tag's path, which it can select and yank but try s.expect(s.at("/pane/{d}/name", .{n}), "/test.txt\n"); // After the path, the text is the tag's own to edit. try s.keys("::A!\x1b"); - try std.testing.expectEqualStrings("/test.txt Save Term Collapse Follow Del!", try tag(&s, n)); + try std.testing.expectEqualStrings("/test.txt Del !", try tag(&s, n)); // What it yanked was the path. try s.keys(":P"); try s.expect(s.at("/pane/{d}/body", .{n}), "/test.txtbody\n"); } -test "tags: a tag remembers its cursor, starts on Save, and a click moves it" { +test "tags: a tag remembers its cursor, starts on its own text, and a click moves it" { var s = try Session.initFile(std.testing.allocator, "body\n"); defer s.deinit(); // A held pane (Keep): its tag as it was before the walk, no `Keep` word (SPEC §6.5). try s.write(s.at("/pane/{d}/exec", .{try s.focused()}), "Keep\n"); const first = try s.focused(); + // Its own text, after its computed Del (UX K'1). + try s.write(s.at("/pane/{d}/tag", .{first}), "Save Term"); try s.write("/ctl", "Newcol\n"); const second = try s.newPane(); try s.write(s.at("/pane/{d}/name", .{second}), "/second.txt"); const focus = s.at("{d}", .{first}); const other = s.at("{d}", .{second}); try s.write("/focus", focus); - // Nothing to remember yet: `:` lands on Save. + // Nothing to remember yet: `:` lands on its own text. try s.keys("::"); - try std.testing.expectEqual(@as(usize, "/test.txt ".len), try tagCol(&s, "/test.txt")); + try std.testing.expectEqual(@as(usize, "/test.txt Del ".len), try tagCol(&s, "/test.txt")); // Home is the line's start, the path's: the keyboard reaches it. try s.keys(home ++ right ++ right ++ right); try std.testing.expectEqual(@as(usize, 3), try tagCol(&s, "/test.txt")); @@ -110,11 +115,11 @@ test "tags: a tag remembers its cursor, starts on Save, and a click moves it" { // A click in the tag puts its cursor there, the pane's keyboard with it. try s.click("Save Term", 6, 1); try std.testing.expectEqual(first, try s.focused()); - try std.testing.expectEqual(@as(usize, "/test.txt Save T".len), try tagCol(&s, "/test.txt")); + try std.testing.expectEqual(@as(usize, "/test.txt Del Save T".len), try tagCol(&s, "/test.txt")); // A prompt opened and left from the body leaves it there (a clicked // tag is in normal mode: `:` goes back to the body). try s.keys(":/\x1b::"); - try std.testing.expectEqual(@as(usize, "/test.txt Save T".len), try tagCol(&s, "/test.txt")); + try std.testing.expectEqual(@as(usize, "/test.txt Del Save T".len), try tagCol(&s, "/test.txt")); try s.keys(":"); try s.expect(s.at("/pane/{d}/body", .{first}), "body\n"); } @@ -125,16 +130,19 @@ test "tags: executing a word from the tag runs it and gives the keyboard back to defer s.deinit(); const n = try s.focused(); try s.keys("ix\x1b"); - // `:` lands on Save; the execute key runs it, the look key looks - // it up. Either way the tag lets go of the keyboard first. + // Save typed into the tag's own text, where `:` lands (UX K'1); + // the execute key runs it, the look key looks it up. Either way + // the tag lets go of the keyboard first. + try s.write(s.at("/pane/{d}/tag", .{n}), "Save"); try s.keys("::"); try s.keys(chord); try std.testing.expectEqual(@as(usize, if (chord[0] == '\t') 1 else 0), s.saved); try s.keys("iQ\x1b"); try s.expect(s.at("/pane/{d}/body", .{n}), "xQbody\n"); - // ...and the tag still knows where it was. + // ...and the tag still knows where it was: on that Save, after the + // computed words the save changed. try s.keys("::"); - try std.testing.expectEqual(@as(usize, "/test.txt ".len), try tagCol(&s, "/test.txt")); + try std.testing.expectEqual((try tag(&s, n)).len - "Save".len, try tagCol(&s, "/test.txt")); } } @@ -144,15 +152,15 @@ test "tags: a renamed path moves the tag's cursor with the text after it and a s // A held pane (Keep): its tag as it was before the walk, no `Keep` word (SPEC §6.5). try s.write(s.at("/pane/{d}/exec", .{try s.focused()}), "Keep\n"); const n = try s.focused(); - try s.keys(":::"); // `::` on Save, and `:` back + try s.keys(":::"); // `::` on its own text, after Del, and `:` back try s.write(s.at("/pane/{d}/name", .{n}), "/界.zig"); try s.keys("::"); - try std.testing.expectEqual(@as(usize, "/界.zig ".len - 1), try tagCol(&s, "/界")); + try std.testing.expectEqual(@as(usize, "/界.zig Del ".len - 1), try tagCol(&s, "/界")); try s.keys(":"); try s.replace(s.at("/pane/{d}/tag", .{n}), "é"); try s.keys("::"); - // `/界.zig é`: the cursor is pulled back onto the last character. - try std.testing.expectEqual(@as(usize, "/界.zig ".len - 1), try tagCol(&s, "/界")); + // `/界.zig Del é`: the cursor is pulled back onto the last character. + try std.testing.expectEqual(@as(usize, "/界.zig Del ".len - 1), try tagCol(&s, "/界")); try s.expect(s.at("/pane/{d}/body", .{n}), "body\n"); } @@ -192,7 +200,7 @@ test "tags: a tag's normal mode is the body's: motions stay in the tag and inser try s.keys(window ++ "h\n"); try std.testing.expectEqual(first, try s.focused()); try s.keys("::i\u{F018}hjklHJKL:"); - try std.testing.expectEqualStrings("/test.txt Save Term Collapse Follow DelhjklHJKL:", try tag(&s, first)); + try std.testing.expectEqualStrings("/test.txt Del hjklHJKL:", try tag(&s, first)); try std.testing.expect(std.mem.endsWith(u8, try s.read(s.at("/pane/{d}/ctl", .{first})), " mode:normal ")); try s.expect(s.at("/pane/{d}/body", .{first}), "body\n"); try std.testing.expectEqual(first, try s.focused()); @@ -206,7 +214,7 @@ test "tags: a tag with a newline in it is as tall as its lines, and each line is const n = try s.focused(); // Insert mode in a tag is a body's: Enter is a new line. try s.keys("::A\nSecond"); - try std.testing.expectEqualStrings("/test.txt Save Term Collapse Follow Del\nSecond", try tag(&s, n)); + try std.testing.expectEqualStrings("/test.txt Del \nSecond", try tag(&s, n)); const x, const y = try s.where("/test.txt"); try std.testing.expectEqual(.{ x, y + 1 }, try s.where("Second")); // The caret is on the second line, after what was typed. @@ -220,7 +228,7 @@ test "tags: a tag with a newline in it is as tall as its lines, and each line is try std.testing.expectEqual(.{ x + 2, y + 1 }, (try s.cursor()).?); // A clicked tag is in normal mode: `i` types where it was clicked. try s.keys("iX"); - try std.testing.expectEqualStrings("/test.txt Save Term Collapse Follow Del\nSeXcond", try tag(&s, n)); + try std.testing.expectEqualStrings("/test.txt Del \nSeXcond", try tag(&s, n)); try s.expect(s.at("/pane/{d}/body", .{n}), "body\n"); } @@ -310,20 +318,20 @@ test "tags: a name drafted in the tag commits with Enter, cancels with two Escs, try s.write(s.at("/pane/{d}/exec", .{try s.focused()}), "Keep\n"); const n = try s.focused(); const name = s.at("/pane/{d}/name", .{n}); - try s.write(s.at("/pane/{d}/tag", .{n}), " JumpTrail"); + try s.write(s.at("/pane/{d}/tag", .{n}), "JumpTrail"); for ([_]bool{ false, true }) |commit| { const path = std.mem.trimEnd(u8, try s.read(name), "\n"); try clickPathEnd(&s, path); try s.keys("\x15/new name.zig"); try s.expect(name, s.at("{s}\n", .{path})); - _ = try s.where("/new name.zig Save Term Collapse Follow Del JumpTrail"); + _ = try s.where("/new name.zig Del JumpTrail"); try s.expect(s.at("/pane/{d}/body", .{n}), "original body\n"); // Esc keeps the draft pending; a second drops it. try s.keys(if (commit) "\n" else "\x1b\x1b"); try s.expect(name, if (commit) "/new name.zig\n" else "/test.txt\n"); - try std.testing.expectEqualStrings(s.at("{s} Save Term Collapse Follow Del JumpTrail", .{if (commit) "/new name.zig" else "/test.txt"}), try tag(&s, n)); + try std.testing.expectEqualStrings(s.at("{s} Del JumpTrail", .{if (commit) "/new name.zig" else "/test.txt"}), try tag(&s, n)); // The keyboard is the body's again. - try std.testing.expect((try s.cursor()).?[1] != (try s.where("Save Term"))[1]); + try std.testing.expect((try s.cursor()).?[1] != (try s.where("Del JumpTrail"))[1]); } try std.testing.expectEqual(@as(usize, 0), s.saved); // A name alone is no edit: the pane stays clean. @@ -338,9 +346,9 @@ test "tags: a drafted name's edits are by grapheme, and an empty one is not comm const n = try s.focused(); try clickPathEnd(&s, "/test.txt"); try s.keys("\x15/café界\x08"); - _ = try s.where("/café Save"); + _ = try s.where("/café Del"); try s.keys("\x08"); - _ = try s.where("/caf Save"); + _ = try s.where("/caf Del"); // (The tag, not the screen: the notice row says where the caret is.) const tagfile = s.at("/pane/{d}/tag", .{n}); try s.keys("\x15\n"); @@ -374,11 +382,13 @@ test "tags: middle clicking Save commits the drafted name before saving" { // A held pane (Keep): its tag as it was before the walk, no `Keep` word (SPEC §6.5). try s.write(s.at("/pane/{d}/exec", .{try s.focused()}), "Keep\n"); const n = try s.focused(); + // Save typed into its own text: a clean file's tag has no Save (UX K'3). + try s.write(s.at("/pane/{d}/tag", .{n}), "Save"); try clickPathEnd(&s, "/test.txt"); try s.keys("\x15/renamed.txt"); - try s.click("Save Term", 0, 2); + try s.click("Del Save", "Del ".len, 2); try s.expect(s.at("/pane/{d}/name", .{n}), "/renamed.txt\n"); - try std.testing.expectEqualStrings("/renamed.txt Save Term Collapse Follow Del", try tag(&s, n)); + try std.testing.expectEqualStrings("/renamed.txt Del Save", try tag(&s, n)); try s.expect(s.at("/pane/{d}/body", .{n}), "untouched\n"); try std.testing.expectEqual(@as(usize, 1), s.saved); } @@ -415,6 +425,8 @@ test "tags: a click on a tag puts its cursor there in normal mode: a letter is a var s = try Session.initFile(std.testing.allocator, "body\n"); defer s.deinit(); const n = try s.focused(); + // Its own text, after its computed words (UX K'1). + try s.write(s.at("/pane/{d}/tag", .{n}), "Save Term"); const was = try tag(&s, n); try s.click("Save", 0, 1); // `w` moves to the next word, as in a body's normal mode: nothing typed. @@ -459,16 +471,16 @@ test "tags: truncating a tag clears its own text, u in the tag undoes it, and > try s.truncate(h); try std.testing.expect(std.mem.indexOf(u8, try tag(&s, n), "Mine") == null); s.clunk(h); - try std.testing.expectEqualStrings("/test.txt", std.mem.trimEnd(u8, try tag(&s, n), " ")); + try std.testing.expectEqualStrings("/test.txt Del", std.mem.trimEnd(u8, try tag(&s, n), " ")); // The tag keeps its undo: undoing in it brings back what was cleared. try s.keys("::u:"); try std.testing.expect(std.mem.endsWith(u8, try tag(&s, n), " Mine")); // Written back without a leading space, the text still stands apart - // from the path, and a click on its first letter lands on it. + // from the computed words, and a click on its first letter lands on it. try s.replace(path, "Get"); - try std.testing.expectEqualStrings("/test.txt Get", try tag(&s, n)); + try std.testing.expectEqualStrings("/test.txt Del Get", try tag(&s, n)); try s.click("Get", 0, 1); - try std.testing.expectEqual(@as(usize, "/test.txt ".len), try tagCol(&s, "/test.txt")); + try std.testing.expectEqual(@as(usize, "/test.txt Del ".len), try tagCol(&s, "/test.txt")); // `echo Make > tag`: the newline ending the truncating write's text is // dropped, one only; a newline between its writes stays. const m = try s.hold(path, 1); @@ -476,10 +488,10 @@ test "tags: truncating a tag clears its own text, u in the tag undoes it, and > _ = try s.writeFid(m, "Make\n"); _ = try s.writeFid(m, "More\n\n"); s.clunk(m); - try std.testing.expectEqualStrings("/test.txt Make\nMore\n", try tag(&s, n)); + try std.testing.expectEqualStrings("/test.txt Del Make\nMore\n", try tag(&s, n)); // `>>` keeps what it is given. try s.write(path, " Tail\n"); - try std.testing.expectEqualStrings("/test.txt Make\nMore\n Tail\n", try tag(&s, n)); + try std.testing.expectEqualStrings("/test.txt Del Make\nMore\n Tail\n", try tag(&s, n)); } test "tags: a pane tag's file name is tinted, its directory, dirty marker and words not" { diff --git a/test/behaviour/terminals.zig b/test/behaviour/terminals.zig index f6bbdfa0..a2f7e951 100644 --- a/test/behaviour/terminals.zig +++ b/test/behaviour/terminals.zig @@ -13,7 +13,11 @@ test "terminals: Togglettymode and Ctrl-B share the mode's transitions, from the defer s.deinit(); const n = try s.focused(); const ctl = s.at("/pane/{d}/ctl", .{n}); - try std.testing.expect(std.mem.indexOf(u8, try s.read(s.at("/pane/{d}/tag", .{n})), " Mode ") != null); + // Mode is a word of its kind's, not its tag's (UX K'3): the tag is + // Del, then its own text, Term. + const tag = try s.read(s.at("/pane/{d}/tag", .{n})); + try std.testing.expect(std.mem.indexOf(u8, tag, " Mode ") == null); + try std.testing.expect(std.mem.indexOf(u8, tag, " Del Term") != null); try s.write(s.at("/pane/{d}/tag", .{n}), " Togglettymode"); try std.testing.expectEqualStrings("tty", try mode(&s, n)); try s.write(ctl, "Togglettymode\n"); |
