fix: compatibility with Yazi v0.4 for full-border.yazi
This commit is contained in:
@@ -1,3 +1,12 @@
|
|||||||
|
-- TODO: remove this once v0.4 is released
|
||||||
|
local v4 = function(typ, area, ...)
|
||||||
|
if typ == "bar" then
|
||||||
|
return ui.Table and ui.Bar(...):area(area) or ui.Bar(area, ...)
|
||||||
|
else
|
||||||
|
return ui.Table and ui.Border(...):area(area) or ui.Border(area, ...)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function setup(_, opts)
|
local function setup(_, opts)
|
||||||
local type = opts and opts.type or ui.Border.ROUNDED
|
local type = opts and opts.type or ui.Border.ROUNDED
|
||||||
local old_build = Tab.build
|
local old_build = Tab.build
|
||||||
@@ -5,10 +14,11 @@ local function setup(_, opts)
|
|||||||
Tab.build = function(self, ...)
|
Tab.build = function(self, ...)
|
||||||
local bar = function(c, x, y)
|
local bar = function(c, x, y)
|
||||||
if x <= 0 or x == self._area.w - 1 then
|
if x <= 0 or x == self._area.w - 1 then
|
||||||
return ui.Bar(ui.Rect.default, ui.Bar.TOP)
|
return v4("bar", ui.Rect.default, ui.Bar.TOP)
|
||||||
end
|
end
|
||||||
|
|
||||||
return ui.Bar(
|
return v4(
|
||||||
|
"bar",
|
||||||
ui.Rect { x = x, y = math.max(0, y), w = ya.clamp(0, self._area.w - x, 1), h = math.min(1, self._area.h) },
|
ui.Rect { x = x, y = math.max(0, y), w = ya.clamp(0, self._area.w - x, 1), h = math.min(1, self._area.h) },
|
||||||
ui.Bar.TOP
|
ui.Bar.TOP
|
||||||
):symbol(c)
|
):symbol(c)
|
||||||
@@ -23,9 +33,9 @@ local function setup(_, opts)
|
|||||||
|
|
||||||
local style = THEME.manager.border_style
|
local style = THEME.manager.border_style
|
||||||
self._base = ya.list_merge(self._base or {}, {
|
self._base = ya.list_merge(self._base or {}, {
|
||||||
ui.Border(self._area, ui.Border.ALL):type(type):style(style),
|
v4("border", self._area, ui.Border.ALL):type(type):style(style),
|
||||||
ui.Bar(self._chunks[1], ui.Bar.RIGHT):style(style),
|
v4("bar", self._chunks[1], ui.Bar.RIGHT):style(style),
|
||||||
ui.Bar(self._chunks[3], ui.Bar.LEFT):style(style),
|
v4("bar", self._chunks[3], ui.Bar.LEFT):style(style),
|
||||||
|
|
||||||
bar("┬", c[1].right - 1, c[1].y),
|
bar("┬", c[1].right - 1, c[1].y),
|
||||||
bar("┴", c[1].right - 1, c[1].bottom - 1),
|
bar("┴", c[1].right - 1, c[1].bottom - 1),
|
||||||
|
|||||||
Reference in New Issue
Block a user