summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-24 22:55:09 -0300
committerGabriel Schneider <[email protected]>2026-11-24 22:58:47 -0300
commit226d8a7635959644a2bafc3d621648c7a5aca2ad (patch)
tree32bcf7eb3854763ab42c4a666f20b04fcdb8db6e
parent7018de2abcf585e26024952cc0b4c97d25b3dc27 (diff)
parentd266ff2b816163ec9d09ec7ab79955b8fce719b0 (diff)
downloadpardes-226d8a7635959644a2bafc3d621648c7a5aca2ad.tar.gz
pardes-226d8a7635959644a2bafc3d621648c7a5aca2ad.zip
walk UI M2: A2's final tip rqntnxpr merged in (ztzvvwkk: B's ozlumvqo dump.zig hunks, already here, and the fuzz session in Help; rqntnxpr: a click that gives the keyboard to another pane ends a level as Esc does): core/fuzz.zig's one conflict is both sessions' setup kept, B's reader walk and then A2's tag out of rest; tui core-test 1034/1203 (169 skipped, 0 failed)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
-rw-r--r--core/TagState.zig42
-rw-r--r--core/fuzz.zig4
-rw-r--r--core/mouse.zig11
3 files changed, 57 insertions, 0 deletions
diff --git a/core/TagState.zig b/core/TagState.zig
index 49c7a3ed..e4053f51 100644
--- a/core/TagState.zig
+++ b/core/TagState.zig
@@ -943,3 +943,45 @@ test "a dump's tag state that indexes past what it names is at rest when loaded,
loaded(p);
try std.testing.expect(s.kind == .rest);
}
+
+test "a click that gives the keyboard to another pane ends a level as Esc does; one in the level's own tag keeps it" {
+ const config = @import("config.zig");
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 40 });
+ defer p.deinit();
+ _ = try p.setTestFile("one\ntwo\n");
+ const top = p.view().active;
+ p.newScratchBelow(top);
+ const low = p.view().active;
+ try std.testing.expect(low != top);
+ const click = struct {
+ fn at(q: *Pardes, col: u16, row: u16) void {
+ q.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = col, .row = row } });
+ q.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = col, .row = row } });
+ }
+ }.at;
+ const rt = p.view().rects[top];
+ const rl = p.view().rects[low];
+ // SPC's level in the lower pane's tag; a click in its own tag keeps it.
+ p.update(.{ .key = .{ .cp = ' ' } });
+ try std.testing.expect(hostOf(p) == low);
+ click(p, rl.x + config.GUTTER + 2, rl.y);
+ try std.testing.expect(hostOf(p) == low and p.view().prefix == .leader);
+ // A click in the other pane's body: the keyboard goes there, the level
+ // ends, nothing out of rest.
+ click(p, rt.x + config.GUTTER + 1, rt.y + pardes.BOX_H);
+ try std.testing.expectEqual(top, p.view().active);
+ try std.testing.expect(hostOf(p) == null and p.view().prefix == .none and p.view().tag_state.root == null);
+ // A helix prefix's level (g, shown after its delay) the same, its text's
+ // prefix gone with it; Help, a typing state, the same.
+ p.update(.{ .key = .{ .cp = 'g' } });
+ p.advance(p.clock.now_ns);
+ p.clock.now_ns = p.view().tag_state.due_ns;
+ try std.testing.expect(hostOf(p) == top);
+ click(p, rl.x + config.GUTTER + 1, rl.y + pardes.BOX_H);
+ try std.testing.expectEqual(low, p.view().active);
+ try std.testing.expect(hostOf(p) == null and p.panes[top].?.body.normal.prefix == null);
+ for (" ?") |c| p.update(.{ .key = .{ .cp = c } });
+ try std.testing.expect(p.view().tag_state.kind == .help);
+ click(p, rt.x + config.GUTTER + 1, rt.y + pardes.BOX_H);
+ try std.testing.expect(p.view().tag_state.kind == .rest and hostOf(p) == null);
+}
diff --git a/core/fuzz.zig b/core/fuzz.zig
index c68c7810..e0d77bd2 100644
--- a/core/fuzz.zig
+++ b/core/fuzz.zig
@@ -779,6 +779,10 @@ test "a dump and an image cut, flipped and grown: refused or loaded, never a pan
defer p.deinit();
// A reader's walk in it: a union, a fixed array held to its length.
p.panes[0].?.trail = pardes.Trail.reader(7, "/x/rank.zig", .{ .line = 3, .col = 2 });
+ // A view's tag out of rest in it (View.tag_state): SPC t w remembered
+ // (a group's last leaf), then Help typed into (a scope, a field, hits).
+ for (" tw ?hel") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } });
+ try testing.expect(p.view().tag_state.kind == .help and p.view().tag_state.nhits > 0);
// The byte dump a join streams, and the image a Dump keeps.
const bytes = try pardes.dump.byteDump(p);
defer gpa.free(bytes);
diff --git a/core/mouse.zig b/core/mouse.zig
index b6e99300..feb5ac08 100644
--- a/core/mouse.zig
+++ b/core/mouse.zig
@@ -499,6 +499,17 @@ fn chordCutPaste(p: *Pardes, cut: bool) edit.Error!void {
pub fn handleMouse(p: *Pardes, event: Mouse) void {
const v = p.view();
+ // A click that gives the keyboard to another pane ends the level or
+ // typing state of the tag out of rest as Esc does, its text's prefix
+ // with it (SPEC ยง3.4.6: only the pane with the keyboard leaves rest);
+ // one in its band or its own tag keeps it.
+ const host = pardes.TagState.hostOf(p);
+ defer if (host) |was| if (v.active != was) {
+ const to = v.active;
+ v.active = was;
+ pardes.TagState.toRest(p);
+ v.active = to;
+ };
var m = event;
// A click goes somewhere else: the question it leaves unanswered is
// taken back, and the pane stays. A wheel only looks around.