mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-22 15:21:04 +00:00
Some checks are pending
Cachix / Publish Flake (push) Waiting to run
Check / clippy (push) Waiting to run
Check / rustfmt (push) Waiting to run
Check / stylua (push) Waiting to run
Draft / build-unix (gcc-aarch64-linux-gnu, ubuntu-latest, aarch64-unknown-linux-gnu) (push) Waiting to run
Draft / build-unix (gcc-i686-linux-gnu, ubuntu-latest, i686-unknown-linux-gnu) (push) Waiting to run
Draft / build-unix (gcc-riscv64-linux-gnu, ubuntu-latest, riscv64gc-unknown-linux-gnu) (push) Waiting to run
Draft / build-unix (gcc-sparc64-linux-gnu, ubuntu-latest, sparc64-unknown-linux-gnu) (push) Waiting to run
Draft / build-unix (macos-latest, aarch64-apple-darwin) (push) Waiting to run
Draft / build-unix (macos-latest, x86_64-apple-darwin) (push) Waiting to run
Draft / build-unix (ubuntu-latest, x86_64-unknown-linux-gnu) (push) Waiting to run
Draft / build-windows (windows-latest, aarch64-pc-windows-msvc) (push) Waiting to run
Draft / build-windows (windows-latest, x86_64-pc-windows-msvc) (push) Waiting to run
Draft / build-musl (aarch64-unknown-linux-musl) (push) Waiting to run
Draft / build-musl (x86_64-unknown-linux-musl) (push) Waiting to run
Draft / build-snap (amd64, ubuntu-latest) (push) Waiting to run
Draft / build-snap (arm64, ubuntu-24.04-arm) (push) Waiting to run
Draft / snap (push) Blocked by required conditions
Draft / draft (push) Blocked by required conditions
Draft / nightly (push) Blocked by required conditions
Test / test (macos-latest) (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
Test / test (windows-latest) (push) Waiting to run
57 lines
1.2 KiB
Lua
57 lines
1.2 KiB
Lua
local M = {}
|
|
|
|
function M:peek(job)
|
|
local start, url = os.clock(), ya.file_cache(job)
|
|
if not url or not fs.cha(url) then
|
|
url = Url(job.file.path)
|
|
end
|
|
|
|
ya.sleep(math.max(0, rt.preview.image_delay / 1000 + start - os.clock()))
|
|
|
|
local _, err = ya.image_show(url, job.area)
|
|
ya.preview_widget(job, err)
|
|
end
|
|
|
|
function M:seek() end
|
|
|
|
function M:preload(job)
|
|
local cache = ya.file_cache(job)
|
|
if not cache or fs.cha(cache) then
|
|
return true
|
|
end
|
|
|
|
return ya.image_precache(Url(job.file.path), cache)
|
|
end
|
|
|
|
function M:spot(job)
|
|
local rows = self:spot_base(job)
|
|
rows[#rows + 1] = ui.Row {}
|
|
|
|
ya.spot_table(
|
|
job,
|
|
ui.Table(ya.list_merge(rows, require("file"):spot_base(job)))
|
|
:area(ui.Pos { "center", w = 60, h = 20 })
|
|
:row(job.skip)
|
|
:row(1)
|
|
:col(1)
|
|
:col_style(th.spot.tbl_col)
|
|
:cell_style(th.spot.tbl_cell)
|
|
:widths { ui.Constraint.Length(14), ui.Constraint.Fill(1) }
|
|
)
|
|
end
|
|
|
|
function M:spot_base(job)
|
|
local info = ya.image_info(Url(job.file.path))
|
|
if not info then
|
|
return {}
|
|
end
|
|
|
|
return {
|
|
ui.Row({ "Image" }):style(ui.Style():fg("green")),
|
|
ui.Row { " Format:", tostring(info.format) },
|
|
ui.Row { " Size:", string.format("%dx%d", info.w, info.h) },
|
|
ui.Row { " Color:", tostring(info.color) },
|
|
}
|
|
end
|
|
|
|
return M
|