diff --git a/src/Surface.zig b/src/Surface.zig index ee5180f657..5e47bf0d35 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -3497,7 +3497,6 @@ pub fn cursorPosCallback( // Only send a message when outside the viewport and // selection scrolling is not currently active. if ((pos.y <= 1 or pos.y > max_y - 1) and !self.io_thread.scroll_active) { - // TODO: the selection region ideally should keep up with this self.io.queueMessage(.{ .selection_scroll = true }, .locked); } @@ -3593,7 +3592,7 @@ fn dragLeftClickTriple( try self.setSelection(sel); } -fn dragLeftClickSingle( +pub fn dragLeftClickSingle( self: *Surface, drag_pin: terminal.Pin, xpos: f64, diff --git a/src/termio/Thread.zig b/src/termio/Thread.zig index fa21c6f9a5..e036cd33a1 100644 --- a/src/termio/Thread.zig +++ b/src/termio/Thread.zig @@ -470,10 +470,27 @@ fn selectionScrollCallback( const cb = cb_ orelse return .disarm; const surface = cb.io.surface_mailbox.surface; const pos = try surface.rt_surface.getCursorPos(); + const pos_vp = surface.posToViewport(pos.x, pos.y); + const screen = &cb.io.renderer_state.terminal.screen; const delta: isize = if (pos.y < 0) -1 else 1; try cb.io.terminal.scrollViewport(.{ .delta = delta }); + // Always the case, but doesn't hurt to check + if (surface.mouse.left_click_count == 1) { + const pin = screen.pages.pin(.{ + .viewport = .{ + .x = pos_vp.x, + .y = pos_vp.y, + }, + }) orelse { + if (comptime std.debug.runtime_safety) unreachable; + return .rearm; + }; + + surface.dragLeftClickSingle(pin, pos.x) catch {}; + } + // Notify the renderer that it should repaint immediately after scrolling cb.io.renderer_wakeup.notify() catch {};