Compare commits

...

57 Commits

Author SHA1 Message Date
Arijit Basu e0b0466e42
v0.21.8 (#716)
- Added vim-like scrolling as the default scrolling method. Set
`xplr.config.general.paginated_scrolling = false` to disable ~ by
@ElSamhaa & @sayanarijit.
- Added `xplr.config.general.scroll_padding` config option to set the
padding in vim-like scrolling ~ by @ElSamhaa & @sayanarijit.
- Fixed some color rendering issues ~ by @har7an.
- Added feature flag so that xplr can be build with system Lua ~ by
@nekopsykose.
- Fixed `ScrollUpHalf` behavior.
- `xplr.util.lscolor()` won't return nil anymore.
- Arguments passed to the custom dynamic layout Lua function will
include `scrolltop` field.
- Fixed node_type resolution for directories with `.` in their name ~ by
@abhinavnatarajan.
- Dependency updates.
1 month ago
Arijit Basu 805e1594ed
Fix vim scrolling 1 month ago
Arijit Basu 41648ced34 Linting fixes 1 month ago
Arijit Basu 89d7bccce8 Update docs 1 month ago
Arijit Basu e15c1e8a8c
Lock ratatui 1 month ago
Arijit Basu 8afdf9e478
Fix node type resolution (#714)
Fixes #712 and #713.
1 month ago
Abhinav Natarajan a48dae008c Fix node type resolution
Fix node_type for directory with extension
1 month ago
Arijit Basu ad8afa9d38 Update deps 1 month ago
Arijit Basu c2a11059c8
Add yazi an alternative 1 month ago
Arijit Basu 6d7ccce282 Pass scrolltop in custom Lua function 1 month ago
Arijit Basu 90df0a2b5a vimlike_scrolling -> paginated_scrolling
Inspired by @ElSamhaa 's PR https://github.com/sayanarijit/xplr/pull/704
1 month ago
Arijit Basu ce52bcdf94 Revert vimlike scrolling
Use stateful ui widget.
1 month ago
Arijit Basu 6fb0781fe4 xplr.util.lscolor shouldn't return nil
Closes: https://github.com/sayanarijit/xplr/issues/705

Also update xplr version.
1 month ago
Arijit Basu c1bb251fef
Adds Vim-Like Scrolling to XPLR (#704)
- Added through a setting `vimlike_scrolling` which is turned off by
default
- A hard-coded _(for now)_ cushion of `5` lines that allows for
previewing the next lines while scrolling
- A separate struct `ScrollState` with getters and setters for the
`current_focus` field to disallow setting the field without updating the
`last_focus` field
2 months ago
Arijit Basu 976530ba70
Gen docs 2 months ago
Arijit Basu 96da7e1da8
Fix linting 2 months ago
Arijit Basu 96ffe8680b
Fix ScrollUpHalf 2 months ago
Ahmed ElSamhaa 1600ad9a9c Makes the preview cushion dynamic now, and sets an initial value 5 for it 2 months ago
Ahmed ElSamhaa 2a3d056bf1 Clarifies some comments 2 months ago
Ahmed ElSamhaa 91276f6871 Removes an unnecessary condition 2 months ago
Ahmed ElSamhaa 00bd54abe9 Removes unnecessary mut from the calc_skipped_rows fn 2 months ago
Ahmed ElSamhaa 95621af9eb Increases the preview_cushion to 5 like in vim 2 months ago
Ahmed ElSamhaa 5240b3904b Rolls back changes to the open terminal file 2 months ago
Ahmed ElSamhaa a6fb695ff9 Refactors the calc_skipped_rows function to make it even more readable 2 months ago
Ahmed ElSamhaa fd40de26e7 Adds tests for the ScrollState calc_skipped_rows fn 2 months ago
Ahmed ElSamhaa 87805509c5 Refactors the calc_skipped_rows function to make it more readable 2 months ago
Ahmed ElSamhaa 4aa367ca7c Makes the current_focus field private to limit usage to its setters and getters 2 months ago
Ahmed ElSamhaa 01606e0e60 Adds corresponding config setting for vimlike_scrolling 2 months ago
Ahmed ElSamhaa e834242f5d Adds vim-like scrolling 2 months ago
alice 7c6dffc2c6
cargo: allow building with system lua (#703)
useful for distros
2 months ago
har7an d5217f6677
cargo: Revert version update on `ansi-to-tui` (#702)
which causes custom styling to be lost on the currently selected line.
3 months ago
Arijit Basu 0285f0824c
Disable snap build 3 months ago
Arijit Basu a6b19425ae
Release v0.21.6 (#701)
- Snap build
- xplr.util.debug()
- `c` and `m` key bindings for quick copy and move.
- ScrollUpHalf fix
- Dependency updates
3 months ago
Arijit Basu 9db8b2cc19
Upgrade dependencies (#700) 3 months ago
mikoloism 68500f3a8e
[Feat] support `snapcraft` build package to releases (#697)
* build(snap): support snapcraft package

- add `snap/snapcraft.yaml` file

NOTE: under `devmode` until fit to release

* ci(gh-action): support `snapcraft` build and publish to `gh-release` page
3 months ago
Arijit Basu ded2e108bf
Add xplr.util.debug
Also update version
4 months ago
Arijit Basu 6e8f3da971
Quick copy and quick move (#692)
* Quick copy and quick move

- Press `c` to quickly copy the focused or selected path
- Press `m` to quickly move the focused or selected path
4 months ago
Arijit Basu d76a70fed4
Fix ScrollUpHalf 4 months ago
Arijit Basu 16673963aa
Minor fix 4 months ago
Arijit Basu b0ef9a5190
Remove unnecessary config example for now 4 months ago
Arijit Basu b70337708c
Minor fix 4 months ago
Arijit Basu 9127d15494
Use tree-view as example 4 months ago
Arijit Basu 66d9f7e586
Minor doc fix 4 months ago
Arijit Basu eab47a9044
Fix nixpkgs link 4 months ago
Arijit Basu a9e3752f56
Minor doc fix 4 months ago
Arijit Basu 470bea1265
NixOS install instructions 4 months ago
Arijit Basu cc578aaf0a
Add initial pwd to history 5 months ago
Arijit Basu 50e81853fe
Update version 5 months ago
Arijit Basu 414b45e4fd
Sync branch (#687)
* Update awesome-plugins.md

* Update awesome-plugins.md

* Visit deep level branches (#686)

* Visit deep level branches

- Press `)` to pass `NextVisitedDeepBranch`
- Press `(` to pass `LastVisitedDeepBranch`

* Last -> Previous

* Upgrade pkgs

* Clippy fixes

* Fix clippy err

---------

Co-authored-by: Dmitry Savosh <d.savosh@gmail.com>
5 months ago
Arijit Basu 75dabeb283
Add support for function keys upto F24 5 months ago
Arijit Basu 1629398adf
Sync branch (#677)
- Selection indicator in input and logs pane title for people who hide
the selection pane.
7 months ago
Arijit Basu dd8bb74dd4
Update Arch Linux package URL in install.md (#676)
The old URL returns 404 now.
7 months ago
Felix Yan 1dc5eae8fc
Update Arch Linux package URL in install.md
The old URL returns 404 now.
7 months ago
Arijit Basu 484b94a961
Add selection indicator in input and logs panel 7 months ago
Arijit Basu 50d9d1c54b
New plugin (#666) 9 months ago
Dugan Chen c7c3d2d7f6 Link to the one-table-column theme 9 months ago
Arijit Basu 1441275860
Avoid duplicate strip call (#664)
Fixes: https://github.com/sayanarijit/xplr/issues/662
10 months ago

@ -65,6 +65,9 @@ jobs:
run: |
sudo apt-get update --fix-missing
sudo apt-get install -y --no-install-recommends liblua5.1-0-dev libluajit-5.1-dev gcc pkg-config curl git make ca-certificates
sudo apt-get install -y snapd
# sudo snap install snapcraft --classic
# sudo snap install multipass --classic --beta
- if: matrix.build == 'linux-musl'
run: sudo apt-get install -y musl-tools
@ -81,6 +84,13 @@ jobs:
- name: Running cargo build
run: cargo build --locked --release --target ${{ matrix.target }}
# - name: Running snapcraft build
# run: |
# snapcraft
# printf ' [ INFO ] generated <snapcraft> files include:\n'
# command ls -Al | grep "\.snap" | awk '{ print $9 }'
# mv ./*.snap ./xplr.snap
- name: Install gpg secret key
run: |
cat <(echo -e "${{ secrets.GPG_SECRET }}") | gpg --batch --import
@ -91,8 +101,7 @@ jobs:
run: |
cd target/${{ matrix.target }}/release
BINARY_NAME=xplr
strip $BINARY_NAME
RELEASE_NAME=xplr-${{ matrix.build }}
RELEASE_NAME=$BINARY_NAME-${{ matrix.build }}
tar czvf $RELEASE_NAME.tar.gz $BINARY_NAME
shasum -a 256 $RELEASE_NAME.tar.gz > $RELEASE_NAME.sha256
cat <(echo "${{ secrets.GPG_PASS }}") | gpg --pinentry-mode loopback --passphrase-fd 0 --detach-sign --armor $RELEASE_NAME.tar.gz
@ -104,9 +113,15 @@ jobs:
target/${{ matrix.target }}/release/xplr-${{ matrix.build }}.tar.gz
target/${{ matrix.target }}/release/xplr-${{ matrix.build }}.sha256
target/${{ matrix.target }}/release/xplr-${{ matrix.build }}.tar.gz.asc
xplr.snap
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Cleaning snapcraft
# run: |
# command rm --verbose ./*.snap
# snapcraft clean
publish-gpg-signature:
name: Publishing GPG signature
runs-on: ubuntu-latest

915
Cargo.lock generated

File diff suppressed because it is too large Load Diff

@ -8,7 +8,7 @@ path = './benches/criterion.rs'
[package]
name = 'xplr'
version = '0.21.3'
version = '0.21.8'
authors = ['Arijit Basu <hi@arijitbasu.in>']
edition = '2021'
description = 'A hackable, minimal, fast TUI file explorer'
@ -22,29 +22,29 @@ categories = ['command-line-interface', 'command-line-utilities']
include = ['src/**/*', 'docs/en/src/**/*', 'LICENSE', 'README.md']
[dependencies]
libc = "0.2.147"
libc = "0.2.153"
humansize = "2.1.3"
natord = "1.0.9"
anyhow = "1.0.72"
serde_yaml = "0.9.25"
anyhow = "1.0.81"
serde_yaml = "0.9.33"
crossterm = { version = "0.27.0", features = [], default-features = false }
ansi-to-tui = "3.1.0"
regex = "1.9.3"
regex = "1.10.3"
gethostname = "0.4.3"
serde_json = "1.0.104"
path-absolutize = "3.1.0"
which = "4.4.0"
nu-ansi-term = "0.49.0"
serde_json = "1.0.114"
path-absolutize = "3.1.1"
which = "6.0.0"
nu-ansi-term = "0.50.0"
textwrap = "0.16"
snailquote = "0.3.1"
skim = { version = "0.10.4", default-features = false }
time = { version = "0.3.25", features = ["serde", "local-offset", "formatting", "macros"] }
time = { version = "0.3.34", features = ["serde", "local-offset", "formatting", "macros"] }
jf = "0.6.2"
xdg = "2.5.2"
home = "0.5.5"
home = "0.5.9"
[dependencies.lscolors]
version = "0.15.0"
version = "0.17.0"
default-features = false
features = ["nu-ansi-term"]
@ -57,23 +57,23 @@ version = "2.0.4"
default-features = false
[dependencies.tui]
version = "0.22.0"
version = "=0.26.1" # https://github.com/ratatui-org/ratatui/issues/1032
default-features = false
features = ['crossterm', 'serde']
package = 'ratatui'
[dependencies.serde]
version = "1.0.183"
version = "1.0.197"
features = []
default-features = false
[dependencies.indexmap]
version = "2.0.0"
version = "2.2.5"
features = ['serde']
[dependencies.mlua]
version = "0.8.9"
features = ['luajit', 'vendored', 'serialize', 'send']
version = "0.9.6"
features = ['luajit', 'serialize', 'send']
[dependencies.tui-input]
version = "0.8.0"
@ -81,7 +81,7 @@ features = ['serde']
[dev-dependencies]
criterion = "0.5.1"
assert_cmd = "2.0.12"
assert_cmd = "2.0.14"
[profile.release]
lto = true
@ -90,3 +90,5 @@ panic = 'abort'
strip = true
[features]
default = ["vendored-lua"]
vendored-lua = ["mlua/vendored"]

@ -12,18 +12,6 @@ A hackable, minimal, fast TUI file explorer
<img src="https://img.shields.io/crates/v/xplr.svg" />
</a>
<a href="https://github.com/sayanarijit/xplr/commits">
<img src="https://img.shields.io/github/commit-activity/m/sayanarijit/xplr" />
</a>
<a href="https://matrix.to/#/#xplr-pub:matrix.org">
<img alt="Matrix" src="https://img.shields.io/matrix/xplr-pub:matrix.org?color=0DB787&label=matrix&logo=Matrix">
</a>
<a href="https://discord.gg/JmasSPCcz3">
<img src="https://img.shields.io/discord/834369918312382485?color=5865F2&label=discord&logo=Discord" />
</a>
</p>
<p align="center">
@ -38,7 +26,6 @@ https://user-images.githubusercontent.com/11632726/166747867-8a4573f2-cb2f-43a6-
[<a href="https://xplr.dev/en/awesome-hacks">Hacks</a>]
[<a href="https://xplr.dev/en/awesome-plugins">Plugins</a>]
[<a href="https://xplr.dev/en/awesome-integrations">Integrations</a>]
[<a href="https://xplr.dev/en/community">Community</a>]
</h3>
xplr is a terminal UI based file explorer that aims to increase our terminal
@ -60,7 +47,7 @@ integration][15], enabling you to achieve insane terminal productivity.
- [[Article] What is a TUI file explorer & why would you need one? ~ xplr.stck.me](https://xplr.stck.me/post/25252/What-is-a-TUI-file-explorer-why-would-you-need-one)
- [[Article] FOSSPicks - Linux Magazine](https://www.linux-magazine.com/Issues/2022/258/FOSSPicks/(offset)/6)
- [[Article] FOSSPicks - Linux Magazine](<https://www.linux-magazine.com/Issues/2022/258/FOSSPicks/(offset)/6>)
## Packaging

@ -3,8 +3,8 @@
See [install.md](./docs/en/src/install.md#build-from-source)
Note: xplr ships with vendored luajit. If the platform can't compile this,
you need to grep out the feature "vendored" from the "mlua" dependency
specified in [Cargo.toml](./Cargo.toml), and static link luajit yourself.
you need to compile using `--no-default-features` argument to avoid using
vendored luajit, so that you can static link luajit yourself.
# Release

@ -98,6 +98,7 @@ fn draw_benchmark(c: &mut Criterion) {
});
let lua = mlua::Lua::new();
let mut ui = ui::UI::new(&lua);
let mut app =
app::App::create("xplr".into(), None, PWD.into(), &lua, None, [].into())
.expect("failed to create app");
@ -121,7 +122,7 @@ fn draw_benchmark(c: &mut Criterion) {
c.bench_function("draw on terminal", |b| {
b.iter(|| {
terminal.draw(|f| ui::draw(f, &app, &lua)).unwrap();
terminal.draw(|f| ui.draw(f, &app)).unwrap();
})
});

@ -39,8 +39,6 @@
- [Awesome Integrations][20]
- [Alternatives][22]
- [Upgrade Guide][23]
- [Community][24]
- [Contribute][25]
[1]: introduction.md
[2]: quickstart.md
@ -64,8 +62,6 @@
[20]: awesome-integrations.md
[22]: alternatives.md
[23]: upgrade-guide.md
[24]: community.md
[25]: contribute.md
[26]: column-renderer.md
[27]: key-bindings.md
[28]: configure-key-bindings.md

@ -15,6 +15,7 @@ These are the alternative TUI/CLI file managers/explorers you might want to chec
- [clifm][11]
- [clifm][12] (non curses)
- [felix][14]
- [yazi][15]
[add more][13]
@ -30,5 +31,6 @@ These are the alternative TUI/CLI file managers/explorers you might want to chec
[10]: https://git.2f30.org/noice/
[11]: https://github.com/pasqu4le/clifm
[12]: https://github.com/leo-arch/clifm
[13]: community.md
[13]: https://github.com/sayanarijit/xplr/edit/dev/docs/en/src/alternatives.md
[14]: https://github.com/kyoheiu/felix
[15]: https://github.com/sxyazi/yazi

@ -6,7 +6,7 @@ too small or too niche for a full fledge [plugin][2].
Do you have something cool to share?
[Edit this file][3] or [share them here][4] or [let us know][5].
[Edit this file][3] or [share them here][4].
You can try these hacks by writing them to a file, say `hack.lua` and passing
it to xplr with `--extra-config` or `-C`.
@ -526,7 +526,6 @@ xplr.config.modes.builtin.default.key_bindings.on_key.T = {
[2]: plugin.md
[3]: https://github.com/sayanarijit/xplr/edit/main/docs/en/src/awesome-hacks.md
[4]: https://github.com/sayanarijit/xplr/discussions/categories/show-and-tell
[5]: community.md
[6]: https://gifyu.com/image/rGSR
[7]: https://s4.gifyu.com/images/xplr-bookmark.gif
[8]: https://github.com/sayanarijit

@ -49,11 +49,14 @@ of the following plugins work for you, it's very easy to
- [**sayanarijit/material-landscape.xplr**][19] Material Landscape
- [**sayanarijit/material-landscape2.xplr**][20] Material Landscape 2
- [**sayanarijit/zentable.xplr**][31] A clean, distraction free xplr table UI
- [**dy-sh/dysh-style.xplr**][63] Complements xplr theme with icons and highlighting.
- [**prncss-xyz/icons.xplr**][30] An icon theme for xplr.
- [**dtomvan/extra-icons.xplr**][50] Adds more icons to icons.xplr, compatible
with zentable.xplr.
- [**hartan/web-devicons.xplr**][59] Adds [nvim-web-devicons][60] to xplr with
optional coloring
- [**duganchen/one-table-column.xplr**][62] Moves file stats to a status bar.
- [**dy-sh/get-rid-of-index.xplr**][64] Removes the index column.
## Also See:
@ -120,3 +123,6 @@ of the following plugins work for you, it's very easy to
[59]: https://gitlab.com/hartan/web-devicons.xplr
[60]: https://github.com/nvim-tree/nvim-web-devicons
[61]: https://github.com/sayanarijit/tree-view.xplr
[62]: https://github.com/duganchen/one-table-column.xplr
[63]: https://github.com/dy-sh/dysh-style.xplr
[64]: https://github.com/dy-sh/get-rid-of-index.xplr

@ -1,12 +0,0 @@
# Community
Building an active community of awesome people and learning stuff together is
one of my reasons to publish this tool and maintain it. Hence, please feel free
to reach out via your preferred way.
- Real-time chat lovers can join our [**matrix room**][3] or [**discord channel**][1].
- Forum discussion veterans can [**start a new GitHub discussion**][2].
[1]: https://discord.gg/JmasSPCcz3
[2]: https://github.com/sayanarijit/xplr/discussions
[3]: https://matrix.to/#/#xplr-pub:matrix.org

@ -1,32 +0,0 @@
If you like xplr, and want to contribute, that would be really awesome.
You can contribute to this project in the following ways
- Contribute your time and expertise (read [CONTRIBUTING.md][1] for instructions).
- **Developers:** You can help me improve my code, fix things, implement features etc.
- **Repository maintainers:** You can save the users from the pain of managing xplr in their system manually.
- **Code Reviewers:** Teach me your ways of code.
- **Designers:** You can make the logo even more awesome, donate stickers and blog post worthy pictures.
- **Bloggers, YouTubers & broadcasters:** You can help spread the word.
- Contribute by donating or sponsoring me via any of the following ways.
- [GitHub Sponsors][5]
- [Open Collective][2]
- [ko-fi][3]
- [liberapay][6]
- [PayPal][7]
For further queries or concern related to `xplr`, [just ask us][4].
### Backers
<a href="https://opencollective.com/xplr#backer"><img src="https://opencollective.com/xplr/tiers/backer.svg?width=890" /></a>
[1]: https://github.com/sayanarijit/xplr/blob/main/CONTRIBUTING.md
[2]: https://opencollective.com/xplr
[3]: https://ko-fi.com/sayanarijit
[4]: community.md
[5]: https://github.com/sponsors/sayanarijit?o=esb
[6]: https://liberapay.com/sayanarijit
[7]: https://paypal.me/sayanarijit

@ -16,14 +16,17 @@ of [modes][4] and the key mappings for each mode.
| key | remaps | action |
| --------- | ------ | ------------------- |
| ( | | prev deep branch |
| ) | | next deep branch |
| . | | show hidden |
| / | ctrl-f | search |
| : | | action |
| ? | | global help menu |
| ? | f1 | global help menu |
| G | | go to bottom |
| V | ctrl-a | select/unselect all |
| c | | copy to |
| ctrl-d | | duplicate as |
| ctrl-i | | next visited path |
| ctrl-i | tab | next visited path |
| ctrl-n | | next selection |
| ctrl-o | | last visited path |
| ctrl-p | | prev selection |
@ -38,6 +41,7 @@ of [modes][4] and the key mappings for each mode.
| h | left | back |
| k | up | up |
| l | right | enter |
| m | | move to |
| page-down | | scroll down |
| page-up | | scroll up |
| q | | quit |
@ -49,113 +53,157 @@ of [modes][4] and the key mappings for each mode.
| ~ | | go home |
| [0-9] | | input |
### vroot
### go_to_path
| key | remaps | action |
| ----- | ------ | ---------------- |
| enter | | submit |
| f1 | | global help menu |
| tab | | try complete |
### rename
| key | remaps | action |
| ----- | ------ | ---------------- |
| enter | | submit |
| f1 | | global help menu |
| tab | | try complete |
### recover
| key | remaps | action |
| --- | ------ | ---------------- |
| f1 | | global help menu |
### go_to
| key | remaps | action |
| ------ | ------ | ------------ |
| . | | vroot $PWD |
| / | | vroot / |
| ctrl-r | | reset vroot |
| ctrl-u | | unset vroot |
| v | | toggle vroot |
| ~ | | vroot $HOME |
| key | remaps | action |
| --- | ------ | ---------------- |
| f | | follow symlink |
| f1 | | global help menu |
| g | | top |
| i | | initial $PWD |
| p | | path |
| x | | open in gui |
### relative_path_does_match_regex
| key | remaps | action |
| ----- | ------ | ------ |
| enter | | submit |
| key | remaps | action |
| ----- | ------ | ---------------- |
| enter | | submit |
| f1 | | global help menu |
### go_to_path
### action
| key | remaps | action |
| ----- | ------ | ------------ |
| enter | | submit |
| tab | | try complete |
| key | remaps | action |
| ----- | ------ | -------------------- |
| ! | | shell |
| c | | create |
| e | | open in editor |
| f1 | | global help menu |
| l | | logs |
| m | | toggle mouse |
| p | | edit permissions |
| q | | quit options |
| s | | selection operations |
| v | | vroot |
| [0-9] | | go to index |
### duplicate_as
### default
| key | remaps | action |
| ----- | ------ | ------------ |
| enter | | submit |
| tab | | try complete |
| key | remaps | action |
| --------- | ------ | ------------------- |
| ( | | prev deep branch |
| ) | | next deep branch |
| . | | show hidden |
| / | ctrl-f | search |
| : | | action |
| ? | f1 | global help menu |
| G | | go to bottom |
| V | ctrl-a | select/unselect all |
| c | | copy to |
| ctrl-d | | duplicate as |
| ctrl-i | tab | next visited path |
| ctrl-n | | next selection |
| ctrl-o | | last visited path |
| ctrl-p | | prev selection |
| ctrl-r | | refresh screen |
| ctrl-u | | clear selection |
| ctrl-w | | switch layout |
| d | | delete |
| down | j | down |
| enter | | quit with result |
| f | | filter |
| g | | go to |
| h | left | back |
| k | up | up |
| l | right | enter |
| m | | move to |
| page-down | | scroll down |
| page-up | | scroll up |
| q | | quit |
| r | | rename |
| s | | sort |
| space | v | toggle selection |
| { | | scroll up half |
| } | | scroll down half |
| ~ | | go home |
| [0-9] | | input |
### debug_error
| key | remaps | action |
| ----- | ------ | ------------------- |
| enter | | open logs in editor |
| f1 | | global help menu |
| q | | quit |
### selection_ops
### create_directory
| key | remaps | action |
| --- | ------ | --------------- |
| c | | copy here |
| e | | edit selection |
| h | | hardlink here |
| l | | list selection |
| m | | move here |
| s | | softlink here |
| u | | clear selection |
| key | remaps | action |
| ----- | ------ | ---------------- |
| enter | | submit |
| f1 | | global help menu |
| tab | | try complete |
### sort
### selection_ops
| key | remaps | action |
| --------- | ------ | --------------------------------- |
| ! | | reverse sorters |
| C | | by created reverse |
| E | | by canonical extension reverse |
| L | | by last modified reverse |
| M | | by canonical mime essence reverse |
| N | | by node type reverse |
| R | | by relative path reverse |
| S | | by size reverse |
| backspace | | remove last sorter |
| c | | by created |
| ctrl-r | | reset sorters |
| ctrl-u | | clear sorters |
| e | | by canonical extension |
| enter | | submit |
| l | | by last modified |
| m | | by canonical mime essence |
| n | | by node type |
| r | | by relative path |
| s | | by size |
| key | remaps | action |
| --- | ------ | ---------------- |
| c | | copy here |
| e | | edit selection |
| f1 | | global help menu |
| h | | hardlink here |
| l | | list selection |
| m | | move here |
| s | | softlink here |
| u | | clear selection |
### go_to
### relative_path_does_not_match_regex
| key | remaps | action |
| --- | ------ | -------------- |
| f | | follow symlink |
| g | | top |
| i | | initial $PWD |
| p | | path |
| x | | open in gui |
| key | remaps | action |
| ----- | ------ | ---------------- |
| enter | | submit |
| f1 | | global help menu |
### edit_permissions
### create_file
| key | remaps | action |
| ------ | ------ | ------ |
| G | | -group |
| M | | min |
| O | | -other |
| U | | -user |
| ctrl-r | | reset |
| enter | | submit |
| g | | +group |
| m | | max |
| o | | +other |
| u | | +user |
| key | remaps | action |
| ----- | ------ | ---------------- |
| enter | | submit |
| f1 | | global help menu |
| tab | | try complete |
### switch_layout
### quit
| key | remaps | action |
| --- | ------ | -------------------- |
| 1 | | default |
| 2 | | no help menu |
| 3 | | no selection panel |
| 4 | | no help or selection |
| key | remaps | action |
| ----- | ------ | ----------------------- |
| enter | | just quit |
| f | | quit printing focus |
| f1 | | global help menu |
| p | | quit printing pwd |
| r | | quit printing result |
| s | | quit printing selection |
### create
@ -163,20 +211,19 @@ of [modes][4] and the key mappings for each mode.
| --- | ------ | ---------------- |
| d | | create directory |
| f | | create file |
| f1 | | global help menu |
### create_directory
| key | remaps | action |
| ----- | ------ | ------------ |
| enter | | submit |
| tab | | try complete |
### create_file
### vroot
| key | remaps | action |
| ----- | ------ | ------------ |
| enter | | submit |
| tab | | try complete |
| key | remaps | action |
| ------ | ------ | ---------------- |
| . | | vroot $PWD |
| / | | vroot / |
| ctrl-r | | reset vroot |
| ctrl-u | | unset vroot |
| f1 | | global help menu |
| v | | toggle vroot |
| ~ | | vroot $HOME |
### search
@ -191,33 +238,95 @@ of [modes][4] and the key mappings for each mode.
| ctrl-z | | toggle ordering |
| enter | | submit |
| esc | | cancel |
| f1 | | global help menu |
| left | | back |
| right | | enter |
| tab | | toggle selection |
### switch_layout
| key | remaps | action |
| --- | ------ | -------------------- |
| 1 | | default |
| 2 | | no help menu |
| 3 | | no selection panel |
| 4 | | no help or selection |
| f1 | | global help menu |
### sort
| key | remaps | action |
| --------- | ------ | --------------------------------- |
| ! | | reverse sorters |
| C | | by created reverse |
| E | | by canonical extension reverse |
| L | | by last modified reverse |
| M | | by canonical mime essence reverse |
| N | | by node type reverse |
| R | | by relative path reverse |
| S | | by size reverse |
| backspace | | remove last sorter |
| c | | by created |
| ctrl-r | | reset sorters |
| ctrl-u | | clear sorters |
| e | | by canonical extension |
| enter | | submit |
| f1 | | global help menu |
| l | | by last modified |
| m | | by canonical mime essence |
| n | | by node type |
| r | | by relative path |
| s | | by size |
### number
| key | remaps | action |
| ----- | ------ | -------- |
| down | j | to down |
| enter | | to index |
| k | up | to up |
| [0-9] | | input |
| key | remaps | action |
| ----- | ------ | ---------------- |
| down | j | to down |
| enter | | to index |
| f1 | | global help menu |
| k | up | to up |
| [0-9] | | input |
### action
### copy_to
| key | remaps | action |
| ----- | ------ | -------------------- |
| ! | | shell |
| c | | create |
| e | | open in editor |
| l | | logs |
| m | | toggle mouse |
| p | | edit permissions |
| q | | quit options |
| s | | selection operations |
| v | | vroot |
| [0-9] | | go to index |
| key | remaps | action |
| ----- | ------ | ---------------- |
| enter | | submit |
| f1 | | global help menu |
| tab | | try complete |
### edit_permissions
| key | remaps | action |
| ------ | ------ | ---------------- |
| G | | -group |
| M | | min |
| O | | -other |
| U | | -user |
| ctrl-r | | reset |
| enter | | submit |
| f1 | | global help menu |
| g | | +group |
| m | | max |
| o | | +other |
| u | | +user |
### delete
| key | remaps | action |
| --- | ------ | ---------------- |
| D | | force delete |
| d | | delete |
| f1 | | global help menu |
### move_to
| key | remaps | action |
| ----- | ------ | ---------------- |
| enter | | submit |
| f1 | | global help menu |
| tab | | try complete |
### filter
@ -227,39 +336,13 @@ of [modes][4] and the key mappings for each mode.
| backspace | | remove last filter |
| ctrl-r | | reset filters |
| ctrl-u | | clear filters |
| f1 | | global help menu |
| r | | relative path does match regex |
### rename
| key | remaps | action |
| ----- | ------ | ------------ |
| enter | | submit |
| tab | | try complete |
### relative_path_does_not_match_regex
| key | remaps | action |
| ----- | ------ | ------ |
| enter | | submit |
### quit
| key | remaps | action |
| ----- | ------ | ----------------------- |
| enter | | just quit |
| f | | quit printing focus |
| p | | quit printing pwd |
| r | | quit printing result |
| s | | quit printing selection |
### recover
| key | remaps | action |
| --- | ------ | ------ |
### delete
### duplicate_as
| key | remaps | action |
| --- | ------ | ------------ |
| D | | force delete |
| d | | delete |
| key | remaps | action |
| ----- | ------ | ---------------- |
| enter | | submit |
| f1 | | global help menu |
| tab | | try complete |

@ -42,6 +42,19 @@ Set it to `true` if you want to hide all remaps in the help menu.
Type: boolean
#### xplr.config.general.paginated_scrolling
Set it to `true` if you want paginated scrolling.
Type: boolean
#### xplr.config.general.scroll_padding
Set the padding value to the scroll area.
Only applicable when `xplr.config.general.paginated_scrolling = false`.
Type: boolean
#### xplr.config.general.enforce_bounded_index_navigation
Set it to `true` if you want the cursor to stay in the same position when

@ -41,6 +41,48 @@ repositories:
nix-env -f https://github.com/NixOS/nixpkgs/tarball/master -iA xplr
```
Or
```nix
# configuration.nix or darwin-configuration.nix
environment.systemPackages = with nixpkgs; [
xplr
# ...
];
```
#### [Home Manager][30]
```nix
# home.nix
home.packages = with nixpkgs; [
xplr
# ...
];
```
Or
```nix
# home.nix
programs.xplr = {
enable = true;
# Optional params:
plugins = {
tree-view = fetchFromGitHub {
owner = "sayanarijit";
repo = "tree-view.xplr";
};
local-plugin = "/home/user/.config/xplr/plugins/local-plugin";
};
extraConfig = ''
require("tree-view").setup()
require("local-plugin").setup()
'';
};
```
### Arch Linux
(same for Manjaro Linux)
@ -196,33 +238,16 @@ cargo build --locked --release --bin xplr
sudo cp target/release/xplr /usr/local/bin/
```
## Android
### [Termux][24]
```bash
pkg install rust make binutils
cargo install --locked xplr
# Run
~/.cargo/bin/xplr
```
> Please note that xplr isn't heavily tested on Termux, hence things might need
> a little tweaking and fixing for a smooth user experience.
![termux demo][23]
[1]: #direct-download
[2]: #from-cratesio
[3]: #build-from-source
[4]: https://github.com/sayanarijit/xplr/watchers
[5]: https://repology.org/badge/vertical-allrepos/xplr.svg
[6]: https://repology.org/project/xplr/versions
[7]: https://archlinux.org/packages/community/x86_64/xplr
[7]: https://archlinux.org/packages/extra/x86_64/xplr
[8]: https://aur.archlinux.org/packages/?O=0&SeB=n&K=xplr&outdated=&SB=n&SO=a&PP=50&do_Search=Go
[9]: https://github.com/shubham-cpp/void-pkg-templates
[10]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/file-managers/xplr/default.nix
[10]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/xp/xplr/package.nix
[11]: https://ports.macports.org/port/xplr
[12]: https://formulae.brew.sh/formula/xplr
[13]: https://cgit.freebsd.org/ports/plain/misc/xplr/
@ -236,9 +261,9 @@ cargo install --locked xplr
[21]: https://www.gnu.org/software/make/
[22]: https://git-scm.com/
[23]: https://github.com/sayanarijit/xplr/assets/11632726/3b61e8c8-76f0-48e8-8734-50e9e7e495b7
[24]: https://termux.dev/
[25]: https://gifyu.com/image/tF2D
[26]: https://github.com/sayanarijit/xplr/releases/latest/download/xplr-linux-musl.tar.gz
[27]: https://pkgs.alpinelinux.org/packages?name=xplr
[28]: https://gpo.zugaina.org/Overlays/guru/app-misc/xplr
[29]: https://formulae.brew.sh/formula/coreutils
[30]: https://github.com/nix-community/home-manager/blob/master/modules/programs/xplr.nix

@ -84,8 +84,6 @@ Some of the coolest features xplr provide beside the basic stuff:
(`:` `q` `s`).
- Quit with failure (`ctrl-c`).
**Q.** What features should be added here? [let us know][20].
[1]: layouts.md
[2]: configure-key-bindings.md
[3]: awesome-plugins.md
@ -105,6 +103,5 @@ Some of the coolest features xplr provide beside the basic stuff:
[17]: node_types.md
[18]: https://github.com/sayanarijit/xplr/blob/main/src/init.lua
[19]: messages.md#startfifo
[20]: community.md
[21]: messages.md#virtual-root
[22]: configuration.md#hooks

@ -495,6 +495,7 @@ It contains the following information:
- [layout_size][37]
- [screen_size][37]
- [scrolltop][57]
- [app][38]
### Size
@ -508,6 +509,12 @@ It contains the following information:
Every field is of integer type.
### scrolltop
Type: integer
The start index of the visible nodes in the table.
### app
This is a lightweight version of the [Lua Context][39]. In this context, the
@ -587,3 +594,4 @@ Hence, only the following fields are available.
[54]: borders.md#border-type
[55]: #customlayout
[56]: sum-type.md
[57]: #scrolltop

@ -320,6 +320,24 @@ Example:
- Lua: `"NextVisitedPath"`
- YAML: `NextVisitedPath`
#### PreviousVisitedDeepBranch
Go to the previous deep level branch.
Example:
- Lua: `"PreviousVisitedDeepBranch"`
- YAML: `PreviousVisitedDeepBranch`
#### NextVisitedDeepBranch
Go to the next deep level branch.
Example:
- Lua: `"NextVisitedDeepBranch"`
- YAML: `NextVisitedDeepBranch`
#### FollowSymlink
Follow the symlink under focus to its actual location.

@ -35,6 +35,18 @@ The builtin go to path mode.
Type: [Mode](https://xplr.dev/en/mode)
#### xplr.config.modes.builtin.move_to
The builtin move_to mode.
Type: [Mode](https://xplr.dev/en/mode)
#### xplr.config.modes.builtin.copy_to
The builtin copy_to mode.
Type: [Mode](https://xplr.dev/en/mode)
#### xplr.config.modes.builtin.selection_ops
The builtin selection ops mode.

@ -90,13 +90,7 @@ And then we'd go on documenting whatever `Layout Config` is.
So, there you go. This is exactly what sum types are - glorified enums that can
have nested types in each branch.
---
If you're still confused about something, or if you found an error in this
explanation, feel free to [discuss together][5].
[1]: https://en.wikipedia.org/wiki/Tagged_union
[2]: layout.md
[3]: message.md
[4]: style.md#color
[5]: community.md

@ -45,7 +45,7 @@ compatibility.
### Instructions
#### [v0.20.2][48] -> [v0.21.3][49]
#### [v0.20.2][48] -> [v0.21.8][49]
- Some plugins might stop rendering colors. Wait for them to update.
- Rename `xplr.config.general.sort_and_filter_ui.search_identifier` to
@ -119,6 +119,21 @@ compatibility.
- Executables will me marked with the mime type: `application/x-executable`.
- macOS legacy coreutils will be generally supported, but please update it.
- Since v0.21.2 you can use the on_selection_change hook.
- Since v0.21.4 you can use function keys upto F24 and the following new
messages:
- NextVisitedDeepBranch (bound to `)` key)
- PreviousVisitedDeepBranch (bound to `(` key)
- Since v0.21.6:
- You can use `c` and `m` keys in default mode to quickly copy
and move focused or selected files, without having to change directory.
- Use `xplr.util.debug()` to debug lua values.
- Since v0.21.8:
- Scroll behavior will default to vim-like continuous scrolling. You can set
`xplr.config.general.paginated_scrolling = true` to revert back to the
paginated scrolling.
- Set `xplr.config.general.scroll_padding` to customize the scroll padding.
- The calculated `scrolltop` value will be passed as part of the
`Content Rendeder Argument` in `Dynamic` layout renderer functions.
Thanks to @noahmayr for contributing to a major part of this release.
@ -206,8 +221,6 @@ Thanks to @noahmayr for contributing to a major part of this release.
- ScrollUpHalf ---- {
- ScrollDownHalf -- }
<sub>Like this project so far? **[Please consider contributing][5]**.</sub>
#### [v0.17.6][45] -> [v0.18.0][46]
- Key binding `f` `r` and `f` `R` will now filter using regex.
@ -473,7 +486,6 @@ Else do the following:
[2]: https://github.com/sayanarijit/xplr/releases/tag/v0.13.7
[3]: https://github.com/sayanarijit/xplr/releases/tag/v0.14.7
[4]: https://github.com/sayanarijit/xplr/pull/229#issue-662426960
[5]: contribute.md
[6]: https://github.com/sayanarijit/xplr/releases/tag/v0.12.1
[7]: https://docs.rs/xplr/latest/xplr/app/enum.ExternalMsg.html#variant.CallLua
[8]: https://docs.rs/xplr/latest/xplr/app/enum.ExternalMsg.html#variant.CallLuaSilently
@ -517,5 +529,5 @@ Else do the following:
[46]: https://github.com/sayanarijit/xplr/releases/tag/v0.18.0
[47]: https://github.com/sayanarijit/xplr/releases/tag/v0.19.4
[48]: https://github.com/sayanarijit/xplr/releases/tag/v0.20.2
[49]: https://github.com/sayanarijit/xplr/releases/tag/v0.21.3
[49]: https://github.com/sayanarijit/xplr/releases/tag/v0.21.8
[50]: https://github.com/lotabout/skim#search-syntax

@ -70,8 +70,6 @@ Visit [Awesome Plugins][5] for xplr plugin examples.
- [Tip: A list of hacks yet to make it as Lua plugins][15]
- [Tip: Some UI and themeing tips][12]
- [Tip: A list of handy utility functions][13]
- [Tip: Share tips and tricks working with Lua][14]
- [Tutorial: Adding a New Mode][6]
- [Example: Using Environment Variables and Pipes][7]
- [Example: Using Lua Function Calls][8]
@ -92,7 +90,5 @@ Visit [Awesome Plugins][5] for xplr plugin examples.
[10]: column-renderer.md#example-customizing-table-renderer
[11]: layout.md#example-render-a-custom-dynamic-table
[12]: https://github.com/sayanarijit/xplr/discussions/274
[13]: https://github.com/sayanarijit/xplr/discussions/273
[14]: https://github.com/sayanarijit/xplr/discussions/250
[15]: https://github.com/sayanarijit/xplr/wiki/Hacks
[15]: awesome-hacks.md
[16]: https://github.com/sayanarijit/xplr/discussions/529#discussioncomment-4073734

@ -11,6 +11,23 @@ xplr.util.version()
-- { major = 0, minor = 0, patch = 0 }
```
### xplr.util.debug
Print the given value to the console, and return it as a string.
Useful for debugging.
Type: function( value ) -> string
Example:
```lua
xplr.util.debug({ foo = "bar", bar = function() end })
-- {
-- ["bar"] = function: 0x55e5cebdeae0,
-- ["foo"] = "bar",
-- }
```
### xplr.util.clone
Clone/deepcopy a Lua value. Doesn't work with functions.
@ -380,7 +397,7 @@ xplr.util.to_yaml({ foo = "bar" })
Get a [Style][3] object for the given path based on the LS_COLORS
environment variable.
Type: function( path:string ) -> [Style][3]|nil
Type: function( path:string ) -> [Style][3]
Example:

@ -0,0 +1,11 @@
v="0.4.37"
curl -L https://github.com/rust-lang/mdBook/releases/download/v$v/mdbook-v$v-x86_64-unknown-linux-gnu.tar.gz -o mdbook.tgz \
&& tar xzvf mdbook.tgz \
&& ./mdbook build docs/en \
&& mkdir dist \
&& mv -v docs/en/book/html dist/en \
&& mv -v assets dist \
&& mv -v docs/landing/index.html docs/landing/css docs/landing/js dist \
&& rm -v mdbook \
&& rm -v mdbook.tgz

@ -2,11 +2,11 @@
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1689422397,
"narHash": "sha256-fnopownlSBGTBYxGdTdUPM215yG/UEEj3wgheBLIbHs=",
"lastModified": 1704262187,
"narHash": "sha256-N4j9qghlp/Eb3Z11WF7Cb9U91AXwpascUbLH7YKMcLc=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "45ae0efbbce2aada6d5e8de6ace0c803b08ac9c7",
"rev": "65f0d241783c94a08e4c9a3870736fc8854dd520",
"type": "github"
},
"original": {

@ -0,0 +1,26 @@
name: xplr
version: git
summary: A hackable, minimal, fast TUI file explorer
description: |
xplr is a terminal UI based file explorer
that aims to increase our terminal productivity by being a flexible,
interactive orchestrator for the ever growing awesome command-line
utilities that work with the file-system.
source-code: https://github.com/sayanarijit/xplr
issues: https://github.com/sayanarijit/xplr/issues
website: https://xplr.dev/
base: core20
grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots
parts:
xplr:
plugin: rust
source: .
apps:
xplr:
command: bin/xplr

@ -135,6 +135,10 @@ impl History {
self
}
fn peek(&self) -> Option<&String> {
self.paths.get(self.loc)
}
fn push(mut self, path: String) -> Self {
if self.peek() != Some(&path) {
self.paths = self.paths.into_iter().take(self.loc + 1).collect();
@ -167,8 +171,47 @@ impl History {
self.cleanup()
}
fn peek(&self) -> Option<&String> {
self.paths.get(self.loc)
fn _is_deepest_dir(&self, path: &str) -> bool {
return !self
.paths
.iter()
.any(|p| p.ends_with('/') && p.starts_with(path) && path != p);
}
fn _uniq_deep_dirs(&self) -> IndexSet<String> {
self.paths
.clone()
.into_iter()
.filter(|p| p.ends_with('/') && self._is_deepest_dir(p))
.collect::<IndexSet<String>>()
}
fn visit_next_deep_branch(self, pwd: &str) -> Self {
let uniq_deep_dirs = self._uniq_deep_dirs();
if let Some(path) = uniq_deep_dirs
.iter()
.skip_while(|p| p.trim_end_matches('/') != pwd)
.nth(1)
{
self.push(path.to_string())
} else {
self
}
}
fn visit_previous_deep_branch(self, pwd: &str) -> Self {
let uniq_deep_dirs = self._uniq_deep_dirs();
if let Some(path) = uniq_deep_dirs
.iter()
.rev()
.skip_while(|p| p.trim_end_matches('/') != pwd)
.nth(1)
{
self.push(path.to_string())
} else {
self
}
}
}
@ -271,9 +314,7 @@ impl App {
}
};
let config_files = config_file
.into_iter()
.chain(extra_config_files.into_iter());
let config_files = config_file.into_iter().chain(extra_config_files);
let mut load_errs = vec![];
for config_file in config_files {
@ -294,12 +335,12 @@ impl App {
&config
.general
.initial_mode
.to_owned()
.clone()
.unwrap_or_else(|| "default".into()),
) {
Some(m) => m.clone().sanitized(
config.general.read_only,
config.general.global_key_bindings.to_owned(),
config.general.global_key_bindings.clone(),
),
None => {
bail!("'default' mode is missing")
@ -310,7 +351,7 @@ impl App {
&config
.general
.initial_layout
.to_owned()
.clone()
.unwrap_or_else(|| "default".into()),
) {
Some(l) => l.clone(),
@ -346,7 +387,7 @@ impl App {
}
if let Some(sorters) = &config.general.initial_sorting {
explorer_config.sorters = sorters.clone();
explorer_config.sorters.clone_from(sorters);
};
let hostname = gethostname().to_string_lossy().to_string();
@ -373,6 +414,12 @@ impl App {
prompt: config.general.prompt.format.clone().unwrap_or_default(),
};
let hist = if &pwd == "/" {
pwd.clone()
} else {
format!("{0}/", &pwd)
};
let mut app = Self {
bin,
version: VERSION.to_string(),
@ -394,7 +441,7 @@ impl App {
explorer_config,
logs: Default::default(),
logs_hidden: Default::default(),
history: Default::default(),
history: History::default().push(hist),
last_modes: Default::default(),
hostname,
hooks,
@ -505,6 +552,8 @@ impl App {
Back => self.back(),
LastVisitedPath => self.last_visited_path(),
NextVisitedPath => self.next_visited_path(),
PreviousVisitedDeepBranch => self.previous_visited_deep_branch(),
NextVisitedDeepBranch => self.next_visited_deep_branch(),
FollowSymlink => self.follow_symlink(),
SetVroot(p) => self.set_vroot(&p),
UnsetVroot => self.unset_vroot(),
@ -771,7 +820,6 @@ impl App {
fn focus_previous(mut self) -> Result<Self> {
let bounded = self.config.general.enforce_bounded_index_navigation;
if let Some(dir) = self.directory_buffer_mut() {
dir.focus = if dir.focus == 0 {
if bounded {
@ -856,7 +904,6 @@ impl App {
fn focus_next(mut self) -> Result<Self> {
let bounded = self.config.general.enforce_bounded_index_navigation;
if let Some(dir) = self.directory_buffer_mut() {
dir.focus = if (dir.focus + 1) == dir.total {
if bounded {
@ -868,6 +915,7 @@ impl App {
dir.focus + 1
}
};
Ok(self)
}
@ -946,7 +994,7 @@ impl App {
fn follow_symlink(self) -> Result<Self> {
if let Some(pth) = self
.focused_node()
.and_then(|n| n.symlink.to_owned().map(|s| s.absolute_path))
.and_then(|n| n.symlink.clone().map(|s| s.absolute_path))
{
self.focus_path(&pth, true)
} else {
@ -1082,6 +1130,24 @@ impl App {
}
}
fn previous_visited_deep_branch(mut self) -> Result<Self> {
self.history = self.history.visit_previous_deep_branch(&self.pwd);
if let Some(path) = self.history.peek().cloned() {
self.change_directory(path.trim_end_matches('/'), false)
} else {
Ok(self)
}
}
fn next_visited_deep_branch(mut self) -> Result<Self> {
self.history = self.history.visit_next_deep_branch(&self.pwd);
if let Some(path) = self.history.peek().cloned() {
self.change_directory(path.trim_end_matches('/'), false)
} else {
Ok(self)
}
}
fn set_input_prompt(mut self, p: String) -> Result<Self> {
self.input.prompt = p;
Ok(self)
@ -1234,7 +1300,7 @@ impl App {
}
pub fn scroll_up_half(mut self) -> Result<Self> {
self.msg_out.push_back(MsgOut::ScrollUp);
self.msg_out.push_back(MsgOut::ScrollUpHalf);
Ok(self)
}
@ -1315,7 +1381,7 @@ impl App {
self = self.push_mode();
self.mode = mode.sanitized(
self.config.general.read_only,
self.config.general.global_key_bindings.to_owned(),
self.config.general.global_key_bindings.clone(),
);
// Hooks
@ -1340,7 +1406,7 @@ impl App {
self = self.push_mode();
self.mode = mode.sanitized(
self.config.general.read_only,
self.config.general.global_key_bindings.to_owned(),
self.config.general.global_key_bindings.clone(),
);
// Hooks
@ -1367,7 +1433,7 @@ impl App {
fn switch_layout_builtin(mut self, layout: &str) -> Result<Self> {
if let Some(l) = self.config.layouts.builtin.get(layout) {
self.layout = l.to_owned();
self.layout = l.clone();
// Hooks
if !self.hooks.on_layout_switch.is_empty() {
@ -1383,7 +1449,7 @@ impl App {
fn switch_layout_custom(mut self, layout: &str) -> Result<Self> {
if let Some(l) = self.config.layouts.get_custom(layout) {
self.layout = l.to_owned();
self.layout = l.clone();
// Hooks
if !self.hooks.on_layout_switch.is_empty() {
@ -1508,7 +1574,7 @@ impl App {
pub fn select(mut self) -> Result<Self> {
let count = self.selection.len();
if let Some(n) = self.focused_node().map(|n| n.to_owned()) {
if let Some(n) = self.focused_node().cloned() {
self.selection.insert(n);
}
@ -1563,7 +1629,7 @@ impl App {
pub fn un_select(mut self) -> Result<Self> {
let count = self.selection.len();
if let Some(n) = self.focused_node().map(|n| n.to_owned()) {
if let Some(n) = self.focused_node().cloned() {
self.selection
.retain(|s| s.absolute_path != n.absolute_path);
}
@ -1737,7 +1803,7 @@ impl App {
.config
.general
.initial_sorting
.to_owned()
.clone()
.unwrap_or_default();
Ok(self)
}
@ -2039,7 +2105,7 @@ impl App {
let read_only = self.config.general.read_only;
let global_kb = &self.config.general.global_key_bindings;
let modes = builtin.into_iter().chain(custom.into_iter());
let modes = builtin.into_iter().chain(custom);
std::iter::once((self.mode.name.clone(), self.mode.clone()))
.chain(modes)

@ -185,7 +185,7 @@ pub fn pipe_msg_in(args: Vec<String>) -> Result<()> {
.cloned()
.context("failed to detect delimmiter")?;
msg.push(delimiter.try_into()?);
msg.push(delimiter.into());
File::options()
.append(true)
.open(&path)?

@ -7,9 +7,8 @@ use crate::ui::block;
use crate::ui::string_to_text;
use crate::ui::Constraint;
use crate::ui::ContentRendererArg;
use mlua::Lua;
use crate::ui::UI;
use serde::{Deserialize, Serialize};
use tui::backend::Backend;
use tui::layout::Constraint as TuiConstraint;
use tui::layout::Rect as TuiRect;
use tui::widgets::Cell;
@ -60,13 +59,12 @@ pub struct CustomContent {
}
/// A cursed function from crate::ui.
pub fn draw_custom_content<B: Backend>(
f: &mut Frame<B>,
screen_size: TuiRect,
pub fn draw_custom_content(
ui: &mut UI,
f: &mut Frame,
layout_size: TuiRect,
app: &app::App,
content: CustomContent,
lua: &Lua,
) {
let config = app.config.general.panel_ui.default.clone();
let title = content.title;
@ -86,12 +84,13 @@ pub fn draw_custom_content<B: Backend>(
let ctx = ContentRendererArg {
app: app.to_lua_ctx_light(),
layout_size: layout_size.into(),
screen_size: screen_size.into(),
screen_size: ui.screen_size.into(),
scrolltop: ui.scrolltop as u16,
};
let render = lua::serialize(lua, &ctx)
let render = lua::serialize(ui.lua, &ctx)
.map(|arg| {
lua::call(lua, &render, arg).unwrap_or_else(|e| format!("{e:?}"))
lua::call(ui.lua, &render, arg).unwrap_or_else(|e| format!("{e:?}"))
})
.unwrap_or_else(|e| e.to_string());
@ -122,12 +121,13 @@ pub fn draw_custom_content<B: Backend>(
let ctx = ContentRendererArg {
app: app.to_lua_ctx_light(),
layout_size: layout_size.into(),
screen_size: screen_size.into(),
screen_size: ui.screen_size.into(),
scrolltop: ui.scrolltop as u16,
};
let items = lua::serialize(lua, &ctx)
let items = lua::serialize(ui.lua, &ctx)
.map(|arg| {
lua::call(lua, &render, arg)
lua::call(ui.lua, &render, arg)
.unwrap_or_else(|e| vec![format!("{e:?}")])
})
.unwrap_or_else(|e| vec![e.to_string()])
@ -162,11 +162,10 @@ pub fn draw_custom_content<B: Backend>(
let widths = widths
.into_iter()
.map(|w| w.to_tui(screen_size, layout_size))
.map(|w| w.to_tui(ui.screen_size, layout_size))
.collect::<Vec<TuiConstraint>>();
let content = Table::new(rows)
.widths(&widths)
let content = Table::new(rows, widths)
.column_spacing(col_spacing.unwrap_or(1))
.block(block(
config,
@ -184,12 +183,13 @@ pub fn draw_custom_content<B: Backend>(
let ctx = ContentRendererArg {
app: app.to_lua_ctx_light(),
layout_size: layout_size.into(),
screen_size: screen_size.into(),
screen_size: ui.screen_size.into(),
scrolltop: ui.scrolltop as u16,
};
let rows = lua::serialize(lua, &ctx)
let rows = lua::serialize(ui.lua, &ctx)
.map(|arg| {
lua::call(lua, &render, arg)
lua::call(ui.lua, &render, arg)
.unwrap_or_else(|e| vec![vec![format!("{e:?}")]])
})
.unwrap_or_else(|e| vec![vec![e.to_string()]])
@ -206,10 +206,10 @@ pub fn draw_custom_content<B: Backend>(
let widths = widths
.into_iter()
.map(|w| w.to_tui(screen_size, layout_size))
.map(|w| w.to_tui(ui.screen_size, layout_size))
.collect::<Vec<TuiConstraint>>();
let mut content = Table::new(rows).widths(&widths).block(block(
let mut content = Table::new(rows, &widths).block(block(
config,
title.map(|t| format!(" {t} ")).unwrap_or_default(),
));

@ -55,7 +55,7 @@ pub struct NodeTypeConfig {
impl NodeTypeConfig {
pub fn extend(mut self, other: &Self) -> Self {
self.style = self.style.extend(&other.style);
self.meta.extend(other.meta.to_owned());
self.meta.extend(other.meta.clone());
self
}
}
@ -85,11 +85,11 @@ pub struct NodeTypesConfig {
impl NodeTypesConfig {
pub fn get(&self, node: &Node) -> NodeTypeConfig {
let mut node_type = if node.is_symlink {
self.symlink.to_owned()
self.symlink.clone()
} else if node.is_dir {
self.directory.to_owned()
self.directory.clone()
} else {
self.file.to_owned()
self.file.clone()
};
let mut me = node.mime_essence.splitn(2, '/');
@ -104,7 +104,7 @@ impl NodeTypesConfig {
node_type = node_type.extend(conf);
}
if let Some(conf) = self.extension.get(&node.extension) {
if let (Some(conf), false) = (self.extension.get(&node.extension), node.is_dir) {
node_type = node_type.extend(conf);
}
@ -141,7 +141,7 @@ pub struct UiElement {
impl UiElement {
pub fn extend(mut self, other: &Self) -> Self {
self.format = other.format.to_owned().or(self.format);
self.format = other.format.clone().or(self.format);
self.style = self.style.extend(&other.style);
self
}
@ -353,6 +353,12 @@ pub struct GeneralConfig {
#[serde(default)]
pub global_key_bindings: KeyBindings,
#[serde(default)]
pub paginated_scrolling: bool,
#[serde(default)]
pub scroll_padding: usize,
}
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
@ -638,8 +644,8 @@ impl PanelUiConfig {
pub fn extend(mut self, other: &Self) -> Self {
self.title = self.title.extend(&other.title);
self.style = self.style.extend(&other.style);
self.borders = other.borders.to_owned().or(self.borders);
self.border_type = other.border_type.to_owned().or(self.border_type);
self.borders = other.borders.clone().or(self.borders);
self.border_type = other.border_type.or(self.border_type);
self.border_style = self.border_style.extend(&other.border_style);
self
}

@ -18,8 +18,9 @@ pub fn config_dir() -> Option<PathBuf> {
pub fn runtime_dir() -> PathBuf {
let Some(dir) = BASE_DIRS
.as_ref()
.and_then(|base| base.get_runtime_directory().ok()) else {
.and_then(|base| base.get_runtime_directory().ok())
else {
return env::temp_dir();
};
dir.to_owned()
dir.clone()
}

@ -91,6 +91,17 @@ xplr.config.general.enable_recover_mode = false
-- Type: boolean
xplr.config.general.hide_remaps_in_help_menu = false
-- Set it to `true` if you want paginated scrolling.
--
-- Type: boolean
xplr.config.general.paginated_scrolling = false
-- Set the padding value to the scroll area.
-- Only applicable when `xplr.config.general.paginated_scrolling = false`.
--
-- Type: boolean
xplr.config.general.scroll_padding = 5
-- Set it to `true` if you want the cursor to stay in the same position when
-- the focus is on the first path and you navigate to the previous path
-- (by pressing `up`/`k`), or when the focus is on the last path and you
@ -157,11 +168,11 @@ xplr.config.general.logs.error.style = { fg = "Red" }
-- * format: nullable string
-- * style: [Style](https://xplr.dev/en/style)
xplr.config.general.table.header.cols = {
{ format = " index", style = {} },
{ format = " index", style = {} },
{ format = "╭─── path", style = {} },
{ format = "perm", style = {} },
{ format = "size", style = {} },
{ format = "modified", style = {} },
{ format = "perm", style = {} },
{ format = "size", style = {} },
{ format = "modified", style = {} },
}
-- Style of the table header.
@ -478,7 +489,7 @@ xplr.config.general.sort_and_filter_ui.search_identifiers = {
--
-- Type: nullable string
xplr.config.general.sort_and_filter_ui.search_direction_identifiers.ordered.format =
""
""
-- The shape of unordered indicator for search ordering identifiers in Sort & filter panel.
--
@ -676,7 +687,7 @@ xplr.config.general.panel_ui.sort_and_filter.border_style = {}
-- Type: nullable list of [Node Sorter](https://xplr.dev/en/sorting#node-sorter-applicable)
xplr.config.general.initial_sorting = {
{ sorter = "ByCanonicalIsDir", reverse = true },
{ sorter = "ByIRelativePath", reverse = false },
{ sorter = "ByIRelativePath", reverse = false },
}
-- The name of one of the modes to use when xplr loads.
@ -1123,6 +1134,18 @@ xplr.config.modes.builtin.default = {
"LastVisitedPath",
},
},
[")"] = {
help = "next deep branch",
messages = {
"NextVisitedDeepBranch",
},
},
["("] = {
help = "prev deep branch",
messages = {
"PreviousVisitedDeepBranch",
},
},
["ctrl-r"] = {
help = "refresh screen",
messages = {
@ -1284,6 +1307,22 @@ xplr.config.modes.builtin.default = {
"FocusPreviousSelection",
},
},
["m"] = {
help = "move to",
messages = {
"PopMode",
{ SwitchModeBuiltin = "move_to" },
{ SetInputBuffer = "" },
},
},
["c"] = {
help = "copy to",
messages = {
"PopMode",
{ SwitchModeBuiltin = "copy_to" },
{ SetInputBuffer = "" },
},
},
},
on_number = {
help = "input",
@ -1297,23 +1336,23 @@ xplr.config.modes.builtin.default = {
}
xplr.config.modes.builtin.default.key_bindings.on_key["v"] =
xplr.config.modes.builtin.default.key_bindings.on_key["space"]
xplr.config.modes.builtin.default.key_bindings.on_key["space"]
xplr.config.modes.builtin.default.key_bindings.on_key["V"] =
xplr.config.modes.builtin.default.key_bindings.on_key["ctrl-a"]
xplr.config.modes.builtin.default.key_bindings.on_key["ctrl-a"]
xplr.config.modes.builtin.default.key_bindings.on_key["/"] =
xplr.config.modes.builtin.default.key_bindings.on_key["ctrl-f"]
xplr.config.modes.builtin.default.key_bindings.on_key["ctrl-f"]
xplr.config.modes.builtin.default.key_bindings.on_key["h"] =
xplr.config.modes.builtin.default.key_bindings.on_key["left"]
xplr.config.modes.builtin.default.key_bindings.on_key["left"]
xplr.config.modes.builtin.default.key_bindings.on_key["j"] =
xplr.config.modes.builtin.default.key_bindings.on_key["down"]
xplr.config.modes.builtin.default.key_bindings.on_key["down"]
xplr.config.modes.builtin.default.key_bindings.on_key["k"] =
xplr.config.modes.builtin.default.key_bindings.on_key["up"]
xplr.config.modes.builtin.default.key_bindings.on_key["up"]
xplr.config.modes.builtin.default.key_bindings.on_key["l"] =
xplr.config.modes.builtin.default.key_bindings.on_key["right"]
xplr.config.modes.builtin.default.key_bindings.on_key["right"]
xplr.config.modes.builtin.default.key_bindings.on_key["tab"] =
xplr.config.modes.builtin.default.key_bindings.on_key["ctrl-i"] -- compatibility workaround
xplr.config.modes.builtin.default.key_bindings.on_key["ctrl-i"] -- compatibility workaround
xplr.config.modes.builtin.default.key_bindings.on_key["?"] =
xplr.config.general.global_key_bindings.on_key["f1"]
xplr.config.general.global_key_bindings.on_key["f1"]
-- The builtin debug error mode.
--
@ -1448,6 +1487,148 @@ xplr.config.modes.builtin.go_to_path = {
},
}
-- The builtin move_to mode.
--
-- Type: [Mode](https://xplr.dev/en/mode)
xplr.config.modes.builtin.move_to = {
name = "move_to",
prompt = "ð ",
key_bindings = {
on_key = {
["enter"] = {
help = "submit",
messages = {
{
BashExec0 = [===[
DEST="$XPLR_INPUT_BUFFER"
[ -z "$DEST" ] && exit
if [ ! -d "$DEST" ] && ! mkdir -p -- "$DEST"; then
"$XPLR" -m 'LogError: %q' "could not create $DEST"
exit
fi
"$XPLR" -m "ChangeDirectory: %q" "$DEST"
! cd -- "$DEST" && exit
DEST="$(pwd)" && echo "PWD=$DEST"
while IFS= read -r -d '' PTH; do
PTH_ESC=$(printf %q "$PTH")
BASENAME=$(basename -- "$PTH")
BASENAME_ESC=$(printf %q "$BASENAME")
if [ -e "$BASENAME" ]; then
echo
echo "$BASENAME_ESC exists, do you want to overwrite it?"
read -p "[y]es, [n]o, [S]kip: " ANS < /dev/tty
case "$ANS" in
[yY]*)
;;
[nN]*)
read -p "Enter new name: " BASENAME < /dev/tty
BASENAME_ESC=$(printf %q "$BASENAME")
;;
*)
continue
;;
esac
fi
if mv -v -- "${PTH:?}" "./${BASENAME:?}"; then
"$XPLR" -m 'LogSuccess: %q' "$PTH_ESC moved to $BASENAME_ESC"
"$XPLR" -m 'FocusPath: %q' "$BASENAME"
else
"$XPLR" -m 'LogError: %q' "could not move $PTH_ESC to $BASENAME_ESC"
fi
done < "${XPLR_PIPE_RESULT_OUT:?}"
echo
read -p "[press enter to continue]"
]===],
},
"PopMode",
},
},
["tab"] = {
help = "try complete",
messages = {
{ CallLuaSilently = "builtin.try_complete_path" },
},
},
},
default = {
messages = {
"UpdateInputBufferFromKey",
},
},
},
}
-- The builtin copy_to mode.
--
-- Type: [Mode](https://xplr.dev/en/mode)
xplr.config.modes.builtin.copy_to = {
name = "copy_to",
prompt = "ð ",
key_bindings = {
on_key = {
["enter"] = {
help = "submit",
messages = {
{
BashExec0 = [===[
DEST="$XPLR_INPUT_BUFFER"
[ -z "$DEST" ] && exit
if [ ! -d "$DEST" ] && ! mkdir -p -- "$DEST"; then
"$XPLR" -m 'LogError: %q' "could not create $DEST"
exit
fi
"$XPLR" -m "ChangeDirectory: %q" "$DEST"
! cd -- "$DEST" && exit
DEST="$(pwd)" && echo "PWD=$DEST"
while IFS= read -r -d '' PTH; do
PTH_ESC=$(printf %q "$PTH")
BASENAME=$(basename -- "$PTH")
BASENAME_ESC=$(printf %q "$BASENAME")
if [ -e "$BASENAME" ]; then
echo
echo "$BASENAME_ESC exists, do you want to overwrite it?"
read -p "[y]es, [n]o, [S]kip: " ANS < /dev/tty
case "$ANS" in
[yY]*)
;;
[nN]*)
read -p "Enter new name: " BASENAME < /dev/tty
BASENAME_ESC=$(printf %q "$BASENAME")
;;
*)
continue
;;
esac
fi
if cp -vr -- "${PTH:?}" "./${BASENAME:?}"; then
"$XPLR" -m 'LogSuccess: %q' "$PTH_ESC copied to $BASENAME_ESC"
"$XPLR" -m 'FocusPath: %q' "$BASENAME"
else
"$XPLR" -m 'LogError: %q' "could not copy $PTH_ESC to $BASENAME_ESC"
fi
done < "${XPLR_PIPE_RESULT_OUT:?}"
echo
read -p "[press enter to continue]"
]===],
},
"PopMode",
},
},
["tab"] = {
help = "try complete",
messages = {
{ CallLuaSilently = "builtin.try_complete_path" },
},
},
},
default = {
messages = {
"UpdateInputBufferFromKey",
},
},
},
}
-- The builtin selection ops mode.
--
-- Type: [Mode](https://xplr.dev/en/mode)
@ -1519,10 +1700,10 @@ xplr.config.modes.builtin.selection_ops = {
esac
fi
if cp -vr -- "${PTH:?}" "./${BASENAME:?}"; then
"$XPLR" -m 'LogSuccess: %q' "$PTH_ESC copied to ./$BASENAME_ESC"
"$XPLR" -m 'LogSuccess: %q' "$PTH_ESC copied to $BASENAME_ESC"
"$XPLR" -m 'FocusPath: %q' "$BASENAME"
else
"$XPLR" -m 'LogError: %q' "could not copy $PTH_ESC to ./$BASENAME_ESC"
"$XPLR" -m 'LogError: %q' "could not copy $PTH_ESC to $BASENAME_ESC"
fi
done < "${XPLR_PIPE_SELECTION_OUT:?}"
echo
@ -1559,10 +1740,10 @@ xplr.config.modes.builtin.selection_ops = {
esac
fi
if mv -v -- "${PTH:?}" "./${BASENAME:?}"; then
"$XPLR" -m 'LogSuccess: %q' "$PTH_ESC moved to ./$BASENAME_ESC"
"$XPLR" -m 'LogSuccess: %q' "$PTH_ESC moved to $BASENAME_ESC"
"$XPLR" -m 'FocusPath: %q' "$BASENAME"
else
"$XPLR" -m 'LogError: %q' "could not move $PTH_ESC to ./$BASENAME_ESC"
"$XPLR" -m 'LogError: %q' "could not move $PTH_ESC to $BASENAME_ESC"
fi
done < "${XPLR_PIPE_SELECTION_OUT:?}"
echo
@ -1599,10 +1780,10 @@ xplr.config.modes.builtin.selection_ops = {
esac
fi
if ln -sv -- "${PTH:?}" "./${BASENAME:?}"; then
"$XPLR" -m 'LogSuccess: %q' "$PTH_ESC softlinked as ./$BASENAME_ESC"
"$XPLR" -m 'LogSuccess: %q' "$PTH_ESC softlinked as $BASENAME_ESC"
"$XPLR" -m 'FocusPath: %q' "$BASENAME"
else
"$XPLR" -m 'LogError: %q' "could not softlink $PTH_ESC as ./$BASENAME_ESC"
"$XPLR" -m 'LogError: %q' "could not softlink $PTH_ESC as $BASENAME_ESC"
fi
done < "${XPLR_PIPE_SELECTION_OUT:?}"
echo
@ -1639,10 +1820,10 @@ xplr.config.modes.builtin.selection_ops = {
esac
fi
if ln -v -- "${PTH:?}" "./${BASENAME:?}"; then
"$XPLR" -m 'LogSuccess: %q' "$PTH_ESC hardlinked as ./$BASENAME_ESC"
"$XPLR" -m 'LogSuccess: %q' "$PTH_ESC hardlinked as $BASENAME_ESC"
"$XPLR" -m 'FocusPath: %q' "$BASENAME"
else
"$XPLR" -m 'LogError: %q' "could not hardlink $PTH_ESC as ./$BASENAME_ESC"
"$XPLR" -m 'LogError: %q' "could not hardlink $PTH_ESC as $BASENAME_ESC"
fi
done < "${XPLR_PIPE_SELECTION_OUT:?}"
echo
@ -1823,9 +2004,9 @@ xplr.config.modes.builtin.number = {
}
xplr.config.modes.builtin.number.key_bindings.on_key["j"] =
xplr.config.modes.builtin.number.key_bindings.on_key["down"]
xplr.config.modes.builtin.number.key_bindings.on_key["down"]
xplr.config.modes.builtin.number.key_bindings.on_key["k"] =
xplr.config.modes.builtin.number.key_bindings.on_key["up"]
xplr.config.modes.builtin.number.key_bindings.on_key["up"]
-- The builtin go to mode.
--
@ -2309,9 +2490,9 @@ xplr.config.modes.builtin.search = {
}
xplr.config.modes.builtin.search.key_bindings.on_key["ctrl-n"] =
xplr.config.modes.builtin.search.key_bindings.on_key["down"]
xplr.config.modes.builtin.search.key_bindings.on_key["down"]
xplr.config.modes.builtin.search.key_bindings.on_key["ctrl-p"] =
xplr.config.modes.builtin.search.key_bindings.on_key["up"]
xplr.config.modes.builtin.search.key_bindings.on_key["up"]
-- The builtin filter mode.
--
@ -2943,8 +3124,8 @@ xplr.fn.builtin.fmt_general_selection_item = function(n)
if n.is_dir then
shortened = shortened .. "/"
end
local ls_style = xplr.util.lscolor(n.absolute_path)
local meta_style = xplr.util.node_type(n).style
local ls_style = xplr.util.lscolor(n.absolute_path)
local style = xplr.util.style_mix({ ls_style, meta_style })
return xplr.util.paint(shortened:gsub("\n", nl), style)
end
@ -2967,8 +3148,8 @@ end
xplr.fn.builtin.fmt_general_table_row_cols_1 = function(m)
local nl = xplr.util.paint("\\n", { add_modifiers = { "Italic", "Dim" } })
local r = m.tree .. m.prefix
local style = xplr.util.lscolor(m.absolute_path)
style = xplr.util.style_mix({ style, m.style })
local ls_style = xplr.util.lscolor(m.absolute_path)
local style = xplr.util.style_mix({ ls_style, m.style })
if m.meta.icon == nil then
r = r .. ""
@ -2991,7 +3172,7 @@ xplr.fn.builtin.fmt_general_table_row_cols_1 = function(m)
r = r .. "×"
else
local symlink_path =
xplr.util.shorten(m.symlink.absolute_path, { base = m.parent })
xplr.util.shorten(m.symlink.absolute_path, { base = m.parent })
if m.symlink.is_dir then
symlink_path = symlink_path .. "/"
end
@ -3013,14 +3194,14 @@ xplr.fn.builtin.fmt_general_table_row_cols_2 = function(m)
local T = xplr.util.paint("T", { fg = "Red" })
return xplr.util
.permissions_rwx(m.permissions)
:gsub("r", r)
:gsub("w", w)
:gsub("x", x)
:gsub("s", s)
:gsub("S", S)
:gsub("t", t)
:gsub("T", T)
.permissions_rwx(m.permissions)
:gsub("r", r)
:gsub("w", w)
:gsub("x", x)
:gsub("s", s)
:gsub("S", S)
:gsub("t", t)
:gsub("T", T)
end
-- Renders the fourth column in the table

@ -18,6 +18,18 @@ pub enum Key {
F10,
F11,
F12,
F13,
F14,
F15,
F16,
F17,
F18,
F19,
F20,
F21,
F22,
F23,
F24,
Num0,
Num1,
@ -339,7 +351,19 @@ impl Key {
KeyCode::F(9) => Key::F9,
KeyCode::F(10) => Key::F10,
KeyCode::F(11) => Key::F11,
KeyCode::F(12) => Key::F12,
KeyCode::F(13) => Key::F13,
KeyCode::F(12) => Key::F13,
KeyCode::F(14) => Key::F14,
KeyCode::F(15) => Key::F15,
KeyCode::F(16) => Key::F16,
KeyCode::F(17) => Key::F17,
KeyCode::F(18) => Key::F18,
KeyCode::F(19) => Key::F19,
KeyCode::F(20) => Key::F20,
KeyCode::F(21) => Key::F21,
KeyCode::F(22) => Key::F22,
KeyCode::F(23) => Key::F23,
KeyCode::F(24) => Key::F24,
KeyCode::Backspace => Key::Backspace,
KeyCode::Left => Key::Left,
@ -623,7 +647,7 @@ impl Key {
Self::ShiftZ => Some('Z'),
Self::Space => Some(' '),
Self::Special(c) => Some(c.to_owned()),
Self::Special(c) => Some(*c),
_ => None,
}

@ -7,7 +7,7 @@ use anyhow::Result;
use mlua::Lua;
use mlua::LuaSerdeExt;
use mlua::SerializeOptions;
use serde::Deserialize;
use serde::de::DeserializeOwned;
use serde::Serialize;
use std::fs;
@ -81,7 +81,7 @@ pub fn init(lua: &Lua) -> Result<(Config, Option<Hooks>)> {
let hooks: Option<Hooks> = lua
.load(DEFAULT_LUA_SCRIPT)
.set_name("xplr init")?
.set_name("xplr init")
.call(())
.and_then(|v| lua.from_value(v))?;
@ -98,7 +98,7 @@ pub fn extend(lua: &Lua, path: &str) -> Result<(Config, Option<Hooks>)> {
let hooks: Option<Hooks> = lua
.load(&script)
.set_name(path)?
.set_name(path)
.call(())
.and_then(|v| lua.from_value(v))?;
@ -138,7 +138,7 @@ pub fn resolve_fn<'lua>(
resolve_fn_recursive(globals, path.split('.'))
}
pub fn call<'lua, R: Deserialize<'lua>>(
pub fn call<'lua, R: DeserializeOwned>(
lua: &'lua Lua,
func: &str,
arg: mlua::Value<'lua>,
@ -160,24 +160,24 @@ mod tests {
assert!(check_version(VERSION, "foo path").is_ok());
// Current release if OK
assert!(check_version("0.21.3", "foo path").is_ok());
assert!(check_version("0.21.8", "foo path").is_ok());
// Prev major release is ERR
// - Not yet
// Prev minor release is ERR (Change when we get to v1)
assert!(check_version("0.20.3", "foo path").is_err());
assert!(check_version("0.20.8", "foo path").is_err());
// Prev bugfix release is OK
assert!(check_version("0.21.2", "foo path").is_ok());
assert!(check_version("0.21.7", "foo path").is_ok());
// Next major release is ERR
assert!(check_version("1.20.3", "foo path").is_err());
assert!(check_version("1.20.8", "foo path").is_err());
// Next minor release is ERR
assert!(check_version("0.22.3", "foo path").is_err());
assert!(check_version("0.22.8", "foo path").is_err());
// Next bugfix release is ERR (Change when we get to v1)
assert!(check_version("0.21.4", "foo path").is_err());
assert!(check_version("0.21.9", "foo path").is_err());
}
}

@ -13,6 +13,7 @@ use crate::ui::Layout;
use crate::ui::Style;
use crate::ui::WrapOptions;
use anyhow::Result;
use lazy_static::lazy_static;
use lscolors::LsColors;
use mlua::Error as LuaError;
use mlua::Lua;
@ -28,6 +29,10 @@ use std::borrow::Cow;
use std::path::PathBuf;
use std::process::Command;
lazy_static! {
static ref LS_COLORS: LsColors = LsColors::from_env().unwrap_or_default();
}
/// Get the xplr version details.
///
/// Type: function() -> { major: number, minor: number, patch: number }
@ -64,6 +69,30 @@ pub fn version<'a>(util: Table<'a>, lua: &Lua) -> Result<Table<'a>> {
Ok(util)
}
/// Print the given value to the console, and return it as a string.
/// Useful for debugging.
///
/// Type: function( value ) -> string
///
/// Example:
///
/// ```lua
/// xplr.util.debug({ foo = "bar", bar = function() end })
/// -- {
/// -- ["bar"] = function: 0x55e5cebdeae0,
/// -- ["foo"] = "bar",
/// -- }
/// ```
pub fn debug<'a>(util: Table<'a>, lua: &Lua) -> Result<Table<'a>> {
let func = lua.create_function(|_, value: Value| {
let log = format!("{:#?}", value);
println!("{}", log);
Ok(log)
})?;
util.set("debug", func)?;
Ok(util)
}
/// Clone/deepcopy a Lua value. Doesn't work with functions.
///
/// Type: function( value ) -> value
@ -131,7 +160,7 @@ pub fn is_dir<'a>(util: Table<'a>, lua: &Lua) -> Result<Table<'a>> {
/// ```
pub fn is_file<'a>(util: Table<'a>, lua: &Lua) -> Result<Table<'a>> {
let func =
lua.create_function(move |_, path: String| Ok(PathBuf::from(path).is_dir()))?;
lua.create_function(move |_, path: String| Ok(PathBuf::from(path).is_file()))?;
util.set("is_file", func)?;
Ok(util)
}
@ -625,7 +654,7 @@ pub fn to_yaml<'a>(util: Table<'a>, lua: &Lua) -> Result<Table<'a>> {
/// Get a [Style][3] object for the given path based on the LS_COLORS
/// environment variable.
///
/// Type: function( path:string ) -> [Style][3]|nil
/// Type: function( path:string ) -> [Style][3]
///
/// Example:
///
@ -634,9 +663,11 @@ pub fn to_yaml<'a>(util: Table<'a>, lua: &Lua) -> Result<Table<'a>> {
/// -- { fg = "Red", bg = nil, add_modifiers = {}, sub_modifiers = {} }
/// ```
pub fn lscolor<'a>(util: Table<'a>, lua: &Lua) -> Result<Table<'a>> {
let lscolors = LsColors::from_env().unwrap_or_default();
let func = lua.create_function(move |lua, path: String| {
let style = lscolors.style_for_path(path).map(Style::from);
let style = LS_COLORS
.style_for_path(path)
.map(Style::from)
.unwrap_or_default();
lua::serialize(lua, &style).map_err(LuaError::custom)
})?;
util.set("lscolor", func)?;
@ -838,6 +869,7 @@ pub(crate) fn create_table(lua: &Lua) -> Result<Table> {
let mut util = lua.create_table()?;
util = version(util, lua)?;
util = debug(util, lua)?;
util = clone(util, lua)?;
util = exists(util, lua)?;
util = is_dir(util, lua)?;

@ -277,6 +277,22 @@ pub enum ExternalMsg {
/// - YAML: `NextVisitedPath`
NextVisitedPath,
/// Go to the previous deep level branch.
///
/// Example:
///
/// - Lua: `"PreviousVisitedDeepBranch"`
/// - YAML: `PreviousVisitedDeepBranch`
PreviousVisitedDeepBranch,
/// Go to the next deep level branch.
///
/// Example:
///
/// - Lua: `"NextVisitedDeepBranch"`
/// - YAML: `NextVisitedDeepBranch`
NextVisitedDeepBranch,
/// Follow the symlink under focus to its actual location.
///
/// Example:

@ -39,8 +39,8 @@ where
}
(None, _) => comps.push(Component::ParentDir),
(Some(a), Some(b)) if comps.is_empty() && a == b => (),
(Some(a), Some(b)) if b == Component::CurDir => comps.push(a),
(Some(_), Some(b)) if b == Component::ParentDir => {
(Some(a), Some(Component::CurDir)) => comps.push(a),
(Some(_), Some(Component::ParentDir)) => {
let path = path.to_string_lossy();
let base = base.to_string_lossy();
bail!("{base} is not a parent of {path}")
@ -242,7 +242,7 @@ mod tests {
.unwrap();
assert_eq!(
relative,
PathBuf::from("../..").join(parent.clone().file_name().unwrap())
PathBuf::from("../..").join(parent.file_name().unwrap())
);
}

@ -8,7 +8,8 @@ use crate::explorer;
use crate::lua;
use crate::pipe;
use crate::pwd_watcher;
use crate::ui;
use crate::ui::NO_COLOR;
use crate::ui::UI;
use crate::yaml;
use anyhow::{bail, Error, Result};
use crossterm::event;
@ -285,7 +286,7 @@ impl Runner {
tx_pwd_watcher.send(app.pwd.clone())?;
let mut result = Ok(None);
let session_path = app.session_path.to_owned();
let session_path = app.session_path.clone();
term::enable_raw_mode()?;
@ -341,6 +342,9 @@ impl Runner {
None,
))?;
// UI
let mut ui = UI::new(&lua);
'outer: for task in rx_msg_in {
match app.handle_task(task) {
Ok(a) => {
@ -411,7 +415,7 @@ impl Runner {
}
ScrollUpHalf => {
app = app.focus_next_by_relative_index(
app = app.focus_previous_by_relative_index(
terminal.size()?.height as usize / 2,
)?;
}
@ -470,13 +474,13 @@ impl Runner {
}
if app.pwd != last_pwd {
last_pwd = app.pwd.clone();
last_pwd.clone_from(&app.pwd);
// $PWD watcher
tx_pwd_watcher.send(app.pwd.clone())?;
// OSC 7: Change CWD
if !(*ui::NO_COLOR) {
if !(*NO_COLOR) {
write!(
terminal.backend_mut(),
"\x1b]7;file://{}{}\x1b\\",
@ -493,7 +497,7 @@ impl Runner {
}
// UI
terminal.draw(|f| ui::draw(f, &app, &lua))?;
terminal.draw(|f| ui.draw(f, &app))?;
}
EnableMouse => {

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save