update yazi
This commit is contained in:
parent
b70d88c06f
commit
71ac4ef6b4
2 changed files with 33 additions and 54 deletions
|
@ -1,27 +1,11 @@
|
||||||
Manager = {
|
-- Full Border
|
||||||
area = ui.Rect.default,
|
|
||||||
}
|
|
||||||
|
|
||||||
function Manager:layout(area)
|
|
||||||
self.area = area
|
|
||||||
|
|
||||||
return ui.Layout()
|
|
||||||
:direction(ui.Layout.HORIZONTAL)
|
|
||||||
:constraints({
|
|
||||||
ui.Constraint.Ratio(MANAGER.ratio.parent, MANAGER.ratio.all),
|
|
||||||
ui.Constraint.Ratio(MANAGER.ratio.current, MANAGER.ratio.all),
|
|
||||||
ui.Constraint.Ratio(MANAGER.ratio.preview, MANAGER.ratio.all),
|
|
||||||
})
|
|
||||||
:split(area)
|
|
||||||
end
|
|
||||||
|
|
||||||
function Manager:render(area)
|
function Manager:render(area)
|
||||||
local chunks = self:layout(area)
|
local chunks = self:layout(area)
|
||||||
|
|
||||||
local bar = function(c, x, y)
|
local bar = function(c, x, y)
|
||||||
x, y = math.max(0, x), math.max(0, y)
|
x, y = math.max(0, x), math.max(0, y)
|
||||||
return ui.Bar(ui.Rect { x = x, y = y, w = ya.clamp(0, area.w - x, 1), h = math.min(1, area.h) }, ui.Bar.TOP)
|
return ui.Bar(ui.Rect { x = x, y = y, w = ya.clamp(0, area.w - x, 1), h = math.min(1, area.h) }, ui.Bar.TOP):symbol(c)
|
||||||
:symbol(c)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return ya.flat {
|
return ya.flat {
|
||||||
|
@ -44,23 +28,7 @@ function Manager:render(area)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
function Header:host()
|
-- Show owner in status bar
|
||||||
if ya.target_family() ~= "unix" then
|
|
||||||
return ui.Line {}
|
|
||||||
end
|
|
||||||
return ui.Span(ya.user_name() .. "@" .. ya.host_name() .. ":"):fg("blue")
|
|
||||||
end
|
|
||||||
|
|
||||||
function Header:render(area)
|
|
||||||
local chunks = self:render(area)
|
|
||||||
|
|
||||||
local left = ui.Line { self:host(), self:cwd() }
|
|
||||||
local right = ui.Line { self:tabs() }
|
|
||||||
return {
|
|
||||||
ui.Paragraph(chunks[1], { left }),
|
|
||||||
ui.Paragraph(chunks[2], { right }):align(ui.Paragraph.RIGHT),
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
function Status:owner()
|
function Status:owner()
|
||||||
local h = cx.active.current.hovered
|
local h = cx.active.current.hovered
|
||||||
|
@ -76,28 +44,34 @@ function Status:owner()
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
function Status:mtime()
|
|
||||||
local h = cx.active.current.hovered
|
|
||||||
if h == nil or ya.target_family() ~= "unix" then
|
|
||||||
return ui.Line {}
|
|
||||||
end
|
|
||||||
|
|
||||||
-- fix unix timestamp format
|
|
||||||
return ui.Line {
|
|
||||||
ui.Span(h.cha.modified):fg("magenta"),
|
|
||||||
ui.Span(" ")
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
function Status:render(area)
|
function Status:render(area)
|
||||||
self.area = area
|
self.area = area
|
||||||
|
|
||||||
local left = ui.Line { self:mode(), self:size(), self:name() }
|
local left = ui.Line { self:mode(), self:size(), self:name() }
|
||||||
--local right = ui.Line { self:mtime(), self:owner(), self:percentage(), self:position() }
|
local right = ui.Line { self:owner(), self:permissions(), self:percentage(), self:position() }
|
||||||
local right = ui.Line { self:owner(), self:percentage(), self:position() }
|
|
||||||
return {
|
return {
|
||||||
ui.Paragraph(area, { left }),
|
ui.Paragraph(area, { left }),
|
||||||
ui.Paragraph(area, { right }):align(ui.Paragraph.RIGHT),
|
ui.Paragraph(area, { right }):align(ui.Paragraph.RIGHT),
|
||||||
table.unpack(Progress:render(area, right:width())),
|
table.unpack(Progress:render(area, right:width())),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Show hostname in header
|
||||||
|
|
||||||
|
function Header:host()
|
||||||
|
if ya.target_family() ~= "unix" then
|
||||||
|
return ui.Line {}
|
||||||
|
end
|
||||||
|
return ui.Span(ya.user_name() .. "@" .. ya.host_name() .. ":"):fg("blue")
|
||||||
|
end
|
||||||
|
|
||||||
|
function Header:render(area)
|
||||||
|
self.area = area
|
||||||
|
|
||||||
|
local right = ui.Line { self:count(), self:tabs() }
|
||||||
|
local left = ui.Line { self:host(), self:cwd(math.max(0, area.w - right:width())) }
|
||||||
|
return {
|
||||||
|
ui.Paragraph(area, { left }),
|
||||||
|
ui.Paragraph(area, { right }):align(ui.Paragraph.RIGHT),
|
||||||
|
}
|
||||||
|
end
|
|
@ -3,6 +3,11 @@ on = [ "<Esc>" ]
|
||||||
run = "close"
|
run = "close"
|
||||||
desc = "Cancel input"
|
desc = "Cancel input"
|
||||||
|
|
||||||
|
[[manager.prepend_keymap]]
|
||||||
|
on = [ "<C-s>" ]
|
||||||
|
run = 'shell "$SHELL" --block --confirm'
|
||||||
|
desc = "Open shell here"
|
||||||
|
|
||||||
[[manager.prepend_keymap]]
|
[[manager.prepend_keymap]]
|
||||||
on = [ "l" ]
|
on = [ "l" ]
|
||||||
run = "plugin --sync smart-enter"
|
run = "plugin --sync smart-enter"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue