move selection logic to mouse click
This commit is contained in:
parent
becdb99222
commit
1526cd176c
|
@ -1,18 +1,6 @@
|
||||||
local core = require "core"
|
local core = require "core"
|
||||||
local command = require "core.command"
|
local command = require "core.command"
|
||||||
|
|
||||||
command.add("core.logview", {
|
|
||||||
["log:expand-item"] = function()
|
|
||||||
if core.active_view.hovered_item then
|
|
||||||
core.active_view:expand_item(core.active_view.hovered_item)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
["log:copy-entry"] = function()
|
|
||||||
if core.active_view.hovered_item then
|
|
||||||
system.set_clipboard(core.get_log(core.active_view.hovered_item))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
command.add(nil, {
|
command.add(nil, {
|
||||||
["log:open-as-doc"] = function()
|
["log:open-as-doc"] = function()
|
||||||
|
|
|
@ -235,8 +235,7 @@ keymap.add_direct {
|
||||||
["pagedown"] = "doc:move-to-next-page",
|
["pagedown"] = "doc:move-to-next-page",
|
||||||
|
|
||||||
["shift+1lclick"] = "doc:select-to-cursor",
|
["shift+1lclick"] = "doc:select-to-cursor",
|
||||||
["ctrl+1lclick"] = { "doc:split-cursor", "log:copy-entry" },
|
["ctrl+1lclick"] = "doc:split-cursor",
|
||||||
["lclick"] = "log:expand-item",
|
|
||||||
["1lclick"] = "doc:set-cursor",
|
["1lclick"] = "doc:set-cursor",
|
||||||
["2lclick"] = "doc:set-cursor-word",
|
["2lclick"] = "doc:set-cursor-word",
|
||||||
["3lclick"] = "doc:set-cursor-line",
|
["3lclick"] = "doc:set-cursor-line",
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
local core = require "core"
|
local core = require "core"
|
||||||
local common = require "core.common"
|
local common = require "core.common"
|
||||||
|
local keymap = require "core.keymap"
|
||||||
local style = require "core.style"
|
local style = require "core.style"
|
||||||
local View = require "core.view"
|
local View = require "core.view"
|
||||||
|
|
||||||
|
@ -78,17 +79,30 @@ function LogView:each_item()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function LogView:on_mouse_moved(px, py, ...)
|
function LogView:on_mouse_pressed(button, px, py, clicks)
|
||||||
LogView.super.on_mouse_moved(self, px, py, ...)
|
if LogView.super.on_mouse_pressed(self, button, px, py, clicks) then
|
||||||
local hovered = false
|
return true
|
||||||
for _, item, x, y, w, h in self:each_item() do
|
end
|
||||||
|
|
||||||
|
local index, selected
|
||||||
|
for i, item, x, y, w, h in self:each_item() do
|
||||||
if px >= x and py >= y and px < x + w and py < y + h then
|
if px >= x and py >= y and px < x + w and py < y + h then
|
||||||
hovered = true
|
index = i
|
||||||
self.hovered_item = item
|
selected = item
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not hovered then self.hovered_item = nil end
|
|
||||||
|
if selected then
|
||||||
|
if keymap.modkeys["ctrl"] then
|
||||||
|
system.set_clipboard(core.get_log(selected))
|
||||||
|
core.status_view:show_message("i", style.text, "copied entry #"..index.." to clipboard.")
|
||||||
|
else
|
||||||
|
self:expand_item(selected)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue