From 95dbd10e51797283c13e47a01201898bf4174463 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 18:35:03 -0300 Subject: A link (OSC 8) under the pointer lights up even in a program that takes every mouse move (1003, codex's fullscreen), as a Look hover does anywhere, so the label shows what B3 will open: the user's report of 2026-11-27 ("could we see like if it would do a look"); THE CAUSE: under 1003 every move was the program's (programMouse returned true) and pardes never hovered, while B3 on the label already looked at its URI; THE CHANGE: programMouse's motion under 1003 still goes to the program, and when its cell holds a link (Term.link) pardes hovers too; off a link the hover pardes showed in that pane goes (look.invalidateLookHover); a plain word there stays the program's, as before; core/Term.zig's S1 row for `link`: exec.zig:1 mouse.zig:1; RUN (TEST FIRST): mouse.zig "under any-event tracking (1003) a move over a link (OSC 8) is pardes's hover too ..." (codex's modes 1000/1002/1003/1006, `see ` and a link labelled `the docs`): the move over it reaches the program (`\e[<35;7;1M`) and the preview covers cells 4..11; off it the program's move alone and no hover; fails with the old rule (NoHoverOverTheLink), passes now; REAL CHECK (.scratch/kp/link_e2e.py MOUSE=1003, pardes --tty in a pty): before, the label's cells unchanged under the pointer; GATES (Debug tui): core-test 1166/1346 (180 skipped), shell-test 1395/1398 (3 skipped), term-test 17/17, kitty-test 45/45, process-test rc 0, behaviour-test 293/293 --- core/mouse.zig | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'core/mouse.zig') diff --git a/core/mouse.zig b/core/mouse.zig index dc730923..f628bbc3 100644 --- a/core/mouse.zig +++ b/core/mouse.zig @@ -337,8 +337,13 @@ fn programMouse(p: *Pardes, m: Mouse) bool { const bytes = panes.Term.mouse(pane.terminal.?, &pane.term_mouse, &buf, .motion, null, mods, cell.col, cell.row, false); if (bytes.len > 0) p.emitWrite(id, bytes); // Under 1003 the move is the program's; below that pardes - // hovers as ever. - return panes.Term.modes(pane.terminal).all_motion; + // hovers as ever. A link (OSC 8) is pardes's under any mode + // (B3 looks at its URI): over one pardes hovers too, so its + // label shows what a look takes; off it, the hover goes. + if (!panes.Term.modes(pane.terminal).all_motion) return false; + if (panes.Term.link(pane.terminal.?, @as(i32, @intCast(pane.termTop())) + cell.row, @intCast(cell.col), false) != null) return false; + look.invalidateLookHover(p, id); + return true; }, } } @@ -2299,3 +2304,37 @@ test "the act step and the rows under the mouse (UX DESIGN O2): B2 on an act's w try std.testing.expect(pardes.Pick.live(p) == pk); try std.testing.expect(std.mem.endsWith(u8, p.registers.text(p.gpa, pardes.Registers.default).?, "one.zig:2\n")); } + +test "under any-event tracking (1003) a move over a link (OSC 8) is pardes's hover too, so its label shows what B3 looks at; off it the hover goes, every move the program's" { + if (pardes.Term.ops == null) return error.SkipZigTest; // a shell + const gpa = std.testing.allocator; + const p = try Pardes.init(gpa, .{ .cols = 60, .rows = 16, .tty_only = true }); + defer p.deinit(); + var frame = std.heap.ArenaAllocator.init(gpa); + defer frame.deinit(); + _ = try p.render(frame.allocator()); + var out: [4096]u8 = undefined; + const pane = p.panes[0].?; + try std.testing.expectEqual(.tty, pane.body.mode); + // codex's modes, then `see ` and a link labelled `the docs` on the grid's first row. + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[?1000h\x1b[?1002h\x1b[?1003h\x1b[?1006hsee \x1b]8;;https://ziglang.org\x1b\\the docs\x1b]8;;\x1b\\ here" } }); + _ = pardes.test_api.ptyBytes(p, 0, &out); + const r = p.view().rects[0]; + const x0 = r.x + config.GUTTER; + const y = p.bodyTop(pane, r); + const hoverAt = struct { + fn f(pp: *Pardes, o: []u8, c: u16, rw: u16) ![]const u8 { + pp.update(.{ .mouse = .{ .button = .none, .kind = .motion, .col = c, .row = rw } }); + const heard = pardes.test_api.ptyBytes(pp, 0, o); + for (0..config.look_preview_delay_frames) |_| pp.update(.tick); + return heard; + } + }.f; + try std.testing.expectEqualStrings("\x1b[<35;7;1M", try hoverAt(p, &out, x0 + 6, y)); + const shown = (p.look_hover_preview orelse return error.NoHoverOverTheLink).sel.?; + try std.testing.expectEqual(@as(i32, 4), shown.c0); + try std.testing.expectEqual(@as(i32, 11), shown.c1); + // Off it: the program's move alone, pardes's hover gone, none started. + try std.testing.expectEqualStrings("\x1b[<35;2;1M", try hoverAt(p, &out, x0 + 1, y)); + try std.testing.expect(p.look_hover_preview == null and p.look_hover_wait == null); +} -- cgit v1.3