summaryrefslogtreecommitdiff
path: root/src/look.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/look.zig')
-rw-r--r--src/look.zig69
1 files changed, 3 insertions, 66 deletions
diff --git a/src/look.zig b/src/look.zig
index 634310f1..0574985b 100644
--- a/src/look.zig
+++ b/src/look.zig
@@ -8,7 +8,6 @@ const pdf_enabled = @import("pardes_config").mupdf;
const diff = @import("diff.zig");
const platform_has_fs = filesystem.platform_has_fs;
const layout = @import("layout.zig");
-const animation = @import("animation.zig");
const modal = @import("modal.zig");
const tagline = @import("tagline.zig");
const filesystem = @import("fs.zig");
@@ -937,8 +936,7 @@ fn noteLookHover(p: *Pardes, col: u16, row: u16, body_hit: ?Mouse.BodyHit, tag_h
pub fn refreshLookHoverFromRaw(p: *Pardes) void {
if (!p.pointer_inside or !p.raw_hover_intent) return;
- const mapped = p.pointerCell(p.pointer_raw_col, p.pointer_raw_row) orelse
- return cancelLookHover(p);
+ const mapped: struct { col: u16, row: u16 } = .{ .col = p.pointer_raw_col, .row = p.pointer_raw_row };
p.hover_col = mapped.col;
p.hover_row = mapped.row;
const body_hit: ?Mouse.BodyHit = if (p.pointer_body_hit) |mapped_hit|
@@ -2009,7 +2007,7 @@ test "Look hover waits without mutating the pane and input cancels it" {
try std.testing.expect(p.look_hover_preview == null);
// The following host repaint must not resurrect a hover after keyboard
// input cancelled its raw-pointer intent.
- p.acknowledgePanelPresentation(&.{});
+ p.presented();
try std.testing.expect(p.look_hover_wait == null);
}
@@ -2037,67 +2035,6 @@ test "cwd changes cancel only the affected pane's Look hover" {
try std.testing.expect(p.look_hover_preview == null);
}
-test "stationary Look hover follows only acknowledged panel samples" {
- const p = try Pardes.init(std.testing.allocator, .{ .cols = 120, .rows = 20, .tty_only = true });
- defer p.deinit();
- const pane = p.panes[0].?;
- const rect = p.rects[0];
- const target: animation.Box = .{
- .x = @floatFromInt(rect.x),
- .y = @floatFromInt(rect.y),
- .w = @floatFromInt(rect.w),
- .h = @floatFromInt(rect.h),
- };
- var track: animation.Track = .{
- .serial = pane.serial,
- .pane = 0,
- .phase = .moving,
- .effect = .slide,
- .from = .{ .x = 20, .y = 5, .w = 40, .h = 10 },
- .to = target,
- };
- p.acknowledgePanelPresentation(&.{track});
- p.update(.{ .mouse = .{ .button = .none, .kind = .motion, .col = 30, .row = 8 } });
- const first = p.look_hover_wait orelse return error.MissingInitialHoverWait;
-
- // Advancing the producer-side track alone cannot move the semantic cell
- // under a stationary pointer.
- track.frame = track.effect.frames() - 1;
- p.presentation.tracks[0] = track;
- refreshLookHoverFromRaw(p);
- try std.testing.expectEqual(first, p.look_hover_wait.?);
-
- // Once that exact sample is acknowledged, the same raw cell maps through
- // the new panel rectangle and the debounce starts over for the new target.
- p.acknowledgePanelPresentation(&.{track});
- const moved = p.look_hover_wait orelse return error.MissingRemappedHoverWait;
- try std.testing.expect(first.col != moved.col or first.row != moved.row);
- try std.testing.expectEqual(@as(u16, 0), moved.frames);
-
- // Re-acknowledging the same semantic target is host repaint noise, not a
- // new hover, so it preserves the accumulated delay.
- p.look_hover_wait.?.frames = 3;
- p.acknowledgePanelPresentation(&.{track});
- try std.testing.expectEqual(@as(u16, 3), p.look_hover_wait.?.frames);
-
- // A zero-sized opening sample covers its future target but exposes no
- // clickable content. Successful presentation therefore cancels the hover.
- track.phase = .opening;
- track.effect = .zoom;
- track.frame = 0;
- track.from = .{
- .x = target.x + target.w * 0.5,
- .y = target.y + target.h * 0.5,
- };
- p.acknowledgePanelPresentation(&.{track});
- try std.testing.expect(p.look_hover_wait == null);
- try std.testing.expect(p.look_hover_preview == null);
-
- track.frame = track.effect.frames() - 1;
- p.acknowledgePanelPresentation(&.{track});
- try std.testing.expect(p.look_hover_wait != null);
-}
-
test "Look copies its operand before releasing pointer selection storage" {
const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 12 });
defer p.deinit();
@@ -2153,7 +2090,7 @@ test "a pointer resting where a look-hover found nothing does not wake the core
while (p.nextWake() != null and frames < 20) : (frames += 1) {
p.update(.tick);
// What a shell's present does after every frame.
- p.acknowledgePanelPresentation(&.{});
+ p.presented();
}
try std.testing.expect(frames < 20);
try std.testing.expect(p.look_hover_wait == null and p.look_hover_preview == null);