core: re-enable click to move cursor

This commit is contained in:
Mitchell Hashimoto
2024-03-11 21:22:47 -07:00
parent 37251dca95
commit e018059a5d

View File

@ -2247,14 +2247,13 @@ pub fn mouseButtonCallback(
} }
// For left button click release we check if we are moving our cursor. // 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. // Moving always resets the click count so that we don't highlight.
self.mouse.left_click_count = 0; self.mouse.left_click_count = 0;
const pin = self.mouse.left_click_pin orelse break :click_move;
// TODO(paged-terminal) self.renderer_state.mutex.lock();
// self.renderer_state.mutex.lock(); defer self.renderer_state.mutex.unlock();
// defer self.renderer_state.mutex.unlock(); try self.clickMoveCursor(pin.*);
// try self.clickMoveCursor(self.mouse.left_click_point);
return; return;
} }
@ -2388,7 +2387,7 @@ pub fn mouseButtonCallback(
/// Performs the "click-to-move" logic to move the cursor to the given /// 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 /// screen point if possible. This works by converting the path to the
/// given point into a series of arrow key inputs. /// 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 click-to-move is disabled then we're done.
if (!self.config.cursor_click_to_move) return; 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; if (!t.flags.shell_redraws_prompt) return;
// Get our path // Get our path
const from = (terminal.point.Viewport{ const from = t.screen.cursor.page_pin.*;
.x = t.screen.cursor.x,
.y = t.screen.cursor.y,
}).toScreen(&t.screen);
const path = t.screen.promptPath(from, to); const path = t.screen.promptPath(from, to);
log.debug("click-to-move-cursor from={} to={} path={}", .{ from, to, path }); log.debug("click-to-move-cursor from={} to={} path={}", .{ from, to, path });