summaryrefslogtreecommitdiff
path: root/test/behaviour
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-04 10:56:51 -0300
committerGabriel Schneider <[email protected]>2026-11-04 10:59:26 -0300
commit5752e5c94f27eced137f4ca061c68715d8b7131a (patch)
treeffc1785740fb008e2ebb10053a2aaaaa25b82fd6 /test/behaviour
parent54f3ce0443f46f0bfe7565d6a31fb906beadf3b9 (diff)
downloadpardes-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/behaviour')
-rw-r--r--test/behaviour/columns_and_tags.zig8
-rw-r--r--test/behaviour/keys.zig3
-rw-r--r--test/behaviour/modes.zig5
-rw-r--r--test/behaviour/tags.zig26
4 files changed, 31 insertions, 11 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");
+}