yazi/yazi-plugin/preset/components/preview.lua
WINLAIC a2996908de
feat: drag-resize panes with mouse (#3890)
Co-authored-by: Lingxuan Ye <yelingxuan@xiaomi.com>
Co-authored-by: sxyazi <sxyazi@gmail.com>
2026-04-22 19:35:19 +08:00

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