Added in double, and triple clicking.
This commit is contained in:
+7
-19
@@ -224,25 +224,13 @@ function DocView:scroll_to_make_visible(line, col)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function DocView:mouse_selection(doc, clicks, line1, col1, line2, col2)
|
||||
local swap = line2 < line1 or line2 == line1 and col2 <= col1
|
||||
if swap then
|
||||
line1, col1, line2, col2 = line2, col2, line1, col1
|
||||
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
|
||||
if clicks % 4 == 2 then
|
||||
line1, col1 = translate.start_of_word(doc, line1, col1)
|
||||
line2, col2 = translate.end_of_word(doc, line2, col2)
|
||||
elseif clicks % 4 == 3 then
|
||||
if line2 == #doc.lines and doc.lines[#doc.lines] ~= "\n" then
|
||||
doc:insert(math.huge, math.huge, "\n")
|
||||
end
|
||||
line1, col1, line2, col2 = line1, 1, line2 + 1, 1
|
||||
end
|
||||
if swap then
|
||||
return line2, col2, line1, col1
|
||||
end
|
||||
return line1, col1, line2, col2
|
||||
core.blink_reset()
|
||||
end
|
||||
|
||||
function DocView:on_mouse_moved(x, y, ...)
|
||||
@@ -265,7 +253,7 @@ function DocView:on_mouse_moved(x, y, ...)
|
||||
self.doc:set_selections(i - l1 + 1, i, math.min(c1, #self.doc.lines[i]), i, math.min(c2, #self.doc.lines[i]))
|
||||
end
|
||||
else
|
||||
self.doc:set_selection(self:mouse_selection(self.doc, clicks, l1, c1, l2, c2))
|
||||
self.doc:set_selection(l1, c1, l2, c2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user