add yazi
This commit is contained in:
parent
ad286ec3f7
commit
04e857d96e
9 changed files with 800 additions and 0 deletions
103
.config/yazi/init.lua
Normal file
103
.config/yazi/init.lua
Normal file
|
@ -0,0 +1,103 @@
|
|||
Manager = {
|
||||
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)
|
||||
local chunks = self:layout(area)
|
||||
|
||||
local bar = function(c, x, 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)
|
||||
:symbol(c)
|
||||
end
|
||||
|
||||
return ya.flat {
|
||||
-- Borders
|
||||
ui.Border(area, ui.Border.ALL):type(ui.Border.ROUNDED),
|
||||
ui.Bar(chunks[1], ui.Bar.RIGHT),
|
||||
ui.Bar(chunks[3], ui.Bar.LEFT),
|
||||
|
||||
bar("┬", chunks[1].right - 1, chunks[1].y),
|
||||
bar("┴", chunks[1].right - 1, chunks[1].bottom - 1),
|
||||
bar("┬", chunks[2].right, chunks[2].y),
|
||||
bar("┴", chunks[2].right, chunks[1].bottom - 1),
|
||||
|
||||
-- Parent
|
||||
Parent:render(chunks[1]:padding(ui.Padding.xy(1))),
|
||||
-- Current
|
||||
Current:render(chunks[2]:padding(ui.Padding.y(1))),
|
||||
-- Preview
|
||||
Preview:render(chunks[3]:padding(ui.Padding.xy(1))),
|
||||
}
|
||||
end
|
||||
|
||||
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)
|
||||
local chunks = self:layout(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()
|
||||
local h = cx.active.current.hovered
|
||||
if h == nil or ya.target_family() ~= "unix" then
|
||||
return ui.Line {}
|
||||
end
|
||||
|
||||
return ui.Line {
|
||||
ui.Span(ya.user_name(h.cha.uid) or tostring(h.cha.uid)):fg("magenta"),
|
||||
ui.Span(":"),
|
||||
ui.Span(ya.group_name(h.cha.gid) or tostring(h.cha.gid)):fg("magenta"),
|
||||
ui.Span(" "),
|
||||
}
|
||||
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)
|
||||
self.area = area
|
||||
|
||||
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:percentage(), self:position() }
|
||||
return {
|
||||
ui.Paragraph(area, { left }),
|
||||
ui.Paragraph(area, { right }):align(ui.Paragraph.RIGHT),
|
||||
table.unpack(Progress:render(area, right:width())),
|
||||
}
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue