mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01:05 +00:00
Co-authored-by: Lingxuan Ye <yelingxuan@xiaomi.com> Co-authored-by: sxyazi <sxyazi@gmail.com>
34 lines
699 B
Lua
34 lines
699 B
Lua
Preview = {
|
|
_id = "preview",
|
|
}
|
|
|
|
function Preview:new(area, tab)
|
|
return setmetatable({
|
|
_area = area,
|
|
_tab = tab,
|
|
_folder = tab.preview.folder,
|
|
}, { __index = self })
|
|
end
|
|
|
|
function Preview:reflow() return { self } end
|
|
|
|
function Preview:redraw() return {} end
|
|
|
|
-- Mouse events
|
|
function Preview:click(event, up)
|
|
if up or event.is_middle then
|
|
return
|
|
end
|
|
|
|
local y = event.y - self._area.y + 1
|
|
local window = self._folder and self._folder.window or {}
|
|
if window[y] then
|
|
Entity:new(window[y]):click(event, up)
|
|
elseif not up and event.is_left then
|
|
ya.emit("enter", {})
|
|
end
|
|
end
|
|
|
|
function Preview:scroll(event, step) ya.emit("seek", { step }) end
|
|
|
|
function Preview:touch(event, step) end
|