Rearranged things to make a bit more sense.

This commit is contained in:
Adam Harrison 2021-10-05 22:07:23 -04:00
parent 7905ddd26f
commit 6bdcfc824d
4 changed files with 18 additions and 12 deletions

View File

@ -392,12 +392,27 @@ local commands = {
["doc:select-to-cursor"] = function(x, y, clicks)
local line1, col1 = select(3, doc():get_selection())
local line2, col2 = dv():resolve_screen_position(x, y)
dv().mouse_selecting = { line1, col1 }
doc():set_selection(line2, col2, line1, col1)
end,
["doc:set-cursor"] = function(x, y, clicks)
local line, col = dv():resolve_screen_position(x, y)
doc():set_selection(line, col, line, col)
dv().mouse_selecting = { line, col }
core.blink_reset()
end,
["doc:set-cursor-word"] = function(x, y, clicks)
local line, col = dv():resolve_screen_position(x, y)
command.perform("doc:select-word")
dv().mouse_selecting = { line, col }
end,
["doc:set-cursor-line"] = function(x, y, clicks)
local line, col = dv():resolve_screen_position(x, y)
command.perform("doc:select-lines")
dv().mouse_selecting = { line, col }
end,
["doc:split-cursor"] = function(x, y, clicks)

View File

@ -224,15 +224,6 @@ function DocView:scroll_to_make_visible(line, col)
end
end
function DocView:on_mouse_pressed(button, x, y, clicks)
local line, col = self:resolve_screen_position(x, y)
self.mouse_selecting = { line, col, clicks = clicks }
if DocView.super.on_mouse_pressed(self, button, x, y, clicks) then
return
end
core.blink_reset()
end
function DocView:on_mouse_moved(x, y, ...)
DocView.super.on_mouse_moved(self, x, y, ...)
@ -245,7 +236,6 @@ function DocView:on_mouse_moved(x, y, ...)
if self.mouse_selecting then
local l1, c1 = self:resolve_screen_position(x, y)
local l2, c2 = table.unpack(self.mouse_selecting)
local clicks = self.mouse_selecting.clicks
if keymap.modkeys["ctrl"] then
if l1 > l2 then l1, l2 = l2, l1 end
self.doc.selections = { }

View File

@ -200,8 +200,8 @@ keymap.add_direct {
["shift+lclick"] = "doc:select-to-cursor",
["ctrl+lclick"] = "doc:split-cursor",
["lclick"] = "doc:set-cursor",
["dlclick"] = "doc:select-word",
["tlclick"] = "doc:select-lines",
["dlclick"] = "doc:set-cursor-word",
["tlclick"] = "doc:set-cursor-line",
["shift+left"] = "doc:select-to-previous-char",
["shift+right"] = "doc:select-to-next-char",
["shift+up"] = "doc:select-to-previous-line",

View File

@ -874,6 +874,7 @@ function RootView:on_mouse_pressed(button, x, y, clicks)
self.dragged_node = { node = node, idx = idx, dragging = false, drag_start_x = x, drag_start_y = y}
end
node:set_active_view(node.views[idx])
return true
end
elseif not self.dragged_node then -- avoid sending on_mouse_pressed events when dragging tabs
core.set_active_view(node.active_view)