feat: add full-border.yazi plugin
This commit is contained in:
@@ -5,7 +5,16 @@
|
||||
|
||||
# Plugins
|
||||
|
||||
The following plugins can be installed using the `ya pack` package manager - it's part of the upcoming Yazi v0.3 (currently available on the latest main branch).
|
||||
|
||||
For specific installation commands and configuration instructions, check the individual `README.md` of each plugin by clicking the link below:
|
||||
|
||||
- [full-border.yazi](full-border.yazi) - Add a full border to Yazi to make it look fancier.
|
||||
- [max-preview.yazi](max-preview.yazi) - Maximize or restore the preview pane.
|
||||
- [hide-preview.yazi](hide-preview.yazi) - Switch the preview pane between hidden and shown.
|
||||
- [smart-filter.yazi](smart-filter.yazi) - Makes filters smarter: continuous filtering, automatically enter unique directory, open file on submitting.
|
||||
- [jump-to-char.yazi](jump-to-char.yazi) - Vim-like `f<char>`, jump to the next file whose name starts with `<char>`.
|
||||
|
||||
Note that `ya` is a newly introduced standalone CLI binary, not a shell alias for Yazi (See https://github.com/sxyazi/yazi/issues/914 for details)
|
||||
|
||||
If you don't have it, you can also copy each directory ending with `.yazi` to your `~/.config/yazi/plugins` and manually keep them up to date.
|
||||
|
||||
21
full-border.yazi/LICENSE
Normal file
21
full-border.yazi/LICENSE
Normal 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.
|
||||
20
full-border.yazi/README.md
Normal file
20
full-border.yazi/README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# full-border.yazi
|
||||
|
||||
Add a full border to Yazi to make it look fancier.
|
||||
|
||||
## 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()
|
||||
```
|
||||
|
||||
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.
|
||||
32
full-border.yazi/init.lua
Normal file
32
full-border.yazi/init.lua
Normal file
@@ -0,0 +1,32 @@
|
||||
local function setup()
|
||||
Manager.render = function(self, 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
|
||||
end
|
||||
|
||||
return { setup = setup }
|
||||
Reference in New Issue
Block a user