yazi/yazi-plugin/preset/plugins/code.lua
2023-12-19 23:13:48 +08:00

18 lines
430 B
Lua

local Code = {}
function Code:peek()
local _, max = ya.preview_code(self.area, self.file, self.skip)
if max then
ya.manager_emit("peek", { tostring(max) })
end
end
function Code:seek(units)
local h = cx.active.current.hovered
if h and h.url == self.file.url then
local step = math.floor(units * self.area.h / 10)
ya.manager_emit("peek", { tostring(math.max(0, cx.active.preview.skip + step)) })
end
end
return Code