core: drag triple click

This commit is contained in:
Mitchell Hashimoto
2024-03-10 21:05:03 -07:00
parent 4d0f210025
commit edc0864f32

View File

@ -2641,8 +2641,8 @@ pub fn cursorPosCallback(
switch (self.mouse.left_click_count) { switch (self.mouse.left_click_count) {
1 => try self.dragLeftClickSingle(pin, pos.x), 1 => try self.dragLeftClickSingle(pin, pos.x),
2 => try self.dragLeftClickDouble(pin), 2 => try self.dragLeftClickDouble(pin),
// 3 => self.dragLeftClickTriple(screen_point), 3 => try self.dragLeftClickTriple(pin),
// 0 => unreachable, // handled above 0 => unreachable, // handled above
else => unreachable, else => unreachable,
} }
@ -2720,26 +2720,29 @@ fn dragLeftClickDouble(
/// Triple-click dragging moves the selection one "line" at a time. /// Triple-click dragging moves the selection one "line" at a time.
fn dragLeftClickTriple( fn dragLeftClickTriple(
self: *Surface, self: *Surface,
screen_point: terminal.point.ScreenPoint, drag_pin: terminal.Pin,
) void { ) !void {
const screen = &self.io.terminal.screen;
const click_pin = self.mouse.left_click_pin.?.*;
// Get the word under our current point. If there isn't a word, do nothing. // Get the word under our current point. If there isn't a word, do nothing.
const word = self.io.terminal.screen.selectLine(screen_point) orelse return; const word = screen.selectLine(drag_pin) orelse return;
// Get our selection to grow it. If we don't have a selection, start it now. // Get our selection to grow it. If we don't have a selection, start it now.
// We may not have a selection if we started our dbl-click in an area // We may not have a selection if we started our dbl-click in an area
// that had no data, then we dragged our mouse into an area with data. // that had no data, then we dragged our mouse into an area with data.
var sel = self.io.terminal.screen.selectLine(self.mouse.left_click_point) orelse { var sel = screen.selectLine(click_pin) orelse {
self.setSelection(word); try self.setSelection(word);
return; return;
}; };
// Grow our selection // Grow our selection
if (screen_point.before(self.mouse.left_click_point)) { if (drag_pin.before(click_pin)) {
sel.start = word.start; sel.startPtr().* = word.start();
} else { } else {
sel.end = word.end; sel.endPtr().* = word.end();
} }
self.setSelection(sel); try self.setSelection(sel);
} }
fn dragLeftClickSingle( fn dragLeftClickSingle(