mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: truncate path for deeply nested directories
This commit is contained in:
parent
d96af54574
commit
30af0af443
1 changed files with 11 additions and 6 deletions
|
|
@ -2,16 +2,21 @@ Header = {
|
|||
area = ui.Rect.default,
|
||||
}
|
||||
|
||||
function Header:cwd()
|
||||
function Header:cwd(area)
|
||||
local cwd = cx.active.current.cwd
|
||||
|
||||
local span
|
||||
local path
|
||||
if not cwd.is_search then
|
||||
span = ui.Span(ya.readable_path(tostring(cwd)))
|
||||
path = ya.readable_path(tostring(cwd))
|
||||
else
|
||||
span = ui.Span(string.format("%s (search: %s)", ya.readable_path(tostring(cwd)), cwd:frag()))
|
||||
path = string.format("%s (search: %s)", ya.readable_path(tostring(cwd)), cwd:frag())
|
||||
end
|
||||
return span:style(THEME.manager.cwd)
|
||||
|
||||
local width = area.right
|
||||
if #path > width then
|
||||
path = string.sub(path, #path - width + 1)
|
||||
end
|
||||
return ui.Span(path):style(THEME.manager.cwd)
|
||||
end
|
||||
|
||||
function Header:count()
|
||||
|
|
@ -72,7 +77,7 @@ end
|
|||
function Header:render(area)
|
||||
local chunks = self:layout(area)
|
||||
|
||||
local left = ui.Line { self:cwd() }
|
||||
local left = ui.Line { self:cwd(chunks[1]) }
|
||||
local right = ui.Line { self:count(), self:tabs() }
|
||||
return {
|
||||
ui.Paragraph(chunks[1], { left }),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue