Compare commits

...

2 Commits

6 changed files with 189 additions and 34 deletions

View File

@ -1,43 +1,48 @@
local function setup(_, opts)
local type = opts and opts.type or ui.Border.ROUNDED
local old_build = Tab.build
-- 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)
end
-- 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)
-- 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.Bar.TOP
):symbol(c)
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.Bar.TOP
-- ):symbol(c)
-- end
local c = self._chunks
self._chunks = {
c[1]:padding(ui.Padding.y(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 c = self._chunks
-- self._chunks = {
-- c[1]:padding(ui.Padding.y(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(type):style(style),
ui.Bar(self._chunks[1], ui.Bar.RIGHT):style(style),
ui.Bar(self._chunks[3], ui.Bar.LEFT):style(style),
-- local style = THEME.manager.border_style
-- self._base = ya.list_merge(self._base or {}, {
-- 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),
bar("", c[1].right - 1, c[1].y),
bar("", c[1].right - 1, c[1].bottom - 1),
bar("", c[2].right, c[2].y),
bar("", c[2].right, c[2].bottom - 1),
})
-- bar("┬", c[1].right - 1, c[1].y),
-- bar("┴", c[1].right - 1, c[1].bottom - 1),
-- bar("┬", c[2].right, c[2].y),
-- bar("┴", c[2].right, c[2].bottom - 1),
-- })
old_build(self, ...)
end
end
-- old_build(self, ...)
-- end
-- end
setup {
-- setup {
-- -- Available values: ui.Border.PLAIN, ui.Border.ROUNDED
-- type = ui.Border.ROUNDED,
-- }
require("full-border"):setup {
-- Available values: ui.Border.PLAIN, ui.Border.ROUNDED
type = ui.Border.ROUNDED,
}

View File

@ -1,4 +1,4 @@
[[manager.prepend_keymap]]
[[manager.prependd_keymap]]
on = "<C-n>"
run = '''
shell 'dragon -x -i -T "$1"' --confirm
@ -19,3 +19,50 @@ desc = "Mount selected archive"
on = [ "m", "u" ]
run = "plugin archivemount --args=unmount"
desc = "Unmount and save changes to original archive"
[[manager.prepend_keymap]]
on = ["R", "p", "p"]
run = "plugin sudo --args='paste'"
desc = "sudo paste"
# sudo cp/mv --force
[[manager.prepend_keymap]]
on = ["R", "P"]
run = "plugin sudo --args='paste -f'"
desc = "sudo paste"
# sudo mv
[[manager.prepend_keymap]]
on = ["R", "r"]
run = "plugin sudo --args='rename'"
desc = "sudo rename"
# sudo ln -s (absolute-path)
[[manager.prepend_keymap]]
on = ["R", "p", "l"]
run = "plugin sudo --args='link'"
desc = "sudo link"
# sudo ln -s (relative-path)
[[manager.prepend_keymap]]
on = ["R", "p", "L"]
run = "plugin sudo --args='link -r'"
desc = "sudo link relative path"
# sudo touch/mkdir
[[manager.prepend_keymap]]
on = ["R", "a"]
run = "plugin sudo --args='create'"
desc = "sudo create"
# sudo trash
[[manager.prepend_keymap]]
on = ["R", "d"]
run = "plugin sudo --args='remove'"
desc = "sudo trash"
# sudo delete
[[manager.prepend_keymap]]
on = ["R", "D"]
run = "plugin sudo --args='remove -P'"
desc = "sudo delete"

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 yazi-rs
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,32 @@
# full-border.yazi
Add a full border to Yazi to make it look fancier.
![full-border](https://github.com/yazi-rs/plugins/assets/17523360/ef81b560-2465-4d36-abf2-5d21dcb7b987)
## Installation
```sh
ya pack -a yazi-rs/plugins:full-border
```
## Usage
Add this to your `init.lua` to enable the plugin:
```lua
require("full-border"):setup()
```
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.

View File

@ -0,0 +1,50 @@
-- 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 v4("bar", ui.Rect.default, ui.Bar.TOP)
end
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.Bar.TOP
):symbol(c)
end
local c = self._chunks
self._chunks = {
c[1]:padding(ui.Padding.y(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 {}, {
v4("border", self._area, ui.Border.ALL):type(type):style(style),
v4("bar", self._chunks[1], ui.Bar.RIGHT):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].bottom - 1),
bar("", c[2].right, c[2].y),
bar("", c[2].right, c[2].bottom - 1),
})
old_build(self, ...)
end
end
return { setup = setup }