2023-12-26 14:48:33 +03:00
|
|
|
Current = {
|
|
|
|
area = ui.Rect.default,
|
|
|
|
}
|
|
|
|
|
2024-04-12 05:09:29 +03:00
|
|
|
function Current:empty(area)
|
|
|
|
local folder = Folder:by_kind(Folder.CURRENT)
|
|
|
|
|
|
|
|
local line
|
|
|
|
if folder.files.filter then
|
|
|
|
line = ui.Line("No filter results")
|
|
|
|
else
|
2024-04-13 20:43:10 +03:00
|
|
|
line = ui.Line(folder.stage == "loading" and "Loading..." or "No items")
|
2024-04-12 05:09:29 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
|
|
|
ui.Paragraph(area, { line }):align(ui.Paragraph.CENTER),
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2023-12-26 14:48:33 +03:00
|
|
|
function Current:render(area)
|
|
|
|
self.area = area
|
|
|
|
|
2024-02-15 15:20:28 +03:00
|
|
|
local files = Folder:by_kind(Folder.CURRENT).window
|
|
|
|
if #files == 0 then
|
2024-04-12 05:09:29 +03:00
|
|
|
return self:empty(area)
|
2024-02-15 15:20:28 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
local items, markers = {}, {}
|
|
|
|
for i, f in ipairs(files) do
|
2024-02-24 19:28:12 +03:00
|
|
|
items[#items + 1] = ui.ListItem(ui.Line(File:full(f))):style(File:style(f))
|
2023-12-26 14:48:33 +03:00
|
|
|
|
2024-02-15 15:24:20 +03:00
|
|
|
-- Yanked/marked/selected files
|
2024-02-24 04:11:53 +03:00
|
|
|
local marker = File:marker(f)
|
2024-02-15 15:24:20 +03:00
|
|
|
if marker ~= 0 then
|
|
|
|
markers[#markers + 1] = { i, marker }
|
2023-12-26 14:48:33 +03:00
|
|
|
end
|
|
|
|
end
|
2024-02-15 15:20:28 +03:00
|
|
|
|
|
|
|
return ya.flat {
|
|
|
|
ui.List(area, items),
|
|
|
|
Folder:linemode(area, files),
|
|
|
|
Folder:markers(area, markers),
|
|
|
|
}
|
2023-12-26 14:48:33 +03:00
|
|
|
end
|
2024-06-03 09:31:55 +03:00
|
|
|
|
|
|
|
function Current:click(event, up)
|
2024-06-29 06:25:45 +03:00
|
|
|
if up or event.is_middle then
|
2024-06-03 09:31:55 +03:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local f = Folder:by_kind(Folder.CURRENT)
|
2024-06-29 06:25:45 +03:00
|
|
|
if event.y > #f.window or not f.hovered then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
ya.manager_emit("arrow", { event.y + f.offset - f.hovered.idx })
|
|
|
|
if event.is_right then
|
|
|
|
ya.manager_emit("open", { hovered = true })
|
2024-06-03 09:31:55 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function Current:scroll(event, step) ya.manager_emit("arrow", { step }) end
|
|
|
|
|
|
|
|
function Current:touch(event, step) end
|