summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/Term.zig2
-rw-r--r--core/mouse.zig43
2 files changed, 42 insertions, 3 deletions
diff --git a/core/Term.zig b/core/Term.zig
index 6415b199..a137267d 100644
--- a/core/Term.zig
+++ b/core/Term.zig
@@ -448,7 +448,7 @@ pub const calls = [_]struct { []const u8, []const u8, []const u8 }{
.{ "scrollbackLen", "ninep/ctl.zig:1 ninep/pane.zig:1", "READ, NOT COVERED: the history's text's length (its row count is in the digest)" },
.{ "commandOutput", "ninep/pty.zig:1", "READ, NOT COVERED: a command's output rows (a 9P pty/run): taped as the session's answer" },
.{ "textRows", "edit.zig:2", "READ, NOT COVERED: every row's text, the history's among them (a selection, a Look over a shell)" },
- .{ "link", "exec.zig:1", "READ, NOT COVERED: the URI of a link (OSC 8) a Look over a shell takes, as its text (`textRows`)" },
+ .{ "link", "exec.zig:1 mouse.zig:1", "READ, NOT COVERED: the URI of a link (OSC 8) a Look over a shell takes, as its text (`textRows`); mouse.zig: whether a move under 1003 is over one (pardes hovers it)" },
.{ "viewport", "body_layer.zig:1 replica.zig:1", "READ: the rows' text a view's place (in the digest, with its pane) shows (body_layer.zig: a draw's; replica.zig: a test's)" },
.{ "editRows", "ansi.zig:1 panes.zig:1", "READ: rows' text for a draw; a command's last rows read for the places its report names when it fails (panes.zig commandDone): in the digest as the emulator's rows are" },
// ---- local ----
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);
+}