From e018059a5dab2b2002685a49e2516c9b912873c2 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 11 Mar 2024 21:22:47 -0700 Subject: [PATCH] core: re-enable click to move cursor --- src/Surface.zig | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/Surface.zig b/src/Surface.zig index aaae855c1..aed6ea84f 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -2247,14 +2247,13 @@ pub fn mouseButtonCallback( } // For left button click release we check if we are moving our cursor. - if (button == .left and action == .release and mods.alt) { + if (button == .left and action == .release and mods.alt) click_move: { // Moving always resets the click count so that we don't highlight. self.mouse.left_click_count = 0; - - // TODO(paged-terminal) - // self.renderer_state.mutex.lock(); - // defer self.renderer_state.mutex.unlock(); - // try self.clickMoveCursor(self.mouse.left_click_point); + const pin = self.mouse.left_click_pin orelse break :click_move; + self.renderer_state.mutex.lock(); + defer self.renderer_state.mutex.unlock(); + try self.clickMoveCursor(pin.*); return; } @@ -2388,7 +2387,7 @@ pub fn mouseButtonCallback( /// Performs the "click-to-move" logic to move the cursor to the given /// screen point if possible. This works by converting the path to the /// given point into a series of arrow key inputs. -fn clickMoveCursor(self: *Surface, to: terminal.point.ScreenPoint) !void { +fn clickMoveCursor(self: *Surface, to: terminal.Pin) !void { // If click-to-move is disabled then we're done. if (!self.config.cursor_click_to_move) return; @@ -2405,10 +2404,7 @@ fn clickMoveCursor(self: *Surface, to: terminal.point.ScreenPoint) !void { if (!t.flags.shell_redraws_prompt) return; // Get our path - const from = (terminal.point.Viewport{ - .x = t.screen.cursor.x, - .y = t.screen.cursor.y, - }).toScreen(&t.screen); + const from = t.screen.cursor.page_pin.*; const path = t.screen.promptPath(from, to); log.debug("click-to-move-cursor from={} to={} path={}", .{ from, to, path });