mirror of
https://github.com/sxyazi/yazi.git
synced 2024-12-18 14:21:32 +03:00
feat: add a new Folder:icon()
API to make it easier for users to extend icons (#301)
This commit is contained in:
parent
6d3457dde0
commit
c9178d4ab3
@ -14,6 +14,8 @@ function Folder:by_kind(kind)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Folder:icon(file) return ui.Span(" " .. file:icon() .. " ") end
|
||||||
|
|
||||||
function Folder:highlighted_name(file)
|
function Folder:highlighted_name(file)
|
||||||
-- Complete prefix when searching across directories
|
-- Complete prefix when searching across directories
|
||||||
local prefix = file:prefix() or ""
|
local prefix = file:prefix() or ""
|
||||||
@ -115,7 +117,7 @@ function Folder:parent(area)
|
|||||||
|
|
||||||
local items = {}
|
local items = {}
|
||||||
for _, f in ipairs(folder.window) do
|
for _, f in ipairs(folder.window) do
|
||||||
local item = ui.ListItem(" " .. f:icon() .. " " .. f.name .. " ")
|
local item = ui.ListItem(ui.Line { self:icon(f), ui.Span(f.name) })
|
||||||
if f:is_hovered() then
|
if f:is_hovered() then
|
||||||
item = item:style(THEME.manager.hovered)
|
item = item:style(THEME.manager.hovered)
|
||||||
else
|
else
|
||||||
@ -135,7 +137,7 @@ function Folder:current(area)
|
|||||||
local name = self:highlighted_name(f)
|
local name = self:highlighted_name(f)
|
||||||
|
|
||||||
-- Highlight hovered file
|
-- Highlight hovered file
|
||||||
local item = ui.ListItem(ui.Line { ui.Span(" " .. f:icon() .. " "), table.unpack(name) })
|
local item = ui.ListItem(ui.Line { self:icon(f), table.unpack(name) })
|
||||||
if f:is_hovered() then
|
if f:is_hovered() then
|
||||||
item = item:style(THEME.manager.hovered)
|
item = item:style(THEME.manager.hovered)
|
||||||
else
|
else
|
||||||
@ -162,7 +164,7 @@ function Folder:preview(area)
|
|||||||
|
|
||||||
local items = {}
|
local items = {}
|
||||||
for _, f in ipairs(folder.window) do
|
for _, f in ipairs(folder.window) do
|
||||||
local item = ui.ListItem(" " .. f:icon() .. " " .. f.name .. " ")
|
local item = ui.ListItem(ui.Line { self:icon(f), ui.Span(f.name) })
|
||||||
if f:is_hovered() then
|
if f:is_hovered() then
|
||||||
item = item:style(THEME.manager.preview_hovered)
|
item = item:style(THEME.manager.preview_hovered)
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user