mirror of
https://github.com/kristoferssolo/solorice.git
synced 2026-02-04 06:32:03 +00:00
Update: 2024-10-17
This commit is contained in:
@@ -7,7 +7,7 @@ Add a full border to Yazi to make it look fancier.
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
ya pack -a yazi-rs/plugins#full-border
|
||||
ya pack -a yazi-rs/plugins:full-border
|
||||
```
|
||||
|
||||
## Usage
|
||||
@@ -18,5 +18,15 @@ Add this to your `init.lua` to enable the plugin:
|
||||
require("full-border"):setup()
|
||||
```
|
||||
|
||||
This plugin overrides the [`Manager.render`](https://github.com/sxyazi/yazi/blob/latest/yazi-plugin/preset/components/manager.lua) method,
|
||||
you might need to check if any other plugins that also need to override it are enabled.
|
||||
Or you can customize the border type:
|
||||
|
||||
```lua
|
||||
require("full-border"):setup {
|
||||
-- Available values: ui.Border.PLAIN, ui.Border.ROUNDED
|
||||
type = ui.Border.ROUNDED,
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
This plugin is MIT-licensed. For more information check the [LICENSE](LICENSE) file.
|
||||
|
||||
@@ -1,13 +1,29 @@
|
||||
local function setup()
|
||||
-- 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 type = opts and opts.type or ui.Border.ROUNDED
|
||||
local old_build = Tab.build
|
||||
|
||||
Tab.build = function(self, ...)
|
||||
local bar = function(c, x, y)
|
||||
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
|
||||
|
||||
return ui.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
|
||||
):symbol(c)
|
||||
end
|
||||
@@ -15,13 +31,13 @@ local function setup()
|
||||
local c = self._chunks
|
||||
self._chunks = {
|
||||
c[1]:padding(ui.Padding.y(1)),
|
||||
c[2]:padding(c[1].w > 0 and ui.Padding.y(1) or ui.Padding(1, 0, 1, 1)),
|
||||
c[2]:padding(ui.Padding(c[1].w > 0 and 0 or 1, c[3].w > 0 and 0 or 1, 1, 1)),
|
||||
c[3]:padding(ui.Padding.y(1)),
|
||||
}
|
||||
|
||||
local style = THEME.manager.border_style
|
||||
self._base = ya.list_merge(self._base or {}, {
|
||||
ui.Border(self._area, ui.Border.ALL):type(ui.Border.ROUNDED):style(style),
|
||||
ui.Border(self._area, ui.Border.ALL):type(type):style(style),
|
||||
ui.Bar(self._chunks[1], ui.Bar.RIGHT):style(style),
|
||||
ui.Bar(self._chunks[3], ui.Bar.LEFT):style(style),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user