2023-12-26 14:48:33 +03:00
|
|
|
local M = {}
|
|
|
|
|
|
|
|
function M:peek()
|
2024-07-12 13:32:01 +03:00
|
|
|
local folder = cx.active.preview.folder
|
2024-02-15 15:20:28 +03:00
|
|
|
if not folder or folder.cwd ~= self.file.url then
|
2024-04-12 05:09:29 +03:00
|
|
|
return
|
2023-12-26 14:48:33 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
local bound = math.max(0, #folder.files - self.area.h)
|
|
|
|
if self.skip > bound then
|
2024-04-22 09:18:00 +03:00
|
|
|
return ya.manager_emit("peek", { bound, only_if = self.file.url, upper_bound = true })
|
2024-04-12 05:09:29 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
if #folder.files == 0 then
|
|
|
|
return ya.preview_widgets(self, {
|
2024-10-14 14:39:59 +03:00
|
|
|
ui.Text(folder.stage.is_loading and "Loading..." or "No items"):area(self.area):align(ui.Text.CENTER),
|
2024-04-12 05:09:29 +03:00
|
|
|
})
|
2023-12-26 14:48:33 +03:00
|
|
|
end
|
|
|
|
|
2024-10-30 14:06:06 +03:00
|
|
|
local entities = {}
|
2024-07-12 13:32:01 +03:00
|
|
|
for _, f in ipairs(folder.window) do
|
2024-10-30 14:06:06 +03:00
|
|
|
entities[#entities + 1] = Entity:new(f):redraw()
|
2023-12-26 14:48:33 +03:00
|
|
|
end
|
2024-02-15 15:20:28 +03:00
|
|
|
|
2024-07-12 13:32:01 +03:00
|
|
|
ya.preview_widgets(self, {
|
2024-10-30 14:06:06 +03:00
|
|
|
ui.List(entities):area(self.area),
|
|
|
|
table.unpack(Marker:new(self.area, folder):redraw()),
|
2024-07-12 13:32:01 +03:00
|
|
|
})
|
2023-12-26 14:48:33 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
function M:seek(units)
|
2024-07-12 13:32:01 +03:00
|
|
|
local folder = cx.active.preview.folder
|
2023-12-26 14:48:33 +03:00
|
|
|
if folder and folder.cwd == self.file.url then
|
|
|
|
local step = math.floor(units * self.area.h / 10)
|
|
|
|
local bound = math.max(0, #folder.files - self.area.h)
|
|
|
|
ya.manager_emit("peek", {
|
2024-03-01 05:22:12 +03:00
|
|
|
ya.clamp(0, cx.active.preview.skip + step, bound),
|
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
|