From 5fc817d52c46c653ae8c7a8d95418b256c5b86da Mon Sep 17 00:00:00 2001 From: sxyazi Date: Wed, 20 Nov 2024 16:09:29 +0800 Subject: [PATCH] .. --- yazi-plugin/preset/plugins/file.lua | 1 + yazi-plugin/preset/plugins/image.lua | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/yazi-plugin/preset/plugins/file.lua b/yazi-plugin/preset/plugins/file.lua index 1cd39bf6..337554b6 100644 --- a/yazi-plugin/preset/plugins/file.lua +++ b/yazi-plugin/preset/plugins/file.lua @@ -16,6 +16,7 @@ end function M:seek() end +-- TODO: remove this local hovered_mime = ya.sync(function() local h = cx.active.current.hovered if not h then diff --git a/yazi-plugin/preset/plugins/image.lua b/yazi-plugin/preset/plugins/image.lua index 53a6bb96..3b398ec1 100644 --- a/yazi-plugin/preset/plugins/image.lua +++ b/yazi-plugin/preset/plugins/image.lua @@ -22,6 +22,30 @@ function M:preload() return ya.image_precache(self.file.url, cache) and 1 or 2 end -function M:spot(args) require("file"):spot(args) end +function M:spot(args) + local info = ya.image_info(args.file.url) + + local rows = {} + local row = function(key, value) + local h = type(value) == "table" and #value or 1 + rows[#rows + 1] = ui.Row({ key, value }):height(h) + end + + row("Format:", tostring(info.format)) + row("Width:", string.format("%dpx", info.w)) + row("Height:", string.format("%dpx", info.h)) + row("Color:", tostring(info.color)) + + ya.spot_table( + args, + ui.Table(rows) + :area(ui.Pos { "center", w = 60, h = 20 }) + :row(args.skip) + :col(1) + :col_style(ui.Style():fg("blue")) + :cell_style(ui.Style():fg("yellow"):reverse()) + :widths { ui.Constraint.Length(12), ui.Constraint.Fill(1) } + ) +end return M