diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-04 10:56:51 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-04 10:59:26 -0300 |
| commit | 5752e5c94f27eced137f4ca061c68715d8b7131a (patch) | |
| tree | ffc1785740fb008e2ebb10053a2aaaaa25b82fd6 /test | |
| parent | 54f3ce0443f46f0bfe7565d6a31fb906beadf3b9 (diff) | |
| download | pardes-5752e5c94f27eced137f4ca061c68715d8b7131a.tar.gz pardes-5752e5c94f27eced137f4ca061c68715d8b7131a.zip | |
mouse: a click on a tag, a pane's, a column's or the workspace's, puts its cursor there in normal mode, where it was insert mode (the user's): a letter is a command, `i` types where it was clicked, Enter or Tab runs the word under it; the guide, the cheatsheet and the changelog say so; the tests that clicked a tag and typed now type `i` (or `a` after a sweep) first, and an Esc that left insert mode goes; snap: nine scripts likewise, layout-close's golden now the Del its chord was meant to run (the click had typed ` dk` into the tag); a behavioural test, checked to fail with insert mode back
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test')
| -rw-r--r-- | test/behaviour/columns_and_tags.zig | 8 | ||||
| -rw-r--r-- | test/behaviour/keys.zig | 3 | ||||
| -rw-r--r-- | test/behaviour/modes.zig | 5 | ||||
| -rw-r--r-- | test/behaviour/tags.zig | 26 | ||||
| -rw-r--r-- | test/mode.zig | 7 | ||||
| -rw-r--r-- | test/panes.zig | 2 | ||||
| -rw-r--r-- | test/snapshots/headersweep-restored.snap | 2 | ||||
| -rw-r--r-- | test/snapshots/headersweep.golden | 2 | ||||
| -rw-r--r-- | test/snapshots/headersweep.snap | 3 | ||||
| -rw-r--r-- | test/snapshots/images.snap | 1 | ||||
| -rw-r--r-- | test/snapshots/layout-close.golden | 17 | ||||
| -rw-r--r-- | test/snapshots/tag.snap | 12 | ||||
| -rw-r--r-- | test/snapshots/tagbottom.snap | 1 | ||||
| -rw-r--r-- | test/snapshots/tagnav.snap | 2 | ||||
| -rw-r--r-- | test/snapshots/theme.snap | 1 | ||||
| -rw-r--r-- | test/snapshots/ttyclick.snap | 4 |
16 files changed, 62 insertions, 34 deletions
diff --git a/test/behaviour/columns_and_tags.zig b/test/behaviour/columns_and_tags.zig index d485ee6e..a1add750 100644 --- a/test/behaviour/columns_and_tags.zig +++ b/test/behaviour/columns_and_tags.zig @@ -168,7 +168,8 @@ test "columns-and-tags: a click past a column tag's text types after it, a newli const rows = " New Tty Find Grep Joincol Delcol"; try std.testing.expect(std.mem.indexOf(u8, try s.screen(), rows ++ " ") != null); try s.click("Delcol", 20, 1); - try s.keys("\nSnarf"); + // A clicked tag is in normal mode: `i` types where it was clicked. + try s.keys("i\nSnarf"); try expectEqualStrings("New Tty 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. @@ -187,8 +188,9 @@ test "columns-and-tags: Enter in a tag in normal mode runs the word under its cu var s = try Session.initFile(std.testing.allocator, "body\n"); defer s.deinit(); const first = try s.focused(); + // A clicked tag starts in normal mode. try s.click("Newcol", 1, 1); - try s.keys("\x1b\n"); + try s.keys("\n"); try expectEqualStrings(s.at("{d}:{d} {d}:", .{ try s.column(0), first, try s.column(1) }), try s.columns()); // The workspace tag lets go of the keyboard: the new, empty column's // tag has it. @@ -196,7 +198,7 @@ test "columns-and-tags: Enter in a tag in normal mode runs the word under its cu try s.keys("iMine\x1b"); try std.testing.expect(std.mem.indexOf(u8, try s.read(s.at("/col/{d}/tag", .{try s.column(1)})), "Mine") != null); try s.click("Tutor", 1, 1); - try s.keys("\x1b\t"); + try s.keys("\t"); try std.testing.expect(std.mem.endsWith(u8, try s.read(s.at("/pane/{d}/name", .{try s.focused()})), "/+Tutor\n")); } diff --git a/test/behaviour/keys.zig b/test/behaviour/keys.zig index 41a2821a..3880b116 100644 --- a/test/behaviour/keys.zig +++ b/test/behaviour/keys.zig @@ -116,8 +116,9 @@ test "keys: a count or a prefix a click or a change of pane cancels leaves nothi switch (gesture) { .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.keys("\x1b:"); + try s.keys(":"); }, .focus, .last => { try s.keys(window ++ "l\n"); diff --git a/test/behaviour/modes.zig b/test/behaviour/modes.zig index dde3ffb6..06bcac98 100644 --- a/test/behaviour/modes.zig +++ b/test/behaviour/modes.zig @@ -34,10 +34,9 @@ test "modes: Esc in a column or the workspace tag gives the keyboard back to a p _ = try s.newPane(); for ([_][]const u8{ "New Tty", "Newcol" }) |tag| { const was = try s.focused(); - // A click types into the tag; Esc is normal mode there, the next - // one is out of it. + // A click puts the tag in normal mode, the keyboard there; Esc is + // out of it. try s.click(tag, 0, 1); - try s.keys("\x1b"); try s.expect("/focus", ""); try s.keys("\x1b"); try std.testing.expect(was != try s.focused()); diff --git a/test/behaviour/tags.zig b/test/behaviour/tags.zig index 6c1c6fcd..7cfa054f 100644 --- a/test/behaviour/tags.zig +++ b/test/behaviour/tags.zig @@ -105,8 +105,9 @@ test "tags: a tag remembers its cursor, starts on Save, and a click moves it" { try s.click("Save Tty", 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")); - // A prompt opened and left from the body leaves it there. - try s.keys("\x1b:/\x1b:"); + // 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 s.keys(":"); try s.expect(s.at("/pane/{d}/body", .{first}), "body\n"); @@ -213,7 +214,8 @@ test "tags: a tag with a newline in it is as tall as its lines, and each line is try s.keys("\x1b:"); try s.write("/mousein", s.at("m {d} {d} 1\nm {d} {d} 0\n", .{ x + 2, y + 1, x + 2, y + 1 })); try std.testing.expectEqual(.{ x + 2, y + 1 }, (try s.cursor()).?); - try s.keys("X"); + // A clicked tag is in normal mode: `i` types where it was clicked. + try s.keys("iX"); try std.testing.expectEqualStrings("/test.txt Save Tty Collapse Del\nSeXcond", try tag(&s, n)); try s.expect(s.at("/pane/{d}/body", .{n}), "body\n"); } @@ -236,7 +238,7 @@ test "tags: a tag with more lines than rows scrolls to keep its caret in view" { try std.testing.expectEqual(.{ x, y }, try s.where("L13")); try std.testing.expectError(error.NotOnScreen, s.where("L12")); try s.write("/mousein", s.at("m {d} {d} 1\nm {d} {d} 0\n", .{ x + 1, y + 1, x + 1, y + 1 })); - try s.keys("X"); + try s.keys("iX"); _ = try s.where("LX14"); // Back to the first line brings the prefix back into view. try s.keys("\x1bgg"); @@ -397,3 +399,19 @@ test "tags: a name typed into the tag's path survives Esc, pending, and the next try s.expect(name, "/ztest.txt\n"); try std.testing.expect(std.mem.startsWith(u8, try s.read(s.at("/pane/{d}/tag", .{n})), "/ztest.txt ")); } + +test "tags: a click on a tag puts its cursor there in normal mode: a letter is a command, i types where it was clicked" { + var s = try Session.initFile(std.testing.allocator, "body\n"); + defer s.deinit(); + const n = try s.focused(); + 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. + try s.keys("w"); + try std.testing.expectEqualStrings(was, try tag(&s, n)); + // Clicked again: `i` types where the click put the cursor. + try s.click("Save", 2, 1); + try s.keys("iQ\x1b"); + try std.testing.expect(std.mem.indexOf(u8, try tag(&s, n), " SaQve ") != null); + try s.expect(s.at("/pane/{d}/body", .{n}), "body\n"); +} diff --git a/test/mode.zig b/test/mode.zig index f49c434c..40a23fc4 100644 --- a/test/mode.zig +++ b/test/mode.zig @@ -36,12 +36,11 @@ test "Mode cycles terminal modes and keeps legacy toggle and custom tags" { try std.testing.expect(std.mem.indexOf(u8, try pardes.tagline.tagText(p, p.scratch.allocator(), pane), " Mode") != null); try mode(p, 0, .normal); try mode(p, 0, .insert); - // A clicked tag is typed into; its execute key is a normal-mode key, as - // a body's is, and the body keeps its own mode meanwhile. + // A clicked tag is in normal mode, where its execute key is, as a + // body's is, and the body keeps its own mode meanwhile. try clickModeTag(p); - try std.testing.expectEqual(panes.Text.Mode.insert, pane.tag.mode); + try std.testing.expectEqual(panes.Text.Mode.normal, pane.tag.mode); try std.testing.expectEqual(panes.Text.Mode.insert, pane.body.mode); - p.update(.{ .key = .{ .cp = pardes.Key.escape } }); p.update(.{ .key = .{ .cp = pardes.Key.tab } }); try std.testing.expectEqual(panes.Text.Mode.tty, pane.body.mode); try std.testing.expect(pane.focus == .body); diff --git a/test/panes.zig b/test/panes.zig index db816d41..3b842c59 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -63,6 +63,8 @@ const TagLayerTests = struct { p.update(.{ .mouse = mouse(layer, x, .release) }); try std.testing.expect(pane.focus == .tag); try std.testing.expectEqual(at, @as(usize, @intCast(pane.tag.cur_col))); + // A clicked tag is in normal mode: `i` types where it was clicked. + p.update(.{ .key = .{ .cp = 'i', .text = "i" } }); p.update(.{ .key = .{ .cp = 'X', .text = "X" } }); _ = try p.render(frame.allocator()); const edited = try pardes.tagline.tagText(p, frame.allocator(), pane); diff --git a/test/snapshots/headersweep-restored.snap b/test/snapshots/headersweep-restored.snap index c2918e1a..b0d51f6e 100644 --- a/test/snapshots/headersweep-restored.snap +++ b/test/snapshots/headersweep-restored.snap @@ -12,6 +12,7 @@ release middle @Restore 1 stable 900 15000 press left 50 2 release left 50 2 +key i key space text echo RE''STORED-COL key esc @@ -27,6 +28,7 @@ stable 700 15000 snap col-swept press left 118 1 release left 118 1 +key i key space text echo RE''STORED-WS key esc diff --git a/test/snapshots/headersweep.golden b/test/snapshots/headersweep.golden index a178306f..11ffa165 100644 --- a/test/snapshots/headersweep.golden +++ b/test/snapshots/headersweep.golden @@ -52,7 +52,7 @@ |9: 1 ZQNEEDLE == snap cancelled grid=120x21 cursor=7,9 == style selected grid=120x21 -|1: 0-1 d,#887455, 2-59 #b2c3b8,#1d2824, 60-61 #b2c3b8,#887455, 62-69 #becfc4,#314738, 70-78 #f5f7ee,#3c614a, 79-79 #f5f7ee,#314738, 80-119 #becfc4,#314738, +|1: 0-1 d,#887455, 2-59 #b2c3b8,#1d2824, 60-61 #b2c3b8,#887455, 62-69 #becfc4,#314738, 70-79 #f5f7ee,#3c614a, 80-119 #becfc4,#314738, |2: 0-1 d,#496656, 2-34 #b2c3b8,#1d2824, 35-43 #d3b0d9,#1d2824, 44-59 #b2c3b8,#1d2824, 60-61 #b2c3b8,#add38a, 62-94 #becfc4,#314738, 95-103 #dfbce5,#314738, 104-119 #becfc4,#314738, |3: 0-2 d,#1d2824, 3-59 #b2c3b8,#1d2824, 60-62 #b2c3b8,#314738, 63-119 #becfc4,#314738, |7: 0-1 d,#496656, 2-34 #b2c3b8,#1d2824, 35-42 #d3b0d9,#1d2824, 43-59 #b2c3b8,#1d2824, 60-60 #b2c3b8,#608269, 61-119 #b2c3b8,#0d1410, diff --git a/test/snapshots/headersweep.snap b/test/snapshots/headersweep.snap index be070357..68ee16b0 100644 --- a/test/snapshots/headersweep.snap +++ b/test/snapshots/headersweep.snap @@ -10,6 +10,7 @@ stable 700 20000 # the column tag: type a command onto it, then sweep the whole command press left 50 2 release left 50 2 +key i key space text echo SW''EPT-COL key esc @@ -26,6 +27,7 @@ snap col-swept # the workspace tag, the same press left 110 1 release left 110 1 +key i key space text echo SW''EPT-WS key esc @@ -40,6 +42,7 @@ snap ws-swept # where a click would look for all of `xxhay.txtxx` press left 118 1 release left 118 1 +key i key space text xxhay.txtxx key esc diff --git a/test/snapshots/images.snap b/test/snapshots/images.snap index 6288a3ba..caed1fa1 100644 --- a/test/snapshots/images.snap +++ b/test/snapshots/images.snap @@ -48,6 +48,7 @@ stable 400 5000 press left @Tty 7 release left @Tty 7 stable 400 5000 +key i send Zork\x20 stable 400 5000 snap tag-edit diff --git a/test/snapshots/layout-close.golden b/test/snapshots/layout-close.golden index a37366e0..fc7870cd 100644 --- a/test/snapshots/layout-close.golden +++ b/test/snapshots/layout-close.golden @@ -54,10 +54,15 @@ |29: se Del |30: ls |31: marker.txt -== snap del grid=140x41 cursor=7,8 -|8: T dkty+bash Save Mode Filter Col -|9: lapse Del -== snap exit grid=140x41 cursor=4,12 +== snap del grid=140x41 cursor=4,9 +|5: ls ls marker.txt +|6: marker.txt marker.txt +|7: +|8: +|9: +|10: +|11: +== snap exit grid=140x41 cursor=4,9 |22: |23: |24: @@ -66,5 +71,5 @@ |2: /tmp/pardes-snap/layout-close/cwd /tmp/pardes-snap/layout-close/cwd Tty+bash Save Mode Filter Collapse |3: Tty+bash Save Mode Filter Collap Del |4: se Del ls -|5: marker.txt marker.txt -|6: +|5: ls marker.txt +|6: marker.txt diff --git a/test/snapshots/tag.snap b/test/snapshots/tag.snap index 4faf6062..133a041d 100644 --- a/test/snapshots/tag.snap +++ b/test/snapshots/tag.snap @@ -1,5 +1,5 @@ -# a CLICKED tag is typed straight into (no 'i'; `:` is the normal-mode door, -# see tagcmd); backspace edits; Esc drops to the tag's normal mode, which is +# 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. @@ -10,13 +10,13 @@ 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, so the evidence for "this click went to -# insert" is the next step — the typed text lands as text instead of running as -# normal-mode commands. +# 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 @@ -43,8 +43,6 @@ snap tag-exit press left @t.txt 3 release left @t.txt 3 stable 400 5000 -key esc -settle 100 key enter wait 10000 ZZLOOKED stable 700 15000 diff --git a/test/snapshots/tagbottom.snap b/test/snapshots/tagbottom.snap index 68b79fc7..7ce0ae5a 100644 --- a/test/snapshots/tagbottom.snap +++ b/test/snapshots/tagbottom.snap @@ -48,6 +48,7 @@ stable 700 15000 press left 90 31 release left 90 31 stable 400 5000 +key i send \x20bottom.txt stable 600 8000 stable 400 5000 diff --git a/test/snapshots/tagnav.snap b/test/snapshots/tagnav.snap index cd83dbd9..ef202a08 100644 --- a/test/snapshots/tagnav.snap +++ b/test/snapshots/tagnav.snap @@ -72,8 +72,6 @@ press left @Mode 3 release left @Mode 3 stable 400 5000 snap tty-tag -key esc -settle 100 key : stable 400 5000 snap tty-restored diff --git a/test/snapshots/theme.snap b/test/snapshots/theme.snap index 2a046ef3..780744d8 100644 --- a/test/snapshots/theme.snap +++ b/test/snapshots/theme.snap @@ -8,6 +8,7 @@ stable 700 20000 # NextColor is no default word of the workspace tag: typed onto its end press left 99 1 release left 99 1 +key i key space text NextColor key esc diff --git a/test/snapshots/ttyclick.snap b/test/snapshots/ttyclick.snap index c125a231..65b6f9fc 100644 --- a/test/snapshots/ttyclick.snap +++ b/test/snapshots/ttyclick.snap @@ -16,14 +16,12 @@ release left 10 5 stable 400 5000 snap tty-bodyclick # tag edit from tty: the box still reads `$` while the tag is typed into (the -# tag's mode is its own), and Esc then `:` hands the keyboard back — a bug +# tag's mode is its own: a clicked tag is in normal mode), and `:` hands the keyboard back — a bug # that lost the body's mode would show `•` in one snap or the other press left @Tty 3 release left @Tty 3 stable 400 5000 snap tty-tagedit -key esc -settle 100 key : stable 400 5000 snap tty-tagexit |
