2023-12-26 14:48:33 +03:00
|
|
|
local M = {}
|
|
|
|
|
|
|
|
function M:peek()
|
2024-08-24 21:56:38 +03:00
|
|
|
local err, bound = ya.preview_code(self)
|
2023-12-26 14:48:33 +03:00
|
|
|
if bound then
|
2024-04-22 09:18:00 +03:00
|
|
|
ya.manager_emit("peek", { bound, only_if = self.file.url, upper_bound = true })
|
2024-08-26 04:00:09 +03:00
|
|
|
elseif err and not err:find("cancelled", 1, true) then
|
2024-08-24 21:56:38 +03:00
|
|
|
ya.preview_widgets(self, {
|
|
|
|
ui.Paragraph(self.area, { ui.Line(err):reverse() }),
|
|
|
|
})
|
2023-12-26 14:48:33 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function M: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", {
|
2024-03-01 05:22:12 +03:00
|
|
|
math.max(0, cx.active.preview.skip + step),
|
2024-04-22 09:18:00 +03:00
|
|
|
only_if = self.file.url,
|
2023-12-26 14:48:33 +03:00
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return M
|