refactor: simplify the code
This commit is contained in:
@@ -23,6 +23,7 @@ ya pack -a yazi-rs/plugins:toggle-pane
|
||||
Hide/Show preview:
|
||||
|
||||
```toml
|
||||
# keymap.toml
|
||||
[[manager.prepend_keymap]]
|
||||
on = "T"
|
||||
run = "plugin toggle-pane min-preview"
|
||||
@@ -32,6 +33,7 @@ desc = "Show or hide the preview pane"
|
||||
Maximize/Restore preview:
|
||||
|
||||
```toml
|
||||
# keymap.toml
|
||||
[[manager.prepend_keymap]]
|
||||
on = "T"
|
||||
run = "plugin toggle-pane max-preview"
|
||||
@@ -52,6 +54,25 @@ end
|
||||
|
||||
In the example above, when it detects that you're [using Yazi in nvim](https://yazi-rs.github.io/docs/resources#vim), the preview is hidden by default — you can always press `T` (or any key you've bound) to show it again.
|
||||
|
||||
## Tips
|
||||
|
||||
This plugin only maximizes the "available preview area", without actually changing the content size.
|
||||
|
||||
This means that the appearance of your preview largely depends on the previewer you are using.
|
||||
However, most previewers tend to make the most of the available space, so this usually isn't an issue.
|
||||
|
||||
For image previews, you may want to tune up the [`max_width`][max-width] and [`max_height`][max-height] options in your `yazi.toml`:
|
||||
|
||||
```toml
|
||||
[preview]
|
||||
# Change them to your desired values
|
||||
max_width = 1000
|
||||
max_height = 1000
|
||||
```
|
||||
|
||||
[max-width]: https://yazi-rs.github.io/docs/configuration/yazi/#preview.max_width
|
||||
[max-height]: https://yazi-rs.github.io/docs/configuration/yazi/#preview.max_height
|
||||
|
||||
## License
|
||||
|
||||
This plugin is MIT-licensed. For more information, check the [LICENSE](LICENSE) file.
|
||||
|
||||
@@ -3,23 +3,21 @@
|
||||
|
||||
local function entry(st, job)
|
||||
local R = MANAGER.ratio
|
||||
job = type(job) == "string" and { args = { job } } or job
|
||||
|
||||
st.parent = st.parent and st.parent or R.parent
|
||||
st.current = st.current and st.current or R.current
|
||||
st.preview = st.preview and st.preview or R.preview
|
||||
|
||||
local act = type(job) == "string" and job or job.args[1]
|
||||
if act == "min-parent" then
|
||||
st.parent = st.parent == R.parent and 0 or R.parent
|
||||
elseif act == "min-current" then
|
||||
st.current = st.current == R.current and 0 or R.current
|
||||
elseif act == "min-preview" then
|
||||
st.preview = st.preview == R.preview and 0 or R.preview
|
||||
elseif act == "max-parent" then
|
||||
st.parent = st.parent == 65535 and R.parent or 65535
|
||||
elseif act == "max-current" then
|
||||
st.current = st.current == 65535 and R.current or 65535
|
||||
elseif act == "max-preview" then
|
||||
st.preview = st.preview == 65535 and R.preview or 65535
|
||||
local act, to = string.match(job.args[1] or "", "(.-)-(.+)")
|
||||
if act == "min" then
|
||||
st[to] = st[to] == R[to] and 0 or R[to]
|
||||
elseif act == "max" then
|
||||
local max = st[to] == 65535 and R[to] or 65535
|
||||
st.parent = st.parent == 65535 and R.parent or st.parent
|
||||
st.current = st.current == 65535 and R.current or st.current
|
||||
st.preview = st.preview == 65535 and R.preview or st.preview
|
||||
st[to] = max
|
||||
end
|
||||
|
||||
if not st.old then
|
||||
@@ -37,7 +35,7 @@ local function entry(st, job)
|
||||
end
|
||||
end
|
||||
|
||||
if act == "reset" then
|
||||
if not act then
|
||||
Tab.layout, st.old = st.old, nil
|
||||
st.parent, st.current, st.preview = nil, nil, nil
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user