mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Refactor
This commit is contained in:
parent
ea674d61d9
commit
8ce8831ef5
2 changed files with 17 additions and 16 deletions
|
|
@ -1,24 +1,27 @@
|
||||||
Entity = {
|
Entity = {
|
||||||
_inc = 1000,
|
_inc = 1000,
|
||||||
_children = {
|
_children = {
|
||||||
{ "icon", id = 1, order = 1000 },
|
{ "space", id = 1, order = 1000 },
|
||||||
{ "prefix", id = 2, order = 2000 },
|
{ "icon", id = 2, order = 2000 },
|
||||||
{ "highlights", id = 3, order = 3000 },
|
{ "prefix", id = 3, order = 3000 },
|
||||||
{ "found", id = 4, order = 4000 },
|
{ "highlights", id = 4, order = 4000 },
|
||||||
{ "symlink", id = 5, order = 5000 },
|
{ "found", id = 5, order = 5000 },
|
||||||
|
{ "symlink", id = 6, order = 6000 },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
function Entity:new(file) return setmetatable({ _file = file }, { __index = self }) end
|
function Entity:new(file) return setmetatable({ _file = file }, { __index = self }) end
|
||||||
|
|
||||||
|
function Entity:space() return ui.Line(" ") end
|
||||||
|
|
||||||
function Entity:icon()
|
function Entity:icon()
|
||||||
local icon = self._file:icon()
|
local icon = self._file:icon()
|
||||||
if not icon then
|
if not icon then
|
||||||
return ui.Line("")
|
return ui.Line("")
|
||||||
elseif self._file:is_hovered() then
|
elseif self._file:is_hovered() then
|
||||||
return ui.Line(" " .. icon.text .. " ")
|
return ui.Line(icon.text .. " ")
|
||||||
else
|
else
|
||||||
return ui.Line(" " .. icon.text .. " "):style(icon.style)
|
return ui.Line(icon.text .. " "):style(icon.style)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,22 +2,23 @@ Linemode = {
|
||||||
_inc = 1000,
|
_inc = 1000,
|
||||||
_children = {
|
_children = {
|
||||||
{ "solo", id = 1, order = 1000 },
|
{ "solo", id = 1, order = 1000 },
|
||||||
|
{ "space", id = 2, order = 2000 },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
function Linemode:new(file) return setmetatable({ _file = file }, { __index = self }) end
|
function Linemode:new(file) return setmetatable({ _file = file }, { __index = self }) end
|
||||||
|
|
||||||
|
function Linemode:space() return ui.Line(" ") end
|
||||||
|
|
||||||
function Linemode:solo()
|
function Linemode:solo()
|
||||||
local mode = cx.active.conf.linemode
|
local mode = cx.active.conf.linemode
|
||||||
if mode == "none" or mode == "solo" then
|
if mode == "none" or mode == "solo" then
|
||||||
return ui.Line("")
|
return ui.Line("")
|
||||||
|
elseif self[mode] then
|
||||||
|
return ui.Line { ui.Span(" "), self[mode](self) }
|
||||||
|
else
|
||||||
|
return ui.Line(" " .. mode)
|
||||||
end
|
end
|
||||||
|
|
||||||
if not self[mode] then
|
|
||||||
return ui.Line(mode)
|
|
||||||
end
|
|
||||||
|
|
||||||
return ui.Line { self[mode](self) }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Linemode:size()
|
function Linemode:size()
|
||||||
|
|
@ -59,9 +60,6 @@ function Linemode:render()
|
||||||
local lines = {}
|
local lines = {}
|
||||||
for _, c in ipairs(self._children) do
|
for _, c in ipairs(self._children) do
|
||||||
lines[#lines + 1] = (type(c[1]) == "string" and self[c[1]] or c[1])(self)
|
lines[#lines + 1] = (type(c[1]) == "string" and self[c[1]] or c[1])(self)
|
||||||
if lines[#lines] and lines[#lines]:width() > 0 then
|
|
||||||
lines[#lines + 1] = ui.Line { ui.Span(" ") }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return ui.Line(lines)
|
return ui.Line(lines)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue