mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Move app data accessing to the if-else block
This commit is contained in:
parent
e2a5211015
commit
b59e4e5a02
2 changed files with 21 additions and 18 deletions
|
|
@ -29,9 +29,9 @@ tab_inactive = { fg = "white", bg = "darkgray" }
|
|||
tab_width = 1
|
||||
|
||||
# Selected counter
|
||||
count_selected = { fg = "white", bg = "green" }
|
||||
count_copied = { fg = "white", bg = "yellow" }
|
||||
count_cut = { fg = "white", bg = "red" }
|
||||
count_copied = { fg = "black", bg = "lightgreen" }
|
||||
count_cut = { fg = "black", bg = "lightred" }
|
||||
count_selected = { fg = "black", bg = "lightblue" }
|
||||
|
||||
# Border
|
||||
border_symbol = "│"
|
||||
|
|
|
|||
|
|
@ -15,35 +15,38 @@ function Header:cwd()
|
|||
end
|
||||
|
||||
function Header:counter()
|
||||
local selected = #cx.active.selected
|
||||
local yanked = #cx.yanked
|
||||
|
||||
local count
|
||||
local style
|
||||
if cx.yanked.is_cut then
|
||||
local count, style
|
||||
if yanked == 0 then
|
||||
count = #cx.active.selected
|
||||
style = THEME.manager.count_selected
|
||||
elseif cx.yanked.is_cut then
|
||||
count = yanked
|
||||
style = THEME.manager.count_cut
|
||||
elseif yanked > 0 then
|
||||
else
|
||||
count = yanked
|
||||
style = THEME.manager.count_copied
|
||||
else
|
||||
count = selected
|
||||
style = THEME.manager.count_selected
|
||||
end
|
||||
|
||||
if count == 0 then
|
||||
return ui.Line({})
|
||||
else
|
||||
return ui.Line({
|
||||
ui.Span(string.format(" %s ", count)):style(style),
|
||||
ui.Span(" "),
|
||||
})
|
||||
return ui.Line {}
|
||||
end
|
||||
|
||||
return ui.Line {
|
||||
ui.Span(string.format(" %d ", count)):style(style),
|
||||
ui.Span(" "),
|
||||
}
|
||||
end
|
||||
|
||||
function Header:tabs()
|
||||
local tabs = #cx.tabs
|
||||
if tabs == 1 then
|
||||
return ui.Line {}
|
||||
end
|
||||
|
||||
local spans = {}
|
||||
for i = 1, #cx.tabs do
|
||||
for i = 1, tabs do
|
||||
local text = i
|
||||
if THEME.manager.tab_width > 2 then
|
||||
text = ya.truncate(text .. " " .. cx.tabs[i]:name(), THEME.manager.tab_width)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue