Skip to content

Commit

Permalink
feat: adapt to sxyazi/yazi#1257
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi committed Jul 13, 2024
1 parent c8b3e39 commit 3783ea0
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 36 deletions.
2 changes: 1 addition & 1 deletion diff.yazi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Add this to your `~/.config/yazi/keymap.toml`:

```toml
[[manager.prepend_keymap]]
on = [ "<C-d>" ]
on = "<C-d>"
run = "plugin diff"
desc = "Diff the selected with the hovered file"
```
Expand Down
35 changes: 18 additions & 17 deletions full-border.yazi/init.lua
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
local function setup()
Manager.render = function(self, area)
local c = self:layout(area)
local old_build = Tab.build
Tab.build = function(self, ...)
local bar = function(c, x, y)
if x <= 0 or x == area.w - 1 then
return {}
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, area.w - x, 1), h = math.min(1, 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

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[3]:padding(ui.Padding.y(1)),
}

local style = THEME.manager.border_style
return ya.flat {
-- Borders
ui.Border(area, ui.Border.ALL):type(ui.Border.ROUNDED):style(style),
ui.Bar(c[1]:padding(ui.Padding.y(1)), ui.Bar.RIGHT):style(style),
ui.Bar(c[3]:padding(ui.Padding.y(1)), ui.Bar.LEFT):style(style),
self._base = ya.list_merge(self._base or {}, {
ui.Border(self._area, ui.Border.ALL):type(ui.Border.ROUNDED):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),
})

-- Parent
Parent:render(c[1]:padding(ui.Padding.xy(1))),
-- Current
Current:render(c[2]:padding(c[1].w > 0 and ui.Padding.y(1) or ui.Padding(1, 0, 1, 1))),
-- Preview
Preview:render(c[3]:padding(ui.Padding.xy(1))),
}
old_build(self, ...)
end
end

Expand Down
2 changes: 1 addition & 1 deletion hide-preview.yazi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Add this to your `~/.config/yazi/keymap.toml`:

```toml
[[manager.prepend_keymap]]
on = [ "T" ]
on = "T"
run = "plugin --sync hide-preview"
desc = "Hide or show preview"
```
Expand Down
12 changes: 5 additions & 7 deletions hide-preview.yazi/init.lua
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
local function entry(st)
if st.old then
Manager.layout, st.old = st.old, nil
Tab.layout, st.old = st.old, nil
else
st.old = Manager.layout
Manager.layout = function(self, area)
self.area = area

st.old = Tab.layout
Tab.layout = function(self)
local all = MANAGER.ratio.parent + MANAGER.ratio.current
return ui.Layout()
self._chunks = ui.Layout()
:direction(ui.Layout.HORIZONTAL)
:constraints({
ui.Constraint.Ratio(MANAGER.ratio.parent, all),
ui.Constraint.Ratio(MANAGER.ratio.current, all),
ui.Constraint.Length(1),
})
:split(area)
:split(self._area)
end
end
ya.app_emit("resize", {})
Expand Down
2 changes: 1 addition & 1 deletion jump-to-char.yazi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Add this to your `~/.config/yazi/keymap.toml`:

```toml
[[manager.prepend_keymap]]
on = [ "f" ]
on = "f"
run = "plugin jump-to-char"
desc = "Jump to char"
```
Expand Down
2 changes: 1 addition & 1 deletion max-preview.yazi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Add this to your `~/.config/yazi/keymap.toml`:

```toml
[[manager.prepend_keymap]]
on = [ "T" ]
on = "T"
run = "plugin --sync max-preview"
desc = "Maximize or restore preview"
```
Expand Down
12 changes: 5 additions & 7 deletions max-preview.yazi/init.lua
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
local function entry(st)
if st.old then
Manager.layout, st.old = st.old, nil
Tab.layout, st.old = st.old, nil
else
st.old = Manager.layout
Manager.layout = function(self, area)
self.area = area

return ui.Layout()
st.old = Tab.layout
Tab.layout = function(self)
self._chunks = ui.Layout()
:direction(ui.Layout.HORIZONTAL)
:constraints({
ui.Constraint.Percentage(0),
ui.Constraint.Percentage(0),
ui.Constraint.Percentage(100),
})
:split(area)
:split(self._area)
end
end
ya.app_emit("resize", {})
Expand Down
2 changes: 1 addition & 1 deletion smart-filter.yazi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Add this to your `~/.config/yazi/keymap.toml`:

```toml
[[manager.prepend_keymap]]
on = [ "F" ]
on = "F"
run = "plugin smart-filter"
desc = "Smart filter"
```
Expand Down

0 comments on commit 3783ea0

Please sign in to comment.