diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-28 10:05:40 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:14 -0300 |
| commit | 6dfe81c92ee532eb9e804dfda2fa05cc36515aa1 (patch) | |
| tree | fe0d491d98862f9cd48fd8383759ee5799272dfe /src | |
| parent | c44894f53decbacc68c0e4e9d1118fc082bc63a0 (diff) | |
| download | pardes-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]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/exec.zig | 23 |
1 files changed, 23 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")); +} |
