mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat(plugin): double-click in current pane opens file or enters dir
This commit is contained in:
parent
da48c8d276
commit
dc6af08714
1 changed files with 22 additions and 2 deletions
|
|
@ -2,6 +2,8 @@ Current = {
|
||||||
_id = "current",
|
_id = "current",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local last_click = { time = 0, url = nil }
|
||||||
|
|
||||||
function Current:new(area, tab)
|
function Current:new(area, tab)
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
_area = area,
|
_area = area,
|
||||||
|
|
@ -54,9 +56,27 @@ function Current:click(event, up)
|
||||||
end
|
end
|
||||||
|
|
||||||
local y = event.y - self._area.y + 1
|
local y = event.y - self._area.y + 1
|
||||||
if self._folder.window[y] then
|
local f = self._folder.window[y]
|
||||||
Entity:new(self._folder.window[y]):click(event, up)
|
if not f then
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if event.is_left then
|
||||||
|
local delay = rt.mgr.mouse_double_click_delay or 0
|
||||||
|
local now = ya.time()
|
||||||
|
local url = tostring(f.url)
|
||||||
|
if delay > 0
|
||||||
|
and (now - last_click.time) * 1000 <= delay
|
||||||
|
and last_click.url == url
|
||||||
|
then
|
||||||
|
last_click.time = 0
|
||||||
|
ya.emit("open", {})
|
||||||
|
return
|
||||||
|
end
|
||||||
|
last_click = { time = now, url = url }
|
||||||
|
end
|
||||||
|
|
||||||
|
Entity:new(f):click(event, up)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Current:scroll(event, step) ya.emit("arrow", { step }) end
|
function Current:scroll(event, step) ya.emit("arrow", { step }) end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue