summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-28 10:05:40 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:14 -0300
commit6dfe81c92ee532eb9e804dfda2fa05cc36515aa1 (patch)
treefe0d491d98862f9cd48fd8383759ee5799272dfe
parentc44894f53decbacc68c0e4e9d1118fc082bc63a0 (diff)
downloadpardes-6dfe81c92ee532eb9e804dfda2fa05cc36515aa1.tar.gz
pardes-6dfe81c92ee532eb9e804dfda2fa05cc36515aa1.zip
A switch setting clicked with a selection held flips again, unless the selection is on or off
Giving panel and scene effects on/off made every switch a word that takes an argument, so a middle click on Verbose or PanelSlide with other text selected passed that text as its value and failed. The click path now passes a held selection to a switch only when it says on or off, and the word flips as it did bare; a ctl write is still checked strictly. The topbarexec golden had been recorded with that failure (Debug clicked with a sweep opening nothing, the very thing the script says it guards); it now shows the overlay again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
-rw-r--r--src/exec.zig23
-rw-r--r--test/snapshots/topbarexec.golden19
2 files changed, 42 insertions, 0 deletions
diff --git a/src/exec.zig b/src/exec.zig
index a0e3d47f..46b4f57b 100644
--- a/src/exec.zig
+++ b/src/exec.zig
@@ -210,10 +210,18 @@ pub fn heldSelection(p: *Pardes, first: usize) ?[]const u8 {
return null;
}
+/// A clicked word and the selection held for it, as one command line.
pub fn withArg(p: *Pardes, txt: []const u8, arg: ?[]const u8) []const u8 {
const a = std.mem.trim(u8, arg orelse return txt, " \t\r\n");
if (a.len == 0) return txt;
const t = std.mem.trim(u8, txt, " \t\r\n");
+ // A switch (Verbose, PanelSlide, Crt) clicked with some other text
+ // selected flips, as it does bare: only `on` or `off` is an argument
+ // for it. What a ctl write gives it is checked strictly instead.
+ if (config.Runtime.find(commandText(t))) |setting| switch (setting.action) {
+ .toggle, .transition, .scene => if (!std.mem.eql(u8, a, "on") and !std.mem.eql(u8, a, "off")) return txt,
+ else => {},
+ };
return std.fmt.allocPrint(p.scratch.allocator(), "{s} {s}", .{ t, a }) catch txt;
}
@@ -567,3 +575,18 @@ test "the acme chords act once per selection, not once on the primary" {
// ...and the chord consumed the selection exactly as it does with one.
try std.testing.expectEqual(@as(u8, 0), p.panes[0].?.body.nsel);
}
+
+test "a switch clicked with a selection held flips unless the selection says on or off" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 });
+ defer p.deinit();
+ while (p.nextEffect()) |_| {}
+ const before = p.settings.verbose;
+ _ = execute(p, p.active, withArg(p, "Verbose", "some selected text"));
+ try std.testing.expectEqual(!before, p.settings.verbose);
+ _ = execute(p, p.active, withArg(p, "Verbose", "on"));
+ try std.testing.expect(p.settings.verbose);
+ _ = execute(p, p.active, withArg(p, "Verbose", " off\n"));
+ try std.testing.expect(!p.settings.verbose);
+ // A word that takes any argument still gets the selection.
+ try std.testing.expectEqualStrings("Msg some text", withArg(p, "Msg", "some text"));
+}
diff --git a/test/snapshots/topbarexec.golden b/test/snapshots/topbarexec.golden
index d70652a9..4218825b 100644
--- a/test/snapshots/topbarexec.golden
+++ b/test/snapshots/topbarexec.golden
@@ -15,6 +15,25 @@
| ls
| zmarkfile.txt
== snap noarg-runs grid=90x21 cursor=14,4
+|1: New Tty Find Grep Joincol Delcol New ╭────────────────────────────────────╮
+|2: /tmp/pardes-snap/topbarexec/cwd Tty Save M /tmp│pardes resizes=1 │
+|3: ls ls │theme orchard │
+|4: zmarkfile.txt zmark│font default │
+|5: │terms 3 cols 2 │
+|6: │active #0 43x9 │
+|7: │scroll 0/9 │
+|8: │pinch 1.0000 │
+|9: │tscroll 0.0000 │
+|10: ╰────────────────────────────────────╯
== snap arg-still-spliced grid=90x21 cursor=14,4
+|1: New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol
+|2: /tmp/pardes-snap/topbarexec/cwd Tty Save M /tmp/pardes-snap/topbarexec/cwd Tty Save M
+|3: ls ls
+|4: zmarkfile.txt zmarkfile.txt
+|5:
+|6:
+|7:
+|8:
+|9:
|10: /tmp/pardes-snap/topbarexec/cwd/+Search Sa
|11: 1 zmarkfile.txt