Fixed a bunch of problems. Fixed left+click not allowing for square selections, fixed esc not exiting multicursor mode, and allowed cntrl+click to remove a cursor.
This commit is contained in:
parent
120c769e7e
commit
82325b6a08
|
@ -175,14 +175,12 @@ local function block_comment(comment, line1, col1, line2, col2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local selection_commands = {
|
local commands = {
|
||||||
["doc:select-none"] = function()
|
["doc:select-none"] = function()
|
||||||
local line, col = doc():get_selection()
|
local line, col = doc():get_selection()
|
||||||
doc():set_selection(line, col)
|
doc():set_selection(line, col)
|
||||||
end
|
end,
|
||||||
}
|
|
||||||
|
|
||||||
local commands = {
|
|
||||||
["doc:cut"] = function()
|
["doc:cut"] = function()
|
||||||
cut_or_copy(true)
|
cut_or_copy(true)
|
||||||
end,
|
end,
|
||||||
|
@ -523,7 +521,19 @@ local commands = {
|
||||||
|
|
||||||
["doc:split-cursor"] = function(x, y, clicks)
|
["doc:split-cursor"] = function(x, y, clicks)
|
||||||
local line, col = dv():resolve_screen_position(x, y)
|
local line, col = dv():resolve_screen_position(x, y)
|
||||||
|
local removal_target = nil
|
||||||
|
for idx, line1, col1 in doc():get_selections(true) do
|
||||||
|
if line1 == line and col1 == col and #doc().selections > 4 then
|
||||||
|
removal_target = idx
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if removal_target then
|
||||||
|
doc():remove_selection(removal_target)
|
||||||
|
else
|
||||||
doc():add_selection(line, col, line, col)
|
doc():add_selection(line, col, line, col)
|
||||||
|
end
|
||||||
|
dv().mouse_selecting = { line, col, "set" }
|
||||||
end,
|
end,
|
||||||
|
|
||||||
["doc:create-cursor-previous-line"] = function()
|
["doc:create-cursor-previous-line"] = function()
|
||||||
|
@ -584,6 +594,3 @@ commands["doc:move-to-next-char"] = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
command.add("core.docview", commands)
|
command.add("core.docview", commands)
|
||||||
command.add(function()
|
|
||||||
return core.active_view:is(DocView) and core.active_view.doc:has_any_selection()
|
|
||||||
end ,selection_commands)
|
|
||||||
|
|
|
@ -198,6 +198,12 @@ function Doc:add_selection(line1, col1, line2, col2, swap)
|
||||||
self:set_selections(target, line1, col1, line2, col2, swap, 0)
|
self:set_selections(target, line1, col1, line2, col2, swap, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function Doc:remove_selection(idx)
|
||||||
|
common.splice(self.selections, (idx - 1) * 4 + 1, 4)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function Doc:set_selection(line1, col1, line2, col2, swap)
|
function Doc:set_selection(line1, col1, line2, col2, swap)
|
||||||
self.selections = {}
|
self.selections = {}
|
||||||
self:set_selections(1, line1, col1, line2, col2, swap)
|
self:set_selections(1, line1, col1, line2, col2, swap)
|
||||||
|
|
|
@ -224,7 +224,6 @@ function DocView:scroll_to_make_visible(line, col)
|
||||||
end
|
end
|
||||||
end
|
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, ...)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue