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"
|
|
|
|
local output, code = Command(cmd):args({ "-bL", tostring(self.file.url) }):stdout(Command.PIPED):output()
|
2024-01-20 03:41:46 +03:00
|
|
|
|
|
|
|
local p
|
|
|
|
if output then
|
2024-10-13 20:54:03 +03:00
|
|
|
p = ui.Text.parse("----- File Type Classification -----\n\n" .. output.stdout):area(self.area)
|
2024-01-20 03:41:46 +03:00
|
|
|
else
|
2024-10-13 20:54:03 +03:00
|
|
|
p = ui.Text(string.format("Spawn `%s` command returns %s", cmd, code)):area(self.area)
|
2024-01-20 03:41:46 +03:00
|
|
|
end
|
|
|
|
|
2024-10-13 20:54:03 +03:00
|
|
|
ya.preview_widgets(self, { p: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
|