2024-01-20 03:41:46 +03:00
|
|
|
local M = {}
|
|
|
|
|
|
|
|
function M:peek()
|
2024-03-28 12:14:11 +03:00
|
|
|
local cmd = os.getenv("YAZI_FILE_ONE") or "file"
|
2024-10-14 19:44:31 +03:00
|
|
|
local output, code = Command(cmd):args({ "-bL", "--", tostring(self.file.url) }):stdout(Command.PIPED):output()
|
2024-01-20 03:41:46 +03:00
|
|
|
|
2024-10-14 14:39:59 +03:00
|
|
|
local text
|
2024-01-20 03:41:46 +03:00
|
|
|
if output then
|
2024-10-14 14:39:59 +03:00
|
|
|
text = ui.Text.parse("----- File Type Classification -----\n\n" .. output.stdout)
|
2024-01-20 03:41:46 +03:00
|
|
|
else
|
2024-10-14 14:39:59 +03:00
|
|
|
text = ui.Text(string.format("Spawn `%s` command returns %s", cmd, code))
|
2024-01-20 03:41:46 +03:00
|
|
|
end
|
|
|
|
|
2024-10-14 14:39:59 +03:00
|
|
|
ya.preview_widgets(self, { text:area(self.area):wrap(ui.Text.WRAP) })
|
2024-01-20 03:41:46 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
function M:seek() end
|
|
|
|
|
2024-10-13 20:54:03 +03:00
|
|
|
function M:spot(skip)
|
|
|
|
local rect = ui.Rect { x = 10, y = 10, w = 20, h = 20 }
|
|
|
|
|
|
|
|
ya.spot_widgets(self, {
|
|
|
|
ui.Clear(rect),
|
|
|
|
ui.Table(rect),
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2024-01-20 03:41:46 +03:00
|
|
|
return M
|