Rearranged things to make a bit more sense.
This commit is contained in:
parent
7905ddd26f
commit
6bdcfc824d
|
@ -392,12 +392,27 @@ local commands = {
|
||||||
["doc:select-to-cursor"] = function(x, y, clicks)
|
["doc:select-to-cursor"] = function(x, y, clicks)
|
||||||
local line1, col1 = select(3, doc():get_selection())
|
local line1, col1 = select(3, doc():get_selection())
|
||||||
local line2, col2 = dv():resolve_screen_position(x, y)
|
local line2, col2 = dv():resolve_screen_position(x, y)
|
||||||
|
dv().mouse_selecting = { line1, col1 }
|
||||||
doc():set_selection(line2, col2, line1, col1)
|
doc():set_selection(line2, col2, line1, col1)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
["doc:set-cursor"] = function(x, y, clicks)
|
["doc:set-cursor"] = function(x, y, clicks)
|
||||||
local line, col = dv():resolve_screen_position(x, y)
|
local line, col = dv():resolve_screen_position(x, y)
|
||||||
doc():set_selection(line, col, line, col)
|
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,
|
end,
|
||||||
|
|
||||||
["doc:split-cursor"] = function(x, y, clicks)
|
["doc:split-cursor"] = function(x, y, clicks)
|
||||||
|
|
|
@ -224,15 +224,6 @@ function DocView:scroll_to_make_visible(line, col)
|
||||||
end
|
end
|
||||||
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, ...)
|
function DocView:on_mouse_moved(x, y, ...)
|
||||||
DocView.super.on_mouse_moved(self, 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
|
if self.mouse_selecting then
|
||||||
local l1, c1 = self:resolve_screen_position(x, y)
|
local l1, c1 = self:resolve_screen_position(x, y)
|
||||||
local l2, c2 = table.unpack(self.mouse_selecting)
|
local l2, c2 = table.unpack(self.mouse_selecting)
|
||||||
local clicks = self.mouse_selecting.clicks
|
|
||||||
if keymap.modkeys["ctrl"] then
|
if keymap.modkeys["ctrl"] then
|
||||||
if l1 > l2 then l1, l2 = l2, l1 end
|
if l1 > l2 then l1, l2 = l2, l1 end
|
||||||
self.doc.selections = { }
|
self.doc.selections = { }
|
||||||
|
|
|
@ -200,8 +200,8 @@ keymap.add_direct {
|
||||||
["shift+lclick"] = "doc:select-to-cursor",
|
["shift+lclick"] = "doc:select-to-cursor",
|
||||||
["ctrl+lclick"] = "doc:split-cursor",
|
["ctrl+lclick"] = "doc:split-cursor",
|
||||||
["lclick"] = "doc:set-cursor",
|
["lclick"] = "doc:set-cursor",
|
||||||
["dlclick"] = "doc:select-word",
|
["dlclick"] = "doc:set-cursor-word",
|
||||||
["tlclick"] = "doc:select-lines",
|
["tlclick"] = "doc:set-cursor-line",
|
||||||
["shift+left"] = "doc:select-to-previous-char",
|
["shift+left"] = "doc:select-to-previous-char",
|
||||||
["shift+right"] = "doc:select-to-next-char",
|
["shift+right"] = "doc:select-to-next-char",
|
||||||
["shift+up"] = "doc:select-to-previous-line",
|
["shift+up"] = "doc:select-to-previous-line",
|
||||||
|
|
|
@ -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}
|
self.dragged_node = { node = node, idx = idx, dragging = false, drag_start_x = x, drag_start_y = y}
|
||||||
end
|
end
|
||||||
node:set_active_view(node.views[idx])
|
node:set_active_view(node.views[idx])
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
elseif not self.dragged_node then -- avoid sending on_mouse_pressed events when dragging tabs
|
elseif not self.dragged_node then -- avoid sending on_mouse_pressed events when dragging tabs
|
||||||
core.set_active_view(node.active_view)
|
core.set_active_view(node.active_view)
|
||||||
|
|
Loading…
Reference in New Issue