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
|
tab_width = 1
|
||||||
|
|
||||||
# Selected counter
|
# Selected counter
|
||||||
count_selected = { fg = "white", bg = "green" }
|
count_copied = { fg = "black", bg = "lightgreen" }
|
||||||
count_copied = { fg = "white", bg = "yellow" }
|
count_cut = { fg = "black", bg = "lightred" }
|
||||||
count_cut = { fg = "white", bg = "red" }
|
count_selected = { fg = "black", bg = "lightblue" }
|
||||||
|
|
||||||
# Border
|
# Border
|
||||||
border_symbol = "│"
|
border_symbol = "│"
|
||||||
|
|
|
||||||
|
|
@ -15,35 +15,38 @@ function Header:cwd()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Header:counter()
|
function Header:counter()
|
||||||
local selected = #cx.active.selected
|
|
||||||
local yanked = #cx.yanked
|
local yanked = #cx.yanked
|
||||||
|
|
||||||
local count
|
local count, style
|
||||||
local style
|
if yanked == 0 then
|
||||||
if cx.yanked.is_cut then
|
count = #cx.active.selected
|
||||||
|
style = THEME.manager.count_selected
|
||||||
|
elseif cx.yanked.is_cut then
|
||||||
count = yanked
|
count = yanked
|
||||||
style = THEME.manager.count_cut
|
style = THEME.manager.count_cut
|
||||||
elseif yanked > 0 then
|
else
|
||||||
count = yanked
|
count = yanked
|
||||||
style = THEME.manager.count_copied
|
style = THEME.manager.count_copied
|
||||||
else
|
|
||||||
count = selected
|
|
||||||
style = THEME.manager.count_selected
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if count == 0 then
|
if count == 0 then
|
||||||
return ui.Line({})
|
return ui.Line {}
|
||||||
else
|
|
||||||
return ui.Line({
|
|
||||||
ui.Span(string.format(" %s ", count)):style(style),
|
|
||||||
ui.Span(" "),
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return ui.Line {
|
||||||
|
ui.Span(string.format(" %d ", count)):style(style),
|
||||||
|
ui.Span(" "),
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
function Header:tabs()
|
function Header:tabs()
|
||||||
|
local tabs = #cx.tabs
|
||||||
|
if tabs == 1 then
|
||||||
|
return ui.Line {}
|
||||||
|
end
|
||||||
|
|
||||||
local spans = {}
|
local spans = {}
|
||||||
for i = 1, #cx.tabs do
|
for i = 1, tabs do
|
||||||
local text = i
|
local text = i
|
||||||
if THEME.manager.tab_width > 2 then
|
if THEME.manager.tab_width > 2 then
|
||||||
text = ya.truncate(text .. " " .. cx.tabs[i]:name(), THEME.manager.tab_width)
|
text = ya.truncate(text .. " " .. cx.tabs[i]:name(), THEME.manager.tab_width)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue