Compare commits

..

No commits in common. 'main' and 'v0.21.1' have entirely different histories.

@ -1,14 +1,4 @@
# Why dynamic linking?
# See https://github.com/sayanarijit/xplr/issues/309
[target.x86_64-unknown-linux-gnu]
rustflags = ["-C", "link-args=-rdynamic"]
[target.aarch64-unknown-linux-gnu]
rustflags = ["-C", "linker=aarch64-linux-gnu-gcc", "-C", "link-args=-rdynamic"]
[target.aarch64-linux-android]
rustflags = ["-C", "linker=aarch64-linux-android-clang", "-C", "link-args=-rdynamic", "-C", "default-linker-libraries"]
[target.arm-unknown-linux-gnueabihf]
rustflags = ["-C", "linker=arm-linux-gnueabihf-gcc", "-C", "link-args=-rdynamic"]

@ -1,6 +0,0 @@
ratatui
crate
ser
enque
noice
ans

@ -12,84 +12,71 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
build:
- macos
- macos-aarch64
- linux
- linux-musl
- linux-aarch64
- linux-arm
os:
- macos-latest
- ubuntu-latest
- ubuntu-20.04
rust: [stable]
include:
# See the list: https://github.com/cross-rs/cross
- build: macos
os: macos-latest
- os: macos-latest
artifact_prefix: macos
target: x86_64-apple-darwin
binary_postfix: ""
- build: macos-aarch64
os: macos-latest
target: aarch64-apple-darwin
- build: linux
os: ubuntu-latest
- os: ubuntu-latest
artifact_prefix: linux
target: x86_64-unknown-linux-gnu
binary_postfix: ""
- build: linux-musl
os: ubuntu-latest
- os: ubuntu-20.04
artifact_prefix: linux-musl
target: x86_64-unknown-linux-musl
binary_postfix: ""
- build: linux-aarch64
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
# Will see later
- build: linux-arm
os: ubuntu-latest
target: arm-unknown-linux-gnueabihf
# - os: ubuntu-latest
# artifact_prefix: x86_64-android
# target: x86_64-linux-android
# binary_postfix: ''
#
# - os: ubuntu-latest
# artifact_prefix: aarch64-android
# target: aarch64-linux-android
# binary_postfix: ''
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
- name: Installing Rust toolchain
uses: dtolnay/rust-toolchain@stable
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
- name: Installing needed macOS dependencies
if: matrix.os == 'macos-latest'
run: brew install openssl@1.1
- name: Installing needed Ubuntu dependencies
if: matrix.os == 'ubuntu-latest'
if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-20.04'
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
- if: matrix.build == 'linux-aarch64'
run: sudo apt-get install -y gcc-aarch64-linux-gnu
sudo apt-get install -y -qq pkg-config libssl-dev libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev
- if: matrix.build == 'linux-arm'
run: |
sudo apt-get install -y gcc-multilib
sudo apt-get install -y gcc-arm-linux-gnueabihf
sudo ln -s /usr/include/asm-generic/ /usr/include/asm
- name: Checking out sources
uses: actions/checkout@v1
- 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
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
toolchain: ${{ matrix.rust }}
args: --locked --release --target ${{ matrix.target }}
- name: Install gpg secret key
run: |
@ -100,8 +87,9 @@ jobs:
shell: bash
run: |
cd target/${{ matrix.target }}/release
BINARY_NAME=xplr
RELEASE_NAME=$BINARY_NAME-${{ matrix.build }}
BINARY_NAME=xplr${{ matrix.binary_postfix }}
strip $BINARY_NAME
RELEASE_NAME=xplr-${{ matrix.artifact_prefix }}
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
@ -110,23 +98,17 @@ jobs:
uses: softprops/action-gh-release@v1
with:
files: |
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
target/${{ matrix.target }}/release/xplr-${{ matrix.artifact_prefix }}.tar.gz
target/${{ matrix.target }}/release/xplr-${{ matrix.artifact_prefix }}.sha256
target/${{ matrix.target }}/release/xplr-${{ matrix.artifact_prefix }}.tar.gz.asc
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
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
- name: Install gpg secret key
run: |
cat <(echo -e "${{ secrets.GPG_SECRET }}") | gpg --batch --import
@ -151,16 +133,20 @@ jobs:
name: Publishing to Cargo
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
- uses: dtolnay/rust-toolchain@stable
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- run: |
sudo apt-get update --fix-missing
sudo apt-get install -y -qq pkg-config libssl-dev libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev
- run: cargo publish --allow-dirty
- uses: actions-rs/cargo@v1
with:
command: publish
args: --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_API_KEY }}

@ -11,134 +11,120 @@ jobs:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- run: cargo check
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt
- run: cargo fmt --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
profile: minimal
override: true
- uses: actions-rs/cargo@v1
with:
toolchain: stable
components: clippy
- run: cargo clippy -- -D warnings
spellcheck:
name: Spellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: codespell-project/actions-codespell@v1
with:
ignore_words_file: .codespellignore
command: check
test:
name: Test Suite
runs-on: ${{ matrix.os }}
needs:
- check
- fmt
- clippy
- spellcheck
strategy:
matrix:
build:
- macos
- macos-aarch64
- linux
- linux-musl
- linux-aarch64
- linux-arm
os:
- macos-latest
- ubuntu-latest
- ubuntu-20.04
rust: [stable]
include:
# See the list: https://github.com/cross-rs/cross
- build: macos
os: macos-latest
- os: macos-latest
artifact_prefix: macos
target: x86_64-apple-darwin
- build: macos-aarch64
os: macos-latest
target: aarch64-apple-darwin
- build: linux
os: ubuntu-latest
binary_postfix: ""
- os: ubuntu-latest
artifact_prefix: linux
target: x86_64-unknown-linux-gnu
- build: linux-musl
os: ubuntu-latest
binary_postfix: ""
- os: ubuntu-20.04
artifact_prefix: linux-musl
target: x86_64-unknown-linux-musl
- build: linux-aarch64
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
- build: linux-arm
os: ubuntu-latest
target: arm-unknown-linux-gnueabihf
binary_postfix: ""
env:
RUST_BACKTRACE: full
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
- name: Installing Rust toolchain
uses: dtolnay/rust-toolchain@stable
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
- name: Installing needed macOS dependencies
if: matrix.os == 'macos-latest'
run: brew install openssl@1.1
- name: Installing needed Ubuntu dependencies
if: matrix.os == 'ubuntu-latest'
if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-20.04'
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
- if: matrix.build == 'linux-musl'
run: sudo apt-get install -y musl-tools
sudo apt-get install -y -qq pkg-config libssl-dev libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev
- if: matrix.build == 'linux-aarch64'
run: sudo apt-get install -y gcc-aarch64-linux-gnu
- if: matrix.build == 'linux-arm'
run: |
sudo apt-get install -y gcc-multilib
sudo apt-get install -y gcc-arm-linux-gnueabihf
sudo ln -s /usr/include/asm-generic/ /usr/include/asm
- run: cargo build --target ${{ matrix.target }}
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
toolchain: ${{ matrix.rust }}
args: --target ${{ matrix.target }}
- if: matrix.build == 'macos' || matrix.build == 'linux'
run: cargo test --target ${{ matrix.target }}
- name: Test
uses: actions-rs/cargo@v1
with:
command: test
toolchain: ${{ matrix.rust }}
args: --target ${{ matrix.target }}
# bench:
# name: Benchmarks
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: dtolnay/rust-toolchain@stable
# - uses: actions/checkout@v2
# - uses: actions-rs/toolchain@v1
# with:
# toolchain: stable
# profile: minimal
# override: true
# # These dependencies are required for `clipboard`
# - run: sudo apt-get install -y -qq libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev
# - run: cargo bench
# - uses: actions-rs/cargo@v1
# with:
# command: bench
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
components: rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
components: clippy
- uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings

6
.gitignore vendored

@ -17,9 +17,3 @@ book/
# direnv
.direnv/
# nix
result
# test files
/init.lua

@ -5,7 +5,7 @@
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socioeconomic status,
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.
@ -17,23 +17,23 @@ diverse, inclusive, and healthy community.
Examples of behavior that contributes to a positive environment for our
community include:
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
- Focusing on what is best not just for us as individuals, but for the
* Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior include:
- The use of sexualized language or imagery, and sexual attention or
* The use of sexualized language or imagery, and sexual attention or
advances of any kind
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
- Other conduct which could reasonably be considered inappropriate in a
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within

1184
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.9'
version = '0.21.1'
authors = ['Arijit Basu <hi@arijitbasu.in>']
edition = '2021'
description = 'A hackable, minimal, fast TUI file explorer'
@ -22,29 +22,27 @@ categories = ['command-line-interface', 'command-line-utilities']
include = ['src/**/*', 'docs/en/src/**/*', 'LICENSE', 'README.md']
[dependencies]
libc = "0.2.155"
libc = "0.2.140"
humansize = "2.1.3"
natord = "1.0.9"
anyhow = "1.0.86"
serde_yaml = "0.9.34"
crossterm = { version = "0.27.0", features = [], default-features = false }
ansi-to-tui = "=3.1.0"
regex = "1.10.5"
gethostname = "0.4.3"
serde_json = "1.0.117"
path-absolutize = "3.1.1"
which = "6.0.1"
nu-ansi-term = "0.50.0"
anyhow = "1.0.70"
serde_yaml = "0.9.19"
crossterm = "0.26.1"
dirs = "5.0.0"
ansi-to-tui = "3.0.0"
regex = "1.7.3"
gethostname = "0.4.1"
serde_json = "1.0.94"
path-absolutize = "3.0.14"
which = "4.4.0"
nu-ansi-term = "0.47.0"
textwrap = "0.16"
snailquote = "0.3.1"
skim = { version = "0.10.4", default-features = false }
time = { version = "0.3.36", features = ["serde", "local-offset", "formatting", "macros"] }
jf = "0.6.2"
xdg = "2.5.2"
home = "0.5.9"
skim = "0.10.4"
time = { version = "0.3.20", features = ["serde", "local-offset", "formatting", "macros"] }
[dependencies.lscolors]
version = "0.17.0"
version = "0.13.0"
default-features = false
features = ["nu-ansi-term"]
@ -54,41 +52,37 @@ default-features = false
[dependencies.mime_guess]
version = "2.0.4"
default-features = false
features = ["rev-mappings"]
[dependencies.tui]
version = "=0.26.1" # https://github.com/ratatui-org/ratatui/issues/1032
version = "0.20.1"
default-features = false
features = ['crossterm', 'serde']
package = 'ratatui'
[dependencies.serde]
version = "1.0.203"
features = []
default-features = false
version = "1.0.158"
features = ['derive']
[dependencies.indexmap]
version = "2.2.6"
version = "1.9.3"
features = ['serde']
[dependencies.mlua]
version = "0.9.8"
features = ['luajit', 'serialize', 'send']
version = "0.8.8"
features = ['luajit', 'vendored', 'serialize', 'send']
[dependencies.tui-input]
version = "0.8.0"
version = "0.7.0"
features = ['serde']
[dev-dependencies]
criterion = "0.5.1"
assert_cmd = "2.0.14"
criterion = "0.4.0"
assert_cmd = "2.0.10"
[profile.release]
lto = true
codegen-units = 1
panic = 'abort'
strip = true
[features]
default = ["vendored-lua"]
vendored-lua = ["mlua/vendored"]

@ -12,6 +12,18 @@ 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">
@ -26,6 +38,7 @@ 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
@ -47,8 +60,6 @@ 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>)
## Packaging
Package maintainers please refer to the [RELEASE.md](./RELEASE.md).

@ -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 compile using `--no-default-features` argument to avoid using
vendored luajit, so that you can static link luajit yourself.
you need to grep out the feature "vendored" from the "mlua" dependency
specified in [Cargo.toml](./Cargo.toml), and static link luajit yourself.
# Release

@ -98,7 +98,6 @@ 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");
@ -122,7 +121,7 @@ fn draw_benchmark(c: &mut Criterion) {
c.bench_function("draw on terminal", |b| {
b.iter(|| {
terminal.draw(|f| ui.draw(f, &app)).unwrap();
terminal.draw(|f| ui::draw(f, &app, &lua)).unwrap();
})
});

@ -10,7 +10,6 @@
- [Layouts][9]
- [Modes][7]
- [Concept][32]
- [Sum Type][42]
- [Key Bindings][27]
- [Configure Key Bindings][28]
- [Default Key Bindings][14]
@ -39,6 +38,8 @@
- [Awesome Integrations][20]
- [Alternatives][22]
- [Upgrade Guide][23]
- [Community][24]
- [Contribute][25]
[1]: introduction.md
[2]: quickstart.md
@ -62,6 +63,8 @@
[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
@ -78,4 +81,3 @@
[39]: input-operation.md
[40]: xplr.util.md
[41]: searching.md
[42]: sum-type.md

@ -15,7 +15,6 @@ 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]
@ -31,6 +30,5 @@ 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]: https://github.com/sayanarijit/xplr/edit/dev/docs/en/src/alternatives.md
[13]: community.md
[14]: https://github.com/kyoheiu/felix
[15]: https://github.com/sxyazi/yazi

@ -6,9 +6,9 @@ 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].
[Edit this file][3] or [share them here][4] or [let us know][5].
You can try these hacks by writing them to a file, say `hack.lua` and passing
You can try these hacks by writing them to a file, say `hack.lua` and passsing
it to xplr with `--extra-config` or `-C`.
```bash
@ -423,7 +423,7 @@ Preview text files in a native xplr pane (should be fast enough).
```lua
local function stat(node)
return xplr.util.to_yaml(xplr.util.node(node.absolute_path))
return node.mime_essence
end
local function read(path, height)
@ -452,29 +452,8 @@ local function read(path, height)
return res
end
xplr.fn.custom.preview_pane = {}
xplr.fn.custom.preview_pane.render = function(ctx)
local title = nil
local body = ""
local n = ctx.app.focused_node
if n and n.canonical then
n = n.canonical
end
if n then
title = { format = n.absolute_path, style = xplr.util.lscolor(n.absolute_path) }
if n.is_file then
body = read(n.absolute_path, ctx.layout_size.height) or stat(n)
else
body = stat(n)
end
end
return { CustomParagraph = { ui = { title = title }, body = body } }
end
local preview_pane = { Dynamic = "custom.preview_pane.render" }
local split_preview = {
xplr.config.layouts.builtin.default = {
Horizontal = {
config = {
constraints = {
@ -484,13 +463,34 @@ local split_preview = {
},
splits = {
"Table",
preview_pane,
{
CustomContent = {
title = "preview",
body = { DynamicParagraph = { render = "custom.preview_pane.render" } },
},
},
},
},
}
xplr.config.layouts.builtin.default =
xplr.util.layout_replace(xplr.config.layouts.builtin.default, "Table", split_preview)
xplr.fn.custom.preview_pane = {}
xplr.fn.custom.preview_pane.render = function(ctx)
local n = ctx.app.focused_node
if n and n.canonical then
n = n.canonical
end
if n then
if n.is_file then
return read(n.absolute_path, ctx.layout_size.height)
else
return stat(n)
end
else
return ""
end
end
```
</details>
@ -510,7 +510,7 @@ Navigate using the [tere][19] file explorer (defaults to type-to-nav system).
xplr.config.modes.builtin.default.key_bindings.on_key.T = {
help = "tere nav",
messages = {
{ BashExec0 = [["$XPLR" -m 'ChangeDirectory: %q' "$(tere)"]] },
{ BashExec0 = [[xplr -m 'ChangeDirectory: %q' "$(tere)"]] },
},
}
```
@ -526,6 +526,7 @@ 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

@ -11,9 +11,8 @@ of the following plugins work for you, it's very easy to
- [**sayanarijit/dual-pane.xplr**][43] Implements support for dual-pane navigation into xplr.
- [**sayanarijit/map.xplr**][38] Visually inspect and interactively execute batch commands using xplr.
- [**sayanarijit/offline-docs.xplr**][51] Fetch the appropriate version of xplr docs and browse offline.
- [**sayanarijit/regex-search.xplr**][55] Bring back the regex based search in xplr.
- [**sayanarijit/regex-search.xplr**][55] Bring back the regex based seach in xplr.
- [**sayanarijit/registers.xplr**][49] Use multiple registers to store the selected paths.
- [**sayanarijit/tree-view.xplr**][61] Hackable tree view for xplr
- [**sayanarijit/tri-pane.xplr**][56] xplr plugin that implements ranger-like three pane layout.
- [**sayanarijit/type-to-nav.xplr**][28] Inspired by [nnn's type-to-nav mode][29] for xplr,
with some tweaks.
@ -49,14 +48,9 @@ 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,9 +114,3 @@ of the following plugins work for you, it's very easy to
[56]: https://github.com/sayanarijit/tri-pane.xplr
[57]: https://github.com/emsquid/style.xplr
[58]: style.md
[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

@ -4,21 +4,21 @@ xplr allows customizing the shape and style of the borders.
### Border
A border is a [sum type][2] that can be one of the following:
A border can be one of the following:
- "Top"
- "Right"
- "Bottom"
- "Left"
- Top
- Right
- Bottom
- Left
### Border Type
A border type is a [sum type][2] that can be one of the following:
A border can be one of the following:
- "Plain"
- "Rounded"
- "Double"
- "Thick"
- Plain
- Rounded
- Double
- Thick
### Border Style
@ -34,4 +34,3 @@ xplr.config.general.panel_ui.default.border_style.bg = "Gray"
```
[1]: style.md#style
[2]: sum-type.md

@ -0,0 +1,12 @@
# 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

@ -131,26 +131,5 @@ return {
{ LogSuccess = "Switched layout" },
{ CallLuaSilently = "custom.some_plugin_with_hooks.on_layout_switch" },
}
-- Add messages to send when the selection changes
--
-- Type: list of [Message](https://xplr.dev/en/message#message)s
on_selection_change = {
{ LogSuccess = "Selection changed" },
{ CallLuaSilently = "custom.some_plugin_with_hooks.on_selection_change" },
}
}
```
---
> Note:
>
> It's not recommended to copy the entire configuration, unless you want to
> freeze it and miss out on useful updates to the defaults.
>
> Instead, you can use this as a reference to overwrite only the parts you
> want to update.
>
> If you still want to copy the entire configuration, make sure to put your
> customization before the return statement.

@ -86,7 +86,7 @@ Default action to perform in case if a keyboard input not mapped via any of the
## Key
A key is a [sum type][36] can be one of the following:
A key can be one of the following:
- 0, 1, ... 9
- a, b, ... z
@ -230,4 +230,3 @@ Visit [Awesome Plugins][27] for more [integration][28] options.
[33]: #on_character
[34]: #on_navigation
[35]: #on_function
[36]: sum-type.md

@ -0,0 +1,32 @@
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,17 +16,14 @@ 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 |
| ? | f1 | global help menu |
| ? | | 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-i | | next visited path |
| ctrl-n | | next selection |
| ctrl-o | | last visited path |
| ctrl-p | | prev selection |
@ -41,7 +38,6 @@ 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 |
@ -53,157 +49,113 @@ of [modes][4] and the key mappings for each mode.
| ~ | | go home |
| [0-9] | | input |
### 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
### vroot
| key | remaps | action |
| --- | ------ | ---------------- |
| f | | follow symlink |
| f1 | | global help menu |
| g | | top |
| i | | initial $PWD |
| p | | path |
| x | | open in gui |
| key | remaps | action |
| ------ | ------ | ------------ |
| . | | vroot $PWD |
| / | | vroot / |
| ctrl-r | | reset vroot |
| ctrl-u | | unset vroot |
| v | | toggle vroot |
| ~ | | vroot $HOME |
### relative_path_does_match_regex
| key | remaps | action |
| ----- | ------ | ---------------- |
| enter | | submit |
| f1 | | global help menu |
| key | remaps | action |
| ----- | ------ | ------ |
| enter | | submit |
### action
### go_to_path
| 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 |
| key | remaps | action |
| ----- | ------ | ------------ |
| enter | | submit |
| tab | | try complete |
### default
### duplicate_as
| 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 |
| key | remaps | action |
| ----- | ------ | ------------ |
| enter | | submit |
| tab | | try complete |
### debug_error
| key | remaps | action |
| ----- | ------ | ------------------- |
| enter | | open logs in editor |
| f1 | | global help menu |
| q | | quit |
### create_directory
### selection_ops
| key | remaps | action |
| ----- | ------ | ---------------- |
| enter | | submit |
| f1 | | global help menu |
| tab | | try complete |
| key | remaps | action |
| --- | ------ | --------------- |
| c | | copy here |
| e | | edit selection |
| h | | hardlink here |
| l | | list selection |
| m | | move here |
| s | | softlink here |
| u | | clear selection |
### selection_ops
### sort
| 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 |
| 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 |
### relative_path_does_not_match_regex
### go_to
| key | remaps | action |
| ----- | ------ | ---------------- |
| enter | | submit |
| f1 | | global help menu |
| key | remaps | action |
| --- | ------ | -------------- |
| f | | follow symlink |
| g | | top |
| i | | initial $PWD |
| p | | path |
| x | | open in gui |
### create_file
### edit_permissions
| key | remaps | action |
| ----- | ------ | ---------------- |
| enter | | submit |
| f1 | | global help menu |
| tab | | try complete |
| key | remaps | action |
| ------ | ------ | ------ |
| G | | -group |
| M | | min |
| O | | -other |
| U | | -user |
| ctrl-r | | reset |
| enter | | submit |
| g | | +group |
| m | | max |
| o | | +other |
| u | | +user |
### quit
### switch_layout
| 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 |
| key | remaps | action |
| --- | ------ | -------------------- |
| 1 | | default |
| 2 | | no help menu |
| 3 | | no selection panel |
| 4 | | no help or selection |
### create
@ -211,19 +163,20 @@ of [modes][4] and the key mappings for each mode.
| --- | ------ | ---------------- |
| d | | create directory |
| f | | create file |
| f1 | | global help menu |
### vroot
### create_directory
| key | remaps | action |
| ----- | ------ | ------------ |
| enter | | submit |
| tab | | try complete |
### create_file
| key | remaps | action |
| ------ | ------ | ---------------- |
| . | | vroot $PWD |
| / | | vroot / |
| ctrl-r | | reset vroot |
| ctrl-u | | unset vroot |
| f1 | | global help menu |
| v | | toggle vroot |
| ~ | | vroot $HOME |
| key | remaps | action |
| ----- | ------ | ------------ |
| enter | | submit |
| tab | | try complete |
### search
@ -238,95 +191,33 @@ 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 |
| f1 | | global help menu |
| k | up | to up |
| [0-9] | | input |
### copy_to
| 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 |
| key | remaps | action |
| ----- | ------ | -------- |
| down | j | to down |
| enter | | to index |
| k | up | to up |
| [0-9] | | input |
### move_to
### action
| key | remaps | action |
| ----- | ------ | ---------------- |
| enter | | submit |
| f1 | | global help menu |
| tab | | try complete |
| 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 |
### filter
@ -336,13 +227,39 @@ 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 |
### duplicate_as
### 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
| key | remaps | action |
| ----- | ------ | ---------------- |
| enter | | submit |
| f1 | | global help menu |
| tab | | try complete |
| key | remaps | action |
| --- | ------ | ------------ |
| D | | force delete |
| d | | delete |

@ -174,8 +174,6 @@ message using newline or null character (`\n` or `\0`).
> directly to this file, as safely escaping YAML strings is a lot of work. Use
> `xplr -m` / `xplr --pipe-msg-in` to pass messages to xplr in a safer way.
>
> It uses [jf][41] syntax to safely convert an YAML template into a valid message.
>
> Example: `"$XPLR" -m 'ChangeDirectory: %q' "${HOME:?}"`
#### XPLR_PIPE_SELECTION_OUT
@ -227,4 +225,3 @@ List of paths, filtered and sorted as displayed in the [files table][28].
[38]: #xplr
[39]: #xplr_vroot
[40]: #xplr_initial_pwd
[41]: https://github.com/sayanarijit/jf

@ -25,7 +25,7 @@ It contains the following information:
### filter
A filter is a [sum type][5] that can be one of the following:
A filter can be one of the following:
- "RelativePathIs"
- "RelativePathIsNot"
@ -90,4 +90,3 @@ Here, `ToggleNodeFilter` is a [message][4] that adds or removes
[2]: #filter
[3]: #input
[4]: message.md
[5]: sum-type.md

@ -42,19 +42,6 @@ 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
@ -85,7 +72,7 @@ Type: nullable string
#### xplr.config.general.logs.info.style
The style for the information logs.
The style for the informations logs.
Type: [Style](https://xplr.dev/en/style)
@ -600,16 +587,12 @@ Type: nullable list of [Node Sorter](https://xplr.dev/en/sorting#node-sorter-app
#### xplr.config.general.initial_mode
The name of one of the modes to use when xplr loads.
This isn't the default mode. To modify the default mode, overwrite
[xplr.config.modes.builtin.default](https://xplr.dev/en/modes#xplrconfigmodesbuiltindefault).
Type: nullable string
#### xplr.config.general.initial_layout
The name of one of the layouts to use when xplr loads.
This isn't the default layout. To modify the default layout, overwrite
[xplr.config.layouts.builtin.default](https://xplr.dev/en/layouts#xplrconfiglayoutsbuiltindefault).
Type: nullable string

@ -1,6 +1,6 @@
# Input Operation
Cursor based input operation is a [sum type][3] can be one of the following:
Cursor based input operation can be one of the following:
- { SetCursor = int }
- { InsertCharacter = str }
@ -24,4 +24,3 @@ Cursor based input operation is a [sum type][3] can be one of the following:
[1]: message.md
[2]: messages.md
[3]: sum-type.md

@ -41,48 +41,6 @@ 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)
@ -238,16 +196,57 @@ cargo build --locked --release --bin xplr
sudo cp target/release/xplr /usr/local/bin/
```
## Android
### [Termux][23]
[![xplr-termuxfd3c398d3cf4bcbc.md.jpg][24]][25]
> Please note that xplr isn't heavily tested on Termux, hence things might
> need a little tweaking and fixing for a smooth usage experience.
- Install build dependencies
```bash
pkg install rustc cargo make
```
- Install `xplr`
```bash
cargo install --locked --force xplr
```
- Setup storage
```bash
termux-setup-storage
```
- Setup config and runtime dir
```bash
export XDG_CONFIG_HOME="$PWD/storage/.config"
export XDG_RUNTIME_DIR="$PWD/storage/run"
mkdir -p "$XDG_CONFIG_HOME" "$XDG_RUNTIME_DIR"
```
- Run
```bash
~/.cargo/bin/xplr
```
[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/extra/x86_64/xplr
[7]: https://archlinux.org/packages/community/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/by-name/xp/xplr/package.nix
[10]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/misc/xplr
[11]: https://ports.macports.org/port/xplr
[12]: https://formulae.brew.sh/formula/xplr
[13]: https://cgit.freebsd.org/ports/plain/misc/xplr/
@ -260,10 +259,10 @@ sudo cp target/release/xplr /usr/local/bin/
[20]: https://gcc.gnu.org/
[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
[23]: https://termux.com/
[24]: https://s3.gifyu.com/images/xplr-termuxfd3c398d3cf4bcbc.md.jpg
[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,6 +84,8 @@ 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
@ -103,5 +105,6 @@ 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

@ -2,13 +2,15 @@
#### Example: Defining Custom Layout
[![layout.png][23]][24]
```lua
xplr.config.layouts.builtin.default = {
Horizontal = {
config = {
margin = 1,
horizontal_margin = 1,
vertical_margin = 1,
horizontal_margin = 2,
vertical_margin = 3,
constraints = {
{ Percentage = 50 },
{ Percentage = 50 },
@ -22,22 +24,7 @@ xplr.config.layouts.builtin.default = {
}
```
Result:
```
╭ /home ─────────────╮╭ Help [default] ────╮
│ ╭─── path ││. show hidden │
│ ├▸[ð Desktop/] ││/ search │
│ ├ ð Documents/ ││: action │
│ ├ ð Downloads/ ││? global help │
│ ├ ð GitHub/ ││G go to bottom │
│ ├ ð Music/ ││V select/unselect│
│ ├ ð Pictures/ ││ctrl duplicate as │
│ ├ ð Public/ ││ctrl next visit │
╰────────────────────╯╰────────────────────╯
```
A layout is a [sum type][56] can be one of the following:
A layout can be one of the following:
- [Nothing][8]
- [Table][9]
@ -99,7 +86,7 @@ Type: { Static = [Custom Panel][27] }
This is a custom layout to render dynamic content using a function defined in
[xplr.fn][28] that takes [Content Renderer Argument][36] and returns [Custom Panel][27].
Type: { Dynamic = "[Content Renderer][35]" }
Type: { Dynamic = [Content Renderer][35] }
### Horizontal
@ -110,7 +97,7 @@ It contains the following information:
- [config][15]
- [splits][17]
Type: { Vertical = { config = [Layout Config][15], splits = { [Layout][17], ... } }
Type: { Horizontal = { config = [config][15], splits = [splits][17] }
### Vertical
@ -121,7 +108,7 @@ It contains the following information:
- [config][15]
- [splits][17]
Type: { Vertical = { config = [Layout Config][15], splits = { [Layout][17], ... } }
Type: { Vertical = { config = [config][15], splits = [splits][17] }
## Layout Config
@ -158,7 +145,7 @@ The constraints applied on the layout.
## Constraint
A constraint is a [sum type][56] can be one of the following:
A constraint can be one of the following:
- { Percentage = int }
- { Ratio = { int, int } }
@ -186,12 +173,11 @@ The list of child layouts to fit into the parent layout.
## Custom Panel
Custom panel is a [sum type][56] can be one of the following:
Custom panel can be one of the following:
- [CustomParagraph][29]
- [CustomList][30]
- [CustomTable][31]
- [CustomLayout][55]
### CustomParagraph
@ -213,16 +199,6 @@ xplr.config.layouts.builtin.default = {
}
```
Result:
```
╭ custom title ────────╮
│custom body │
│ │
│ │
╰──────────────────────╯
```
#### Example: Render a custom dynamic paragraph
```lua
@ -238,23 +214,6 @@ xplr.fn.custom.render_layout = function(ctx)
end
```
Result:
```
╭/home/sayanarijit───────────────────────────╮
│mime_essence: inode/directory │
│relative_path: Desktop │
│is_symlink: false │
│is_readonly: false │
│parent: /home/sayanarijit │
│absolute_path: /home/sayanarijit/Desktop │
│is_broken: false │
│created: 1668087850396758714 │
│size: 4096 │
│gid: 100 │
╰────────────────────────────────────────────╯
```
### CustomList
A list to render. It contains the following fields:
@ -275,17 +234,6 @@ xplr.config.layouts.builtin.default = {
}
```
Result:
```
╭ custom title ─────────────╮
│1 │
│2 │
│3 │
│ │
╰───────────────────────────╯
```
#### Example: Render a custom dynamic list
```lua
@ -305,18 +253,6 @@ xplr.fn.custom.render_layout = function(ctx)
end
```
Result:
```
╭/home/sayanarijit──────────╮
│Desktop │
│0.21.2 │
│17336 │
│ │
│ │
╰───────────────────────────╯
```
## CustomTable
A custom table to render. It contains the following fields:
@ -346,18 +282,6 @@ xplr.config.layouts.builtin.default = {
}
```
Result:
```
╭ custom title ────────────────────╮
│a b │
│c d │
│ │
│ │
│ │
╰──────────────────────────────────╯
```
#### Example: Render a custom dynamic table
```lua
@ -384,95 +308,6 @@ xplr.fn.custom.render_layout = function(ctx)
end
```
Result:
```
╭/home/sayanarijit───────────────────────────╮
│ │
│Layout height 12 │
│Layout width 46 │
│ │
│Screen height 12 │
│Screen width 46 │
│ │
│ │
│ │
│ │
╰────────────────────────────────────────────╯
```
### CustomLayout
A whole custom layout to render. It doesn't make sense to use it as a
[Static][25] layout, but can be very useful to render as a [Dynamic][26] layout
for use cases where the structure of the layout needs to change without having
to switch modes.
> WARNING: Rendering the same dynamic custom layout recursively will result in
> a ugly crash.
#### Example: Render a custom dynamic layout
```lua
xplr.config.layouts.builtin.default = { Dynamic = "custom.render_layout" }
xplr.fn.custom.render_layout = function(ctx)
local inner = {
config = {
constraints = {
{ Percentage = 50 },
{ Percentage = 50 },
},
},
splits = {
{ Static = { CustomParagraph = { body = "Try your luck..." } } },
{ Static = { CustomParagraph = { body = "Press ctrl-r" } } },
},
}
local layout_type = "Vertical"
if math.random(1, 2) == 1 then
layout_type = "Horizontal"
end
return { CustomLayout = { [layout_type] = inner } }
end
```
Result:
```
╭─────────────────────╮╭─────────────────────╮
│Try your luck... ││Press ctrl-r │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
╰─────────────────────╯╰─────────────────────╯
```
Or
```
╭────────────────────────────────────────────╮
│Try your luck... │
│ │
│ │
│ │
╰────────────────────────────────────────────╯
╭────────────────────────────────────────────╮
│Press ctrl-r │
│ │
│ │
│ │
╰────────────────────────────────────────────╯
```
## Panel UI Config
It contains the following optional fields:
@ -495,7 +330,6 @@ It contains the following information:
- [layout_size][37]
- [screen_size][37]
- [scrolltop][57]
- [app][38]
### Size
@ -509,19 +343,13 @@ 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
heavyweight fields like [directory_buffer][50] are omitted for performance
reasons.
Hence, only the following fields are available.
Hence, only the following fields are avilable.
- [version][40]
- [pwd][41]
@ -562,6 +390,8 @@ Hence, only the following fields are available.
[20]: #vertical_margin
[21]: #constraints
[22]: #constraint
[23]: https://s6.gifyu.com/images/layout.png
[24]: https://gifyu.com/image/1X38
[25]: #static
[26]: #dynamic
[27]: #custom-panel
@ -592,6 +422,3 @@ Hence, only the following fields are available.
[52]: lua-function-calls.md#vroot
[53]: lua-function-calls.md#initial_pwd
[54]: borders.md#border-type
[55]: #customlayout
[56]: sum-type.md
[57]: #scrolltop

@ -12,13 +12,15 @@ You can add new panels in `xplr.config.layouts.custom`.
##### Example: Defining Custom Layout
![demo](https://s6.gifyu.com/images/layout.png)
```lua
xplr.config.layouts.builtin.default = {
Horizontal = {
config = {
margin = 1,
horizontal_margin = 1,
vertical_margin = 1,
horizontal_margin = 2,
vertical_margin = 3,
constraints = {
{ Percentage = 50 },
{ Percentage = 50 },
@ -32,21 +34,6 @@ xplr.config.layouts.builtin.default = {
}
```
Result:
```
╭ /home ─────────────╮╭ Help [default] ────╮
│ ╭─── path ││. show hidden │
│ ├▸[ð Desktop/] ││/ search │
│ ├ ð Documents/ ││: action │
│ ├ ð Downloads/ ││? global help │
│ ├ ð GitHub/ ││G go to bottom │
│ ├ ð Music/ ││V select/unselect│
│ ├ ð Pictures/ ││ctrl duplicate as │
│ ├ ð Public/ ││ctrl next visit │
╰────────────────────╯╰────────────────────╯
```
#### xplr.config.layouts.builtin.default
The default layout

@ -372,7 +372,7 @@ The searcher to use (if any).
Type: nullable [Node Searcher Applicable][82]
## Also See:
## Also Ssee:
- [xplr.util][85]

@ -1,9 +1,7 @@
# Message
You can think of xplr as a server. Just like web servers listen to HTTP
requests, xplr listens to messages.
A message is a [sum type][9] that can have [these possible values][1].
requests, xplr listens to [messages][1].
You can send these messages to an xplr session in the following ways:
@ -15,35 +13,22 @@ You can send these messages to an xplr session in the following ways:
### Format
To send messages using the [key bindings][2] or [Lua function calls][3],
messages are represented in [Lua][5] syntax.
For example:
To send messages using the [key bindings][2] or
[Lua function calls][3], messages are represented in
[Lua][5] syntax. For example:
- `"Quit"`
- `{ FocusPath = "/path/to/file" }`
- `{ Call = { command = "bash", args = { "-c", "read -p test" } } }`
However, to send messages using the [input pipe][4], they need to be
represented using [YAML][6] (or [JSON][7]) syntax.
For example:
represented using
[YAML][6] (or [JSON][7]) syntax. For example:
- `Quit`
- `FocusPath: "/path/to/file"`
- `Call: { command: bash, args: ["-c", "read -p test"] }`
Use `"$XPLR" -m TEMPLATE [VALUE]...` command-line option to safely format
`TEMPLATE` into a valid message. If uses [jf][8] to parse and render the
template. And `$XPLR` (rather than `xplr`) makes sure that the correct version
of the binary is being used.
For example:
- `"$XPLR" -m Quit`
- `"$XPLR" -m 'FocusPath: %q' "/path/to/file"`
- `"$XPLR" -m 'Call: { command: %q, args: [%*q] }' bash -c "read -p test"`
## Also See:
- [Full List of Messages][1]
@ -55,5 +40,3 @@ For example:
[5]: https://www.lua.org/
[6]: http://yaml.org/
[7]: https://www.json.org
[8]: https://github.com/sayanarijit/jf
[9]: sum-type.md

@ -320,24 +320,6 @@ 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.
@ -407,7 +389,7 @@ Example:
Update the input buffer using cursor based operations.
Type: { UpdateInputBuffer = [Input Operation](https://xplr.dev/en/input-operation) }
Type: { UpdateInputBuffer = [Input Opertaion](https://xplr.dev/en/input-operation) }
Example:
@ -436,7 +418,7 @@ Example:
#### BufferInputFromKey
Append/buffer the character read from a keyboard input into the
Append/buffer the characted read from a keyboard input into the
input buffer.
Example:
@ -861,7 +843,7 @@ Example:
Add a [filter](https://xplr.dev/en/filtering#filter) to exclude nodes
while exploring directories.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
Filters get automatically cleared when changing directories.
Type: { AddNodeFilter = { filter = [Filter](https://xplr.dev/en/filtering#filter), input = "string" }
@ -874,7 +856,7 @@ Example:
#### RemoveNodeFilter
Remove an existing [filter](https://xplr.dev/en/filtering#filter).
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
Type: { RemoveNodeFilter = { filter = [Filter](https://xplr.dev/en/filtering), input = "string" }
@ -887,7 +869,7 @@ Example:
Remove a [filter](https://xplr.dev/en/filtering#filter) if it exists,
else, add a it.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
Type: { ToggleNodeFilter = { filter = [Filter](https://xplr.dev/en/filtering), input = "string" }
@ -900,7 +882,7 @@ Example:
Add a node [filter](https://xplr.dev/en/filtering#filter) reading the
input from the buffer.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
Type: { AddNodeFilterFromInput = [Filter](https://xplr.dev/en/filtering) }
@ -913,7 +895,7 @@ Example:
Remove a node [filter](https://xplr.dev/en/filtering#filter) reading
the input from the buffer.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
Type: { RemoveNodeFilterFromInput = [Filter](https://xplr.dev/en/filtering) }
@ -925,7 +907,7 @@ Example:
#### RemoveLastNodeFilter
Remove the last node [filter](https://xplr.dev/en/filtering).
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
Example:
@ -936,7 +918,7 @@ Example:
Reset the node [filters](https://xplr.dev/en/filtering) back to the
default configuration.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
Example:
@ -946,7 +928,7 @@ Example:
#### ClearNodeFilters
Clear all the node [filters](https://xplr.dev/en/filtering).
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
Example:
@ -959,7 +941,7 @@ Example:
Add a [sorter](https://xplr.dev/en/sorting#sorter) to sort nodes while
exploring directories.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
Type: { AddNodeSorter = { sorter = [Sorter](https://xplr.dev/en/sorting#sorter), reverse = bool } }
@ -971,7 +953,7 @@ Example:
#### RemoveNodeSorter
Remove an existing [sorter](https://xplr.dev/en/sorting#sorter).
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
Type: { RemoveNodeSorter = [Sorter](https://xplr.dev/en/sorting#sorter) }
@ -983,7 +965,7 @@ Example:
#### ReverseNodeSorter
Reverse a node [sorter](https://xplr.dev/en/sorting#sorter).
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
Type: { ReverseNodeSorter = [Sorter](https://xplr.dev/en/sorting#sorter) }
@ -996,7 +978,7 @@ Example:
Remove a [sorter](https://xplr.dev/en/sorting#sorter) if it exists,
else, add a it.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
Type: { ToggleNodeSorter = { sorter = [Sorter](https://xplr.dev/en/sorting#sorter), reverse = bool } }
@ -1008,7 +990,7 @@ Example:
#### ReverseNodeSorters
Reverse the node [sorters](https://xplr.dev/en/sorting#sorter).
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
Example:
@ -1018,7 +1000,7 @@ Example:
#### RemoveLastNodeSorter
Remove the last node [sorter](https://xplr.dev/en/sorting#sorter).
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
Example:
@ -1029,7 +1011,7 @@ Example:
Reset the node [sorters](https://xplr.dev/en/sorting#sorter) back to
the default configuration.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
Example:
@ -1039,7 +1021,7 @@ Example:
#### ClearNodeSorters
Clear all the node [sorters](https://xplr.dev/en/sorting#sorter).
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
Example:
@ -1051,7 +1033,7 @@ Example:
#### Search
Search files using the current or default (fuzzy) search algorithm.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
It gets reset automatically when changing directory.
Type: { Search = "string" }
@ -1074,7 +1056,7 @@ Example:
Search files using fuzzy match algorithm.
It keeps the filters, but overrides the sorters.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
It gets reset automatically when changing directory.
Type: { SearchFuzzy = "string" }
@ -1087,7 +1069,7 @@ Example:
#### SearchFuzzyFromInput
Calls `SearchFuzzy` with the input taken from the input buffer.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
It gets reset automatically when changing directory.
Example:
@ -1098,7 +1080,7 @@ Example:
#### SearchFuzzyUnordered
Like `SearchFuzzy`, but doesn't not perform rank based sorting.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
It gets reset automatically when changing directory.
Type: { SearchFuzzyUnordered = "string" }
@ -1111,7 +1093,7 @@ Example:
#### SearchFuzzyUnorderedFromInput
Calls `SearchFuzzyUnordered` with the input taken from the input buffer.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
It gets reset automatically when changing directory.
Example:
@ -1123,7 +1105,7 @@ Example:
Search files using regex match algorithm.
It keeps the filters, but overrides the sorters.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
It gets reset automatically when changing directory.
Type: { SearchRegex = "string" }
@ -1136,7 +1118,7 @@ Example:
#### SearchRegexFromInput
Calls `SearchRegex` with the input taken from the input buffer.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
It gets reset automatically when changing directory.
Example:
@ -1147,7 +1129,7 @@ Example:
#### SearchRegexUnordered
Like `SearchRegex`, but doesn't not perform rank based sorting.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
It gets reset automatically when changing directory.
Type: { SearchRegexUnordered = "string" }
@ -1160,7 +1142,7 @@ Example:
#### SearchRegexUnorderedFromInput
Calls `SearchRegexUnordered` with the input taken from the input buffer.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
It gets reset automatically when changing directory.
Example:
@ -1172,7 +1154,7 @@ Example:
Toggles between different search algorithms, without changing the input
buffer
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
Example:
@ -1182,7 +1164,7 @@ Example:
#### EnableSearchOrder
Enables ranked search without changing the input buffer.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
Example:
@ -1192,7 +1174,7 @@ Example:
#### DisableSearchOrder
Disabled ranked search without changing the input buffer.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
Example:
@ -1282,7 +1264,7 @@ Example:
#### ToggleFifo
Toggle between {Start|Stop}Fifo
Toggle betwen {Start|Stop}Fifo
Type: { ToggleFifo = "string" }

@ -35,18 +35,6 @@ 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.

@ -88,7 +88,7 @@ Example:
xplr.config.node_types.mime_essence = {
application = {
-- application/*
["*"] = { meta = { icon = "a" } },
["*"] = { meta = { icon = "a" } }
-- application/pdf
pdf = { meta = { icon = "" }, style = { fg = "Blue" } },

@ -24,7 +24,7 @@ Node Searcher contains the following fields:
### pattern
The patterns used to search.
The patters used to search.
Type: string

@ -27,7 +27,7 @@ It contains the following information:
### sorter
A sorter is a [sum type][4] that can be one of the following:
A sorter can be one of the following:
- "ByRelativePath"
- "ByIRelativePath"
@ -82,4 +82,3 @@ This snippet defines the initial sorting logic to be applied when xplr loads.
[1]: #node-sorter-applicable
[2]: #sorter
[3]: #reverse
[4]: sum-type.md

@ -33,7 +33,7 @@ Modifiers to remove.
## Color
Color is a [sum type][7] that can be one of the following:
Color can be one of the following:
- "Reset"
- "Black"
@ -57,7 +57,7 @@ Color is a [sum type][7] that can be one of the following:
## Modifier
Modifier is a [sum type][7] that can be one of the following:
Modifier can be one of the following:
- "Bold"
- "Dim"
@ -84,4 +84,3 @@ xplr.config.general.prompt.style.sub_modifiers = { "Hidden" }
[4]: #sub_modifiers
[5]: #color
[6]: #modifier
[7]: sum-type.md

@ -1,96 +0,0 @@
# Sum Type
> This section isn't specific to xplr. However, since xplr configuration makes
> heavy use of this particular data type, even though it isn't available in
> most of the mainstream programming languages (yet), making it a wild or
> unfamiliar concept for many, it's worth doing a quick introduction here.
>
> If you're already familiar with [Sum Type / Tagged Union][1] (e.g. Rust's
> enum), you can skip ahead.
While reading this doc, you'll come across some data types like [Layout][2],
[Color][4], [Message][3] etc. that says something like "x is a sum type that
can be any of the following", and then you'll see a list of strings and/or lua
tables just below.
Yes, they are actually sum types, i.e. they can be any of the given set of
tagged variants listed there.
Notice the word "be". Unlike classes or structs (aka product types), they can't
"have" values, they can only "be" the value, or rather, be one of the possible
set of values.
Also notice the word "tagged". Unlike the single variant `null`, or the dual
variant `boolean` types, the variants of sum types are tagged (i.e. named), and
may further have, or be, value or values of any data type.
A simple example of a sum type is an enum. Many programming languages have
them, but only a few modern programming languages allow nesting other types
into a sum type.
```rust
enum Color {
Red,
Green,
}
```
Here, `Color` can be one of two possible set of values: `Red` and `Green`, just
like `boolean`, but unlike `boolean`, being tagged allows `Color` to have more
than two variants if required, by changing the definition.
e.g.
```rust
enum Color {
Red,
Green,
Blue,
}
```
We'd document it here as:
> Result is a sum type that can be one of the following:
>
> - "Red"
> - "Green"
> - "Blue"
But some languages (like Rust, Haskell, Elm etc.) go even further, allowing us
to associate each branch of the enum with further nested types like:
```rust
enum Layout {
Table,
HelpMenu,
Horizontal {
config: LayoutConfig, // A product type (similar to class/struct)
splits: Vec<Layout> // A list of "Layout"s (i.e. list of sum types)
},
}
```
Here, as we can see, unlike the first example, some of `Layout`'s possible
variants can have further nested types associated with them. Note that
`Horizontal` here can have a sum type (e.g. enum), or a product type (e.g.
class/struct), or both (any number of them actually) nested in it. But the
nested values will only exist when `Layout` is `Horizontal`.
We'd document it here as:
> Layout is a sum type that can be one of the following:
>
> - "Table"
> - "HelpMenu"
> - { Horizontal = { config = Layout Config, splits = { Layout, ... } }
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.
[1]: https://en.wikipedia.org/wiki/Tagged_union
[2]: layout.md
[3]: message.md
[4]: style.md#color

@ -45,7 +45,7 @@ compatibility.
### Instructions
#### [v0.20.2][48] -> [v0.21.9][49]
#### [v0.20.2][48] -> [v0.21.1][49]
- Some plugins might stop rendering colors. Wait for them to update.
- Rename `xplr.config.general.sort_and_filter_ui.search_identifier` to
@ -81,7 +81,7 @@ compatibility.
- `:ss` to create softlink of the selected items.
- `:sh` to create hardlink of the selected items.
- `:se` to edit selection list in your $EDITOR.
- Better conflict handling: prompt for action.
- Better conflict handling: add suffix rather than overriding/skipping.
- Navigate between the selected paths using the following messages:
- FocusPreviousSelection (`ctrl-p`)
- FocusNextSelection (`ctrl-n`)
@ -98,7 +98,7 @@ compatibility.
rendered:
- xplr.config.general.selection.item.format
- xplr.config.general.selection.item.style
- Use the following utility functions to work with the file permissions:
- Use the following utility functions to work with teh file permissions:
- xplr.util.permissions_rwx
- xplr.util.permissions_octal
- Type `:p` to edit file permissions interactively.
@ -118,22 +118,6 @@ compatibility.
- xplr.util.shell_escape
- 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.
@ -221,6 +205,8 @@ 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.
@ -319,7 +305,7 @@ Thanks to @noahmayr for contributing to a major part of this release.
- You can disable the recover mode using `config.general.disable_recover_mode = true`.
- Try running `xplr --help`. Yes, CLI has been implemented.
- Since version `v0.14.3`, `StartFifo` and `ToggleFifo` will write to the FIFO
path when called. So, there's no need to pipe the focus path explicitly.
path when called. So, there's no need to pipe the focus path explicitely.
- Since version `v0.14.3`, general config `xplr.config.start_fifo` is available
which can be set to a file path to start a fifo when xplr starts.
- Since version `v0.14.4`, `$XPLR_SESSION_PATH` can be used to dump session
@ -330,7 +316,7 @@ Thanks to @noahmayr for contributing to a major part of this release.
#### [v0.12.1][6] -> [v0.13.7][2]
- Lua functions called using [`CallLua`][7] and [`CallLuaSilently`][8] messages will receive [`CallLuaArg`][9] object as the function argument (instead of the [`App`][10] object).
- Each `node_types` config will inherit defaults from matching less specific `node_types` config and overwrite them.
- Each `node_types` config will inherit defaults from matching less specifig `node_types` config and overwrite them.
- Since version `v0.13.2`, you don't need to use/send `Refresh` anymore. It will be auto-handled by xplr.
#### [v0.11.1][11] -> [v0.12.1][6]
@ -486,6 +472,7 @@ 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
@ -529,5 +516,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.9
[49]: https://github.com/sayanarijit/xplr/releases/tag/v0.21.1
[50]: https://github.com/lotabout/skim#search-syntax

@ -69,7 +69,9 @@ Visit [Awesome Plugins][5] for xplr plugin examples.
## Also See
- [Tip: A list of hacks yet to make it as Lua plugins][15]
- [Tip: Some UI and theming tips][12]
- [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]
@ -90,5 +92,7 @@ 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
[15]: awesome-hacks.md
[13]: https://github.com/sayanarijit/xplr/discussions/273
[14]: https://github.com/sayanarijit/xplr/discussions/250
[15]: https://github.com/sayanarijit/xplr/wiki/Hacks
[16]: https://github.com/sayanarijit/xplr/discussions/529#discussioncomment-4073734

@ -11,23 +11,6 @@ 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.
@ -303,7 +286,7 @@ Example:
```lua
xplr.util.shell_execute("pwd")
-- { stdout = "/present/working/directory", stderr = "", returncode = 0 }
-- "/present/working/directory"
xplr.util.shell_execute("bash", {"-c", "xplr --help"})
-- { stdout = "xplr...", stderr = "", returncode = 0 }
@ -397,7 +380,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]
Type: function( path:string ) -> [Style][3]|nil
Example:

@ -1,11 +1,11 @@
<!DOCTYPE HTML>
<html lang="{{ language }}" class="{{ default_theme }}" dir="{{ text_direction }}">
<html lang="{{ language }}" class="sidebar-visible no-js {{ default_theme }}">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>{{ title }}</title>
{{#if is_print }}
<meta name="robots" content="noindex">
<meta name="robots" content="noindex" />
{{/if}}
{{#if base_url}}
<base href="{{ base_url }}">
@ -15,9 +15,10 @@
<!-- Custom HTML head -->
{{> head}}
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="{{ description }}">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff">
<meta name="theme-color" content="#ffffff" />
{{#if favicon_svg}}
<link rel="icon" href="{{ path_to_root }}favicon.svg">
@ -50,22 +51,21 @@
{{#if mathjax_support}}
<!-- MathJax -->
<script async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script async type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
{{/if}}
<!-- EthicalAds -->
<script async src="https://media.ethicalads.io/media/client/ethicalads.min.js"></script>
</head>
<body class="sidebar-visible no-js">
<div id="body-container">
<body>
<!-- Provide site root to javascript -->
<script>
<script type="text/javascript">
var path_to_root = "{{ path_to_root }}";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "{{ preferred_dark_theme }}" : "{{ default_theme }}";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script>
<script type="text/javascript">
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
@ -81,38 +81,32 @@
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script>
<script type="text/javascript">
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('no-js')
html.classList.remove('{{ default_theme }}')
html.classList.add(theme);
var body = document.querySelector('body');
body.classList.remove('no-js')
body.classList.add('js');
html.classList.add('js');
</script>
<input type="checkbox" id="sidebar-toggle-anchor" class="hidden">
<!-- Hide / unhide sidebar before it is displayed -->
<script>
var body = document.querySelector('body');
var sidebar = null;
var sidebar_toggle = document.getElementById("sidebar-toggle-anchor");
<script type="text/javascript">
var html = document.querySelector('html');
var sidebar = 'hidden';
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
} else {
sidebar = 'hidden';
}
sidebar_toggle.checked = sidebar === 'visible';
body.classList.remove('sidebar-visible');
body.classList.add("sidebar-" + sidebar);
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox">
{{#toc}}{{/toc}}
<!-- EthicalAds -->
@ -122,53 +116,30 @@
data-ea-publisher="xplrdev"
data-ea-type="image"
></div>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle">
<div class="sidebar-resize-indicator"></div>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
<!-- Track and set sidebar scroll position -->
<script>
var sidebarScrollbox = document.querySelector('#sidebar .sidebar-scrollbox');
sidebarScrollbox.addEventListener('click', function(e) {
if (e.target.tagName === 'A') {
sessionStorage.setItem('sidebar-scroll', sidebarScrollbox.scrollTop);
}
}, { passive: true });
var sidebarScrollTop = sessionStorage.getItem('sidebar-scroll');
sessionStorage.removeItem('sidebar-scroll');
if (sidebarScrollTop) {
// preserve sidebar scroll position when navigating via links within sidebar
sidebarScrollbox.scrollTop = sidebarScrollTop;
} else {
// scroll sidebar to current active section when navigating via "next/previous chapter" buttons
var activeSection = document.querySelector('#sidebar .active');
if (activeSection) {
activeSection.scrollIntoView({ block: 'center' });
}
}
</script>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
{{> header}}
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky">
<div id="menu-bar" class="menu-bar sticky bordered">
<div class="left-buttons">
<label id="sidebar-toggle" class="icon-button" for="sidebar-toggle-anchor" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</label>
</button>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
<li role="none"><button role="menuitem" class="theme" id="light">{{ theme_option "Light" }}</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">{{ theme_option "Rust" }}</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">{{ theme_option "Coal" }}</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">{{ theme_option "Navy" }}</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">{{ theme_option "Ayu" }}</button></li>
</ul>
{{#if search_enabled}}
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
@ -213,7 +184,7 @@
{{/if}}
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script>
<script type="text/javascript">
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
@ -235,7 +206,7 @@
{{/previous}}
{{#next}}
<a rel="next prefetch" href="{{ path_to_root }}{{link}}" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a rel="next" href="{{ path_to_root }}{{link}}" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
{{/next}}
@ -253,7 +224,7 @@
{{/previous}}
{{#next}}
<a rel="next prefetch" href="{{ path_to_root }}{{link}}" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a rel="next" href="{{ path_to_root }}{{link}}" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
{{/next}}
@ -261,12 +232,10 @@
</div>
{{#if live_reload_endpoint}}
{{#if livereload}}
<!-- Livereload script (if served using the cli tool) -->
<script>
const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
const wsAddress = wsProtocol + "//" + location.host + "/" + "{{{live_reload_endpoint}}}";
const socket = new WebSocket(wsAddress);
<script type="text/javascript">
var socket = new WebSocket("{{{livereload}}}");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
@ -282,7 +251,7 @@
{{#if google_analytics}}
<!-- Google Analytics Tag -->
<script>
<script type="text/javascript">
var localAddrs = ["localhost", "127.0.0.1", ""];
// make sure we don't activate google analytics if the developer is
@ -300,43 +269,43 @@
{{/if}}
{{#if playground_line_numbers}}
<script>
<script type="text/javascript">
window.playground_line_numbers = true;
</script>
{{/if}}
{{#if playground_copyable}}
<script>
<script type="text/javascript">
window.playground_copyable = true;
</script>
{{/if}}
{{#if playground_js}}
<script src="{{ path_to_root }}ace.js"></script>
<script src="{{ path_to_root }}editor.js"></script>
<script src="{{ path_to_root }}mode-rust.js"></script>
<script src="{{ path_to_root }}theme-dawn.js"></script>
<script src="{{ path_to_root }}theme-tomorrow_night.js"></script>
<script src="{{ path_to_root }}ace.js" type="text/javascript" charset="utf-8"></script>
<script src="{{ path_to_root }}editor.js" type="text/javascript" charset="utf-8"></script>
<script src="{{ path_to_root }}mode-rust.js" type="text/javascript" charset="utf-8"></script>
<script src="{{ path_to_root }}theme-dawn.js" type="text/javascript" charset="utf-8"></script>
<script src="{{ path_to_root }}theme-tomorrow_night.js" type="text/javascript" charset="utf-8"></script>
{{/if}}
{{#if search_js}}
<script src="{{ path_to_root }}elasticlunr.min.js"></script>
<script src="{{ path_to_root }}mark.min.js"></script>
<script src="{{ path_to_root }}searcher.js"></script>
<script src="{{ path_to_root }}elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="{{ path_to_root }}mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="{{ path_to_root }}searcher.js" type="text/javascript" charset="utf-8"></script>
{{/if}}
<script src="{{ path_to_root }}clipboard.min.js"></script>
<script src="{{ path_to_root }}highlight.js"></script>
<script src="{{ path_to_root }}book.js"></script>
<script src="{{ path_to_root }}clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="{{ path_to_root }}highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="{{ path_to_root }}book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts -->
{{#each additional_js}}
<script src="{{ ../path_to_root }}{{this}}"></script>
<script type="text/javascript" src="{{ ../path_to_root }}{{this}}"></script>
{{/each}}
{{#if is_print}}
{{#if mathjax_support}}
<script>
<script type="text/javascript">
window.addEventListener('load', function() {
MathJax.Hub.Register.StartupHook('End', function() {
window.setTimeout(window.print, 100);
@ -344,7 +313,7 @@
});
</script>
{{else}}
<script>
<script type="text/javascript">
window.addEventListener('load', function() {
window.setTimeout(window.print, 100);
});
@ -352,6 +321,5 @@
{{/if}}
{{/if}}
</div>
</body>
</html>

@ -151,7 +151,7 @@
<li class="nav-item">
<a
class="nav-link page-scroll"
href="https://blog.xplr.dev"
href="https://xplr.stck.me"
target="_blank"
rel="noreferrer noopener"
>

@ -1,11 +0,0 @@
v="0.4.40"
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

@ -1,12 +1,97 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1650374568,
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"lowdown-src": {
"flake": false,
"locked": {
"lastModified": 1633514407,
"narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=",
"owner": "kristapsdz",
"repo": "lowdown",
"rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8",
"type": "github"
},
"original": {
"owner": "kristapsdz",
"repo": "lowdown",
"type": "github"
}
},
"nix": {
"inputs": {
"lowdown-src": "lowdown-src",
"nixpkgs": "nixpkgs",
"nixpkgs-regression": "nixpkgs-regression"
},
"locked": {
"lastModified": 1667849540,
"narHash": "sha256-kqo8PTE3i21Z0pnxJwcwCQRZKKC15Y8xFTEN6qko3M8=",
"owner": "domenkozar",
"repo": "nix",
"rev": "3dcbdd412592413f34552a50403daf58656d43e6",
"type": "github"
},
"original": {
"owner": "domenkozar",
"ref": "relaxed-flakes",
"repo": "nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1704262187,
"narHash": "sha256-N4j9qghlp/Eb3Z11WF7Cb9U91AXwpascUbLH7YKMcLc=",
"lastModified": 1657693803,
"narHash": "sha256-G++2CJ9u0E7NNTAi9n5G8TdDmGJXcIjkJ3NF8cetQB8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "365e1b3a859281cf11b94f87231adeabbdd878a2",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-22.05-small",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-regression": {
"locked": {
"lastModified": 1643052045,
"narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1668199800,
"narHash": "sha256-qnEeVo88H8an0Wds9kBSxWlGCa0vY5EgEswnQUZnXmc=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "65f0d241783c94a08e4c9a3870736fc8854dd520",
"rev": "98bb201bbfba99003e6cd5f85c13c46050fb8ee8",
"type": "github"
},
"original": {
@ -17,7 +102,9 @@
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
"flake-compat": "flake-compat",
"nix": "nix",
"nixpkgs": "nixpkgs_2"
}
}
},

@ -3,26 +3,30 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
nix.url = "github:domenkozar/nix/relaxed-flakes";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = inputs@{ self, nixpkgs, ... }:
outputs = { self, nixpkgs, nix, ... }:
let
lib = nixpkgs.lib;
darwin = [ "x86_64-darwin" "aarch64-darwin" ];
linux = [ "x86_64-linux" "x86_64-linux-musl" "aarch64-linux" "aarch64-linux-android" "i86_64-linux" ];
allSystems = darwin ++ linux;
forEachSystem = systems: f: lib.genAttrs systems (system: f system);
forAllSystems = forEachSystem allSystems;
systems = [
"x86_64-linux"
"i686-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
];
forAllSystems = f: builtins.listToAttrs (map (name: { inherit name; value = f name; }) systems);
in
{
packages = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
in
rec {
# e.g. nix build .#xplr
{
xplr = pkgs.rustPlatform.buildRustPackage rec {
name = "xplr";
src = ./.;
@ -30,14 +34,6 @@
lockFile = ./Cargo.lock;
};
};
# e.g. nix build .#cross.x86_64-linux-musl.xplr --impure
cross = forEachSystem (lib.filter (sys: sys != system) allSystems) (targetSystem:
let
crossPkgs = import nixpkgs { localSystem = system; crossSystem = targetSystem; };
in
{ inherit (crossPkgs) xplr; }
);
}
);
defaultPackage = forAllSystems (system: self.packages.${system}.xplr);
@ -58,9 +54,6 @@
default = pkgs.mkShell {
RUST_BACKTRACE = 1;
# For cross compilation
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM = 1;
buildInputs = devRequirements;
packages = devRequirements;
};

@ -1,26 +0,0 @@
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

@ -2,7 +2,6 @@ use crate::config::Config;
use crate::config::Hooks;
use crate::config::Mode;
pub use crate::directory_buffer::DirectoryBuffer;
use crate::dirs;
use crate::explorer;
use crate::input::{InputOperation, Key};
use crate::lua;
@ -135,10 +134,6 @@ 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();
@ -171,47 +166,8 @@ impl History {
self.cleanup()
}
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
}
fn peek(&self) -> Option<&String> {
self.paths.get(self.loc)
}
}
@ -298,8 +254,8 @@ impl App {
let config_file = if let Some(path) = config_file {
Some(path)
} else if let Some(dir) = dirs::config_dir() {
let path = dir.join("xplr/init.lua");
} else if let Some(dir) = dirs::home_dir() {
let path = dir.join(".config/xplr/init.lua");
if path.exists() {
Some(path)
} else {
@ -314,7 +270,9 @@ impl App {
}
};
let config_files = config_file.into_iter().chain(extra_config_files);
let config_files = config_file
.into_iter()
.chain(extra_config_files.into_iter());
let mut load_errs = vec![];
for config_file in config_files {
@ -335,12 +293,12 @@ impl App {
&config
.general
.initial_mode
.clone()
.to_owned()
.unwrap_or_else(|| "default".into()),
) {
Some(m) => m.clone().sanitized(
config.general.read_only,
config.general.global_key_bindings.clone(),
config.general.global_key_bindings.to_owned(),
),
None => {
bail!("'default' mode is missing")
@ -351,7 +309,7 @@ impl App {
&config
.general
.initial_layout
.clone()
.to_owned()
.unwrap_or_else(|| "default".into()),
) {
Some(l) => l.clone(),
@ -362,6 +320,7 @@ impl App {
let pid = std::process::id();
let mut session_path = dirs::runtime_dir()
.unwrap_or_else(env::temp_dir)
.join("xplr")
.join("session")
.join(pid.to_string())
@ -387,7 +346,7 @@ impl App {
}
if let Some(sorters) = &config.general.initial_sorting {
explorer_config.sorters.clone_from(sorters);
explorer_config.sorters = sorters.clone();
};
let hostname = gethostname().to_string_lossy().to_string();
@ -414,12 +373,6 @@ 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(),
@ -441,7 +394,7 @@ impl App {
explorer_config,
logs: Default::default(),
logs_hidden: Default::default(),
history: History::default().push(hist),
history: Default::default(),
last_modes: Default::default(),
hostname,
hooks,
@ -471,6 +424,11 @@ impl App {
.unwrap_or_default()
}
fn enqueue(mut self, task: Task) -> Self {
self.msg_out.push_back(MsgOut::Enque(task));
self
}
pub fn handle_batch_external_msgs(mut self, msgs: Vec<ExternalMsg>) -> Result<Self> {
for task in msgs
.into_iter()
@ -499,23 +457,15 @@ impl App {
self.add_last_focus(parent, focus_path)
}
InternalMsg::HandleKey(key) => self.handle_key(key),
InternalMsg::RefreshSelection => self.refresh_selection(),
}
}
fn handle_external(mut self, msg: ExternalMsg, key: Option<Key>) -> Result<Self> {
let is_msg_read_only = msg.is_read_only();
if self.config.general.read_only && !is_msg_read_only {
fn handle_external(self, msg: ExternalMsg, key: Option<Key>) -> Result<Self> {
if self.config.general.read_only && !msg.is_read_only() {
self.log_error("could not execute code in read-only mode.".into())
} else {
use ExternalMsg::*;
if !is_msg_read_only {
// We don't want to operate on imaginary paths.
self = self.refresh_selection()?;
}
self = match msg {
match msg {
ExplorePwd => self.explore_pwd(),
ExploreParentsAsync => self.explore_parents_async(),
ExplorePwdAsync => self.explore_pwd_async(),
@ -552,8 +502,6 @@ 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(),
@ -671,20 +619,9 @@ impl App {
PrintAppStateAndQuit => self.print_app_state_and_quit(),
Debug(path) => self.debug(path),
Terminate => bail!(""),
}?;
if !is_msg_read_only {
// We don't want to keep imaginary paths in the selection.
// But the write action is probably still in queue.
// So we need to refresh selection after the write action.
let msg = InternalMsg::RefreshSelection;
let msg = MsgIn::Internal(msg);
let task = Task::new(msg, None);
self.msg_out.push_back(MsgOut::Enqueue(task));
}
Ok(self)
}
}?
.refresh_selection()
}
fn handle_key(mut self, key: Key) -> Result<Self> {
@ -733,11 +670,7 @@ impl App {
});
for msg in msgs {
// Rename breaks without enqueue
let external = MsgIn::External(msg);
let task = Task::new(external, Some(key));
let msg_out = MsgOut::Enqueue(task);
self.msg_out.push_back(msg_out);
self = self.enqueue(Task::new(MsgIn::External(msg), Some(key)));
}
Ok(self)
@ -820,6 +753,7 @@ 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 {
@ -904,6 +838,7 @@ 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 {
@ -915,7 +850,6 @@ impl App {
dir.focus + 1
}
};
Ok(self)
}
@ -994,7 +928,7 @@ impl App {
fn follow_symlink(self) -> Result<Self> {
if let Some(pth) = self
.focused_node()
.and_then(|n| n.symlink.clone().map(|s| s.absolute_path))
.and_then(|n| n.symlink.to_owned().map(|s| s.absolute_path))
{
self.focus_path(&pth, true)
} else {
@ -1082,23 +1016,19 @@ impl App {
}
fn enter(self) -> Result<Self> {
if let Some(node) = self.focused_node() {
if node.is_dir || node.symlink.as_ref().map(|s| s.is_dir).unwrap_or(false) {
let path = node.absolute_path.clone();
self.change_directory(&path, true)
} else {
Ok(self)
}
if let Some(path) = self.focused_node().map(|n| n.absolute_path.clone()) {
self.change_directory(&path, true)
} else {
Ok(self)
}
}
fn back(self) -> Result<Self> {
let pwd = self.pwd.clone();
if let Some(p) = PathBuf::from(&pwd).parent().and_then(|p| p.to_str()) {
self.change_directory(p, false)
.and_then(|a| a.focus_path(&pwd, true))
if let Some(p) = PathBuf::from(self.pwd.clone())
.parent()
.and_then(|p| p.to_str())
{
self.change_directory(p, true)
} else {
Ok(self)
}
@ -1130,24 +1060,6 @@ 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)
@ -1300,7 +1212,7 @@ impl App {
}
pub fn scroll_up_half(mut self) -> Result<Self> {
self.msg_out.push_back(MsgOut::ScrollUpHalf);
self.msg_out.push_back(MsgOut::ScrollUp);
Ok(self)
}
@ -1381,7 +1293,7 @@ impl App {
self = self.push_mode();
self.mode = mode.sanitized(
self.config.general.read_only,
self.config.general.global_key_bindings.clone(),
self.config.general.global_key_bindings.to_owned(),
);
// Hooks
@ -1406,7 +1318,7 @@ impl App {
self = self.push_mode();
self.mode = mode.sanitized(
self.config.general.read_only,
self.config.general.global_key_bindings.clone(),
self.config.general.global_key_bindings.to_owned(),
);
// Hooks
@ -1433,7 +1345,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.clone();
self.layout = l.to_owned();
// Hooks
if !self.hooks.on_layout_switch.is_empty() {
@ -1449,7 +1361,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.clone();
self.layout = l.to_owned();
// Hooks
if !self.hooks.on_layout_switch.is_empty() {
@ -1556,8 +1468,6 @@ impl App {
if dir.parent == self.pwd {
self.directory_buffer = Some(dir);
// Might as well refresh the selection
self = self.refresh_selection()?;
};
Ok(self)
@ -1573,15 +1483,9 @@ impl App {
}
pub fn select(mut self) -> Result<Self> {
let count = self.selection.len();
if let Some(n) = self.focused_node().cloned() {
if let Some(n) = self.focused_node().map(|n| n.to_owned()) {
self.selection.insert(n);
}
if self.selection.len() != count {
self = self.on_selection_change()?;
}
Ok(self)
}
@ -1589,59 +1493,36 @@ impl App {
let path = PathBuf::from(path).absolutize()?.to_path_buf();
let parent = path.parent().map(|p| p.to_string_lossy().to_string());
let filename = path.file_name().map(|p| p.to_string_lossy().to_string());
let count = self.selection.len();
if let (Some(p), Some(n)) = (parent, filename) {
self.selection.insert(Node::new(p, n));
}
if self.selection.len() != count {
self = self.on_selection_change()?;
}
Ok(self)
}
pub fn select_all(mut self) -> Result<Self> {
let count = self.selection.len();
if let Some(d) = self.directory_buffer.as_ref() {
self.selection.extend(d.nodes.clone());
};
if self.selection.len() != count {
self = self.on_selection_change()?;
}
Ok(self)
}
pub fn un_select_path(mut self, path: String) -> Result<Self> {
let pathbuf = PathBuf::from(path).absolutize()?.to_path_buf();
let count = self.selection.len();
self.selection
.retain(|n| PathBuf::from(&n.absolute_path) != pathbuf);
if self.selection.len() != count {
self = self.on_selection_change()?;
}
Ok(self)
}
pub fn un_select(mut self) -> Result<Self> {
let count = self.selection.len();
if let Some(n) = self.focused_node().cloned() {
if let Some(n) = self.focused_node().map(|n| n.to_owned()) {
self.selection
.retain(|s| s.absolute_path != n.absolute_path);
}
if self.selection.len() != count {
self = self.on_selection_change()?;
}
Ok(self)
}
pub fn un_select_all(mut self) -> Result<Self> {
let count = self.selection.len();
if let Some(d) = self.directory_buffer.as_ref() {
d.nodes.clone().into_iter().for_each(|n| {
self.selection
@ -1649,10 +1530,6 @@ impl App {
});
};
if self.selection.len() != count {
self = self.on_selection_change()?;
}
Ok(self)
}
@ -1690,11 +1567,7 @@ impl App {
}
fn clear_selection(mut self) -> Result<Self> {
let count = self.selection.len();
self.selection.clear();
if self.selection.len() != count {
self = self.on_selection_change()?;
}
Ok(self)
}
@ -1803,7 +1676,7 @@ impl App {
.config
.general
.initial_sorting
.clone()
.to_owned()
.unwrap_or_default();
Ok(self)
}
@ -2025,28 +1898,12 @@ impl App {
format!("{0}\n", &self.mode.name)
}
// This is a performance heavy function. Use it only when necessary.
fn refresh_selection(mut self) -> Result<Self> {
let count = self.selection.len();
self.selection.retain(|n| {
let p = PathBuf::from(&n.absolute_path);
// Should be able to retain broken symlink
p.exists() || p.symlink_metadata().is_ok()
});
if count != self.selection.len() {
self = self.on_selection_change()?;
}
Ok(self)
}
fn on_selection_change(mut self) -> Result<Self> {
if !self.hooks.on_selection_change.is_empty() {
let msgs = self.hooks.on_selection_change.clone();
self = self.handle_batch_external_msgs(msgs)?
}
Ok(self)
}
@ -2105,10 +1962,8 @@ 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);
std::iter::once((self.mode.name.clone(), self.mode.clone()))
.chain(modes)
builtin.into_iter()
.chain(custom.into_iter())
.map(|(name, mode)| {
(name, mode.sanitized(read_only, global_kb.clone()))
})

@ -15,32 +15,32 @@ fn main() {
xplr [FLAG]... [OPTION]... [PATH] [SELECTION]..."###;
let flags = r###"
- Reads new-line (\n) separated paths from stdin
-- Denotes the end of command-line flags and options
--force-focus Focuses on the given <PATH>, even if it is a directory
-h, --help Prints help information
-m, --pipe-msg-in Helps safely passing messages to the active xplr
session, use %%, %s and %q as the placeholders
-M, --print-msg-in Like --pipe-msg-in, but prints the message instead of
passing to the active xplr session
--print-pwd-as-result Prints the present working directory when quitting
with `PrintResultAndQuit`
--read-only Enables read-only mode (config.general.read_only)
--read0 Reads paths separated using the null character (\0)
--write0 Prints paths separated using the null character (\0)
-0 --null Combines --read0 and --write0
-V, --version Prints version information"###;
- Reads new-line (\n) separated paths from stdin
-- Denotes the end of command-line flags and options
--force-focus Focuses on the given <PATH>, even if it is a directory
-h, --help Prints help information
-m, --pipe-msg-in Helps safely passing messages to the active xplr
session, use %%, %s and %q as the placeholders
-M, --print-msg-in Like --pipe-msg-in, but prints the message instead of
passing to the active xplr session
--print-pwd-as-result Prints the present working directory when quitting
with `PrintResultAndQuit`
--read-only Enables read-only mode (config.general.read_only)
--read0 Reads paths separated using the null character (\0)
--write0 Prints paths separated using the null character (\0)
-0 --null Combines --read0 and --write0
-V, --version Prints version information"###;
let options = r###"
-c, --config <PATH> Specifies a custom config file (default is
"$HOME/.config/xplr/init.lua")
-C, --extra-config <PATH>... Specifies extra config files to load
--on-load <MESSAGE>... Sends messages when xplr loads
--vroot <PATH> Treats the specified path as the virtual root"###;
-c, --config <PATH> Specifies a custom config file (default is
"$HOME/.config/xplr/init.lua")
-C, --extra-config <PATH>... Specifies extra config files to load
--on-load <MESSAGE>... Sends messages when xplr loads
--vroot <PATH> Treats the specified path as the virtual root"###;
let args = r###"
<PATH> Path to focus on, or enter if directory, (default is `.`)
<SELECTION>... Paths to select, requires <PATH> to be set explicitly"###;
<PATH> Path to focus on, or enter if directory, (default is `.`)
<SELECTION>... Paths to select, requires <PATH> to be set explicitly"###;
let help = format!(
"xplr {}\n{}\n{}\n\nUSAGE:{}\n\nFLAGS:{}\n\nOPTIONS:{}\n\nARGS:{}",

@ -185,7 +185,7 @@ pub fn pipe_msg_in(args: Vec<String>) -> Result<()> {
.cloned()
.context("failed to detect delimmiter")?;
msg.push(delimiter.into());
msg.push(delimiter.try_into()?);
File::options()
.append(true)
.open(&path)?
@ -204,16 +204,62 @@ pub fn print_msg_in(args: Vec<String>) -> Result<()> {
}
fn fmt_msg_in(args: Vec<String>) -> Result<String> {
let msg = match jf::format(args.into_iter().map(Into::into)) {
Ok(msg) => msg,
Err(jf::Error::Jf(e)) => bail!("xplr -m: {e}"),
Err(jf::Error::Json(e)) => bail!("xplr -m: json: {e}"),
Err(jf::Error::Yaml(e)) => bail!("xplr -m: yaml: {e}"),
Err(jf::Error::Io(e)) => bail!("xplr -m: io: {e}"),
};
let mut args = args.into_iter();
let format = args.next().context("FORMAT is missing")?;
let mut msg = "".to_string();
let mut last_char = None;
for (col, ch) in format.chars().enumerate() {
match (ch, last_char) {
('%', Some('%')) => {
msg.push(ch);
last_char = None;
}
('%', _) => {
last_char = Some(ch);
}
('q', Some('%')) => {
let arg = args.next().context(format!(
"argument missing for the placeholder at column {col}"
))?;
msg.push_str(&json::to_string(&arg)?);
last_char = None;
}
('s', Some('%')) => {
let arg = args.next().context(format!(
"argument missing for the placeholder at column {col}",
))?;
msg.push_str(&arg);
last_char = None;
}
(ch, Some('%')) => {
bail!(format!(
"invalid placeholder '%{ch}' at column {col}, use one of '%s' or '%q', or escape it using '%%'",
));
}
(ch, _) => {
msg.push(ch);
last_char = Some(ch);
}
}
}
if last_char == Some('%') {
bail!("message ended with incomplete placeholder");
}
// validate
let _: ExternalMsg = json::from_str(&msg)?;
if args.count() != 0 {
bail!("too many arguments, not enough placeholders")
}
// Since we'll mostly by passing json using `-m`, and json is faster than yaml
// let's try to validate using json first.
let msg = if let Ok(val) = json::from_str::<ExternalMsg>(&msg) {
json::to_string(&val)?
} else {
let val: ExternalMsg = yaml::from_str(&msg)?;
json::to_string(&val)?
};
Ok(msg)
}

@ -7,8 +7,9 @@ use crate::ui::block;
use crate::ui::string_to_text;
use crate::ui::Constraint;
use crate::ui::ContentRendererArg;
use crate::ui::UI;
use mlua::Lua;
use serde::{Deserialize, Serialize};
use tui::backend::Backend;
use tui::layout::Constraint as TuiConstraint;
use tui::layout::Rect as TuiRect;
use tui::widgets::Cell;
@ -59,12 +60,13 @@ pub struct CustomContent {
}
/// A cursed function from crate::ui.
pub fn draw_custom_content(
ui: &mut UI,
f: &mut Frame,
pub fn draw_custom_content<B: Backend>(
f: &mut Frame<B>,
screen_size: TuiRect,
layout_size: TuiRect,
app: &app::App,
content: CustomContent,
lua: &Lua,
) {
let config = app.config.general.panel_ui.default.clone();
let title = content.title;
@ -84,13 +86,12 @@ pub fn draw_custom_content(
let ctx = ContentRendererArg {
app: app.to_lua_ctx_light(),
layout_size: layout_size.into(),
screen_size: ui.screen_size.into(),
scrolltop: ui.scrolltop as u16,
screen_size: screen_size.into(),
};
let render = lua::serialize(ui.lua, &ctx)
let render = lua::serialize(lua, &ctx)
.map(|arg| {
lua::call(ui.lua, &render, arg).unwrap_or_else(|e| format!("{e:?}"))
lua::call(lua, &render, arg).unwrap_or_else(|e| format!("{e:?}"))
})
.unwrap_or_else(|e| e.to_string());
@ -121,13 +122,12 @@ pub fn draw_custom_content(
let ctx = ContentRendererArg {
app: app.to_lua_ctx_light(),
layout_size: layout_size.into(),
screen_size: ui.screen_size.into(),
scrolltop: ui.scrolltop as u16,
screen_size: screen_size.into(),
};
let items = lua::serialize(ui.lua, &ctx)
let items = lua::serialize(lua, &ctx)
.map(|arg| {
lua::call(ui.lua, &render, arg)
lua::call(lua, &render, arg)
.unwrap_or_else(|e| vec![format!("{e:?}")])
})
.unwrap_or_else(|e| vec![e.to_string()])
@ -162,10 +162,11 @@ pub fn draw_custom_content(
let widths = widths
.into_iter()
.map(|w| w.to_tui(ui.screen_size, layout_size))
.map(|w| w.to_tui(screen_size, layout_size))
.collect::<Vec<TuiConstraint>>();
let content = Table::new(rows, widths)
let content = Table::new(rows)
.widths(&widths)
.column_spacing(col_spacing.unwrap_or(1))
.block(block(
config,
@ -183,13 +184,12 @@ pub fn draw_custom_content(
let ctx = ContentRendererArg {
app: app.to_lua_ctx_light(),
layout_size: layout_size.into(),
screen_size: ui.screen_size.into(),
scrolltop: ui.scrolltop as u16,
screen_size: screen_size.into(),
};
let rows = lua::serialize(ui.lua, &ctx)
let rows = lua::serialize(lua, &ctx)
.map(|arg| {
lua::call(ui.lua, &render, arg)
lua::call(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(
let widths = widths
.into_iter()
.map(|w| w.to_tui(ui.screen_size, layout_size))
.map(|w| w.to_tui(screen_size, layout_size))
.collect::<Vec<TuiConstraint>>();
let mut content = Table::new(rows, &widths).block(block(
let mut content = Table::new(rows).widths(&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.clone());
self.meta.extend(other.meta.to_owned());
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.clone()
self.symlink.to_owned()
} else if node.is_dir {
self.directory.clone()
self.directory.to_owned()
} else {
self.file.clone()
self.file.to_owned()
};
let mut me = node.mime_essence.splitn(2, '/');
@ -104,7 +104,7 @@ impl NodeTypesConfig {
node_type = node_type.extend(conf);
}
if let (Some(conf), false) = (self.extension.get(&node.extension), node.is_dir) {
if let Some(conf) = self.extension.get(&node.extension) {
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.clone().or(self.format);
self.format = other.format.to_owned().or(self.format);
self.style = self.style.extend(&other.style);
self
}
@ -353,12 +353,6 @@ 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)]
@ -644,8 +638,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.clone().or(self.borders);
self.border_type = other.border_type.or(self.border_type);
self.borders = other.borders.to_owned().or(self.borders);
self.border_type = other.border_type.to_owned().or(self.border_type);
self.border_style = self.border_style.extend(&other.border_style);
self
}
@ -708,9 +702,6 @@ pub struct Hooks {
#[serde(default)]
pub on_layout_switch: Vec<ExternalMsg>,
#[serde(default)]
pub on_selection_change: Vec<ExternalMsg>,
// TODO After cleanup or Runner::run
// #[serde(default)]
// pub before_quit: Vec<ExternalMsg>,
@ -723,7 +714,6 @@ impl Hooks {
self.on_focus_change.extend(other.on_focus_change);
self.on_mode_switch.extend(other.on_mode_switch);
self.on_layout_switch.extend(other.on_layout_switch);
self.on_selection_change.extend(other.on_selection_change);
self
}
}

@ -1,26 +0,0 @@
use std::{env, path::PathBuf};
use lazy_static::lazy_static;
use xdg::BaseDirectories;
lazy_static! {
pub static ref BASE_DIRS: Option<BaseDirectories> = BaseDirectories::new().ok();
}
pub fn home_dir() -> Option<PathBuf> {
home::home_dir()
}
pub fn config_dir() -> Option<PathBuf> {
BASE_DIRS.as_ref().map(|base| base.get_config_home())
}
pub fn runtime_dir() -> PathBuf {
let Some(dir) = BASE_DIRS
.as_ref()
.and_then(|base| base.get_runtime_directory().ok())
else {
return env::temp_dir();
};
dir.clone()
}

@ -91,17 +91,6 @@ 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
@ -126,7 +115,7 @@ xplr.config.general.prompt.style = {}
-- Type: nullable string
xplr.config.general.logs.info.format = "INFO"
-- The style for the information logs.
-- The style for the informations logs.
--
-- Type: [Style](https://xplr.dev/en/style)
xplr.config.general.logs.info.style = { fg = "LightBlue" }
@ -691,15 +680,11 @@ xplr.config.general.initial_sorting = {
}
-- The name of one of the modes to use when xplr loads.
-- This isn't the default mode. To modify the default mode, overwrite
-- [xplr.config.modes.builtin.default](https://xplr.dev/en/modes#xplrconfigmodesbuiltindefault).
--
-- Type: nullable string
xplr.config.general.initial_mode = "default"
-- The name of one of the layouts to use when xplr loads.
-- This isn't the default layout. To modify the default layout, overwrite
-- [xplr.config.layouts.builtin.default](https://xplr.dev/en/layouts#xplrconfiglayoutsbuiltindefault).
--
-- Type: nullable string
xplr.config.general.initial_layout = "default"
@ -716,17 +701,6 @@ xplr.config.general.start_fifo = nil
-- Type: [Key Bindings](https://xplr.dev/en/configure-key-bindings#key-bindings)
xplr.config.general.global_key_bindings = {
on_key = {
["f1"] = {
help = "global help menu",
messages = {
{
BashExec = [===[
[ -z "$PAGER" ] && PAGER="less -+F"
cat -- "${XPLR_PIPE_GLOBAL_HELP_MENU_OUT}" | ${PAGER:?}
]===],
},
},
},
["esc"] = {
messages = {
"PopMode",
@ -754,7 +728,9 @@ xplr.config.general.global_key_bindings = {
-- The style for the directory nodes
--
-- Type: [Style](https://xplr.dev/en/style)
xplr.config.node_types.directory.style = {}
xplr.config.node_types.directory.style = {
fg = "Blue",
}
-- Metadata for the directory nodes.
-- You can set as many metadata as you want.
@ -790,7 +766,10 @@ xplr.config.node_types.file.meta.icon = "ƒ"
-- The style for the symlink nodes.
--
-- Type: [Style](https://xplr.dev/en/style)
xplr.config.node_types.symlink.style = {}
xplr.config.node_types.symlink.style = {
fg = "Magenta",
add_modifiers = { "Italic" },
}
-- Metadata for the symlink nodes.
-- You can set as many metadata as you want.
@ -822,7 +801,7 @@ xplr.config.node_types.symlink.meta.icon = "§"
-- xplr.config.node_types.mime_essence = {
-- application = {
-- -- application/*
-- ["*"] = { meta = { icon = "a" } },
-- ["*"] = { meta = { icon = "a" } }
--
-- -- application/pdf
-- pdf = { meta = { icon = "" }, style = { fg = "Blue" } },
@ -878,13 +857,15 @@ xplr.config.node_types.special = {}
--
-- ##### Example: Defining Custom Layout
--
-- ![demo](https://s6.gifyu.com/images/layout.png)
--
-- ```lua
-- xplr.config.layouts.builtin.default = {
-- Horizontal = {
-- config = {
-- margin = 1,
-- horizontal_margin = 1,
-- vertical_margin = 1,
-- horizontal_margin = 2,
-- vertical_margin = 3,
-- constraints = {
-- { Percentage = 50 },
-- { Percentage = 50 },
@ -897,21 +878,6 @@ xplr.config.node_types.special = {}
-- }
-- }
-- ```
--
-- Result:
--
-- ```
-- ╭ /home ─────────────╮╭ Help [default] ────╮
-- │ ╭─── path ││. show hidden │
-- │ ├▸[ð Desktop/] ││/ search │
-- │ ├ ð Documents/ ││: action │
-- │ ├ ð Downloads/ ││? global help │
-- │ ├ ð GitHub/ ││G go to bottom │
-- │ ├ ð Music/ ││V select/unselect│
-- │ ├ ð Pictures/ ││ctrl duplicate as │
-- │ ├ ð Public/ ││ctrl next visit │
-- ╰────────────────────╯╰────────────────────╯
-- ```
-- The default layout
--
@ -1101,6 +1067,17 @@ xplr.config.modes.builtin.default = {
{ SwitchModeBuiltin = "action" },
},
},
["?"] = {
help = "global help menu",
messages = {
{
BashExec = [===[
[ -z "$PAGER" ] && PAGER="less -+F"
cat -- "${XPLR_PIPE_GLOBAL_HELP_MENU_OUT}" | ${PAGER:?}
]===],
},
},
},
["G"] = {
help = "go to bottom",
messages = {
@ -1134,18 +1111,6 @@ xplr.config.modes.builtin.default = {
"LastVisitedPath",
},
},
[")"] = {
help = "next deep branch",
messages = {
"NextVisitedDeepBranch",
},
},
["("] = {
help = "prev deep branch",
messages = {
"PreviousVisitedDeepBranch",
},
},
["ctrl-r"] = {
help = "refresh screen",
messages = {
@ -1307,22 +1272,6 @@ 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",
@ -1351,8 +1300,6 @@ 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["tab"] =
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"]
-- The builtin debug error mode.
--
@ -1487,148 +1434,6 @@ 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)
@ -1643,15 +1448,15 @@ xplr.config.modes.builtin.selection_ops = {
{
BashExec0 = [===[
TMPFILE="$(mktemp)"
while IFS= read -r -d '' PTH; do
(while IFS= read -r -d '' PTH; do
echo $(printf %q "${PTH:?}") >> "${TMPFILE:?}"
done < "${XPLR_PIPE_SELECTION_OUT:?}"
done < "${XPLR_PIPE_SELECTION_OUT:?}")
${EDITOR:-vi} "${TMPFILE:?}"
[ ! -e "$TMPFILE" ] && exit
"$XPLR" -m ClearSelection
while IFS= read -r PTH_ESC; do
(while IFS= read -r PTH_ESC; do
"$XPLR" -m 'SelectPath: %q' "$(eval printf %s ${PTH_ESC:?})"
done < "${TMPFILE:?}"
done < "${TMPFILE:?}")
rm -- "${TMPFILE:?}"
]===],
},
@ -1679,35 +1484,22 @@ xplr.config.modes.builtin.selection_ops = {
{
BashExec0 = [===[
"$XPLR" -m ExplorePwd
while IFS= read -r -d '' PTH; do
(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
while [ -e "$BASENAME" ]; do
BASENAME="$BASENAME (copied)"
BASENAME_ESC=$(printf %q "$BASENAME")
done
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
read -p "[press enter to continue]"
done < "${XPLR_PIPE_SELECTION_OUT:?}")
read -p "[enter to continue]"
]===],
},
"PopMode",
@ -1719,35 +1511,22 @@ xplr.config.modes.builtin.selection_ops = {
{
BashExec0 = [===[
"$XPLR" -m ExplorePwd
while IFS= read -r -d '' PTH; do
(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
while [ -e "$BASENAME" ]; do
BASENAME="$BASENAME (moved)"
BASENAME_ESC=$(printf %q "$BASENAME")
done
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
read -p "[press enter to continue]"
done < "${XPLR_PIPE_SELECTION_OUT:?}")
read -p "[enter to continue]"
]===],
},
"PopMode",
@ -1759,35 +1538,22 @@ xplr.config.modes.builtin.selection_ops = {
{
BashExec0 = [===[
"$XPLR" -m ExplorePwd
while IFS= read -r -d '' PTH; do
(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
while [ -e "$BASENAME" ]; do
BASENAME="$BASENAME (softlinked)"
BASENAME_ESC=$(printf %q "$BASENAME")
done
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
read -p "[press enter to continue]"
done < "${XPLR_PIPE_SELECTION_OUT:?}")
read -p "[enter to continue]"
]===],
},
"PopMode",
@ -1799,35 +1565,22 @@ xplr.config.modes.builtin.selection_ops = {
{
BashExec0 = [===[
"$XPLR" -m ExplorePwd
while IFS= read -r -d '' PTH; do
(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
while [ -e "$BASENAME" ]; do
BASENAME="$BASENAME (hardlinked)"
BASENAME_ESC=$(printf %q "$BASENAME")
done
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
read -p "[press enter to continue]"
done < "${XPLR_PIPE_SELECTION_OUT:?}")
read -p "[enter to continue]"
]===],
},
"PopMode",
@ -2064,9 +1817,9 @@ xplr.config.modes.builtin.go_to = {
exit 1
fi
fi
while IFS= read -r -d '' PTH; do
(while IFS= read -r -d '' PTH; do
$OPENER "${PTH:?}" > /dev/null 2>&1
done < "${XPLR_PIPE_RESULT_OUT:?}"
done < "${XPLR_PIPE_RESULT_OUT:?}")
]===],
},
"ClearScreen",
@ -2178,16 +1931,8 @@ xplr.config.modes.builtin.delete = {
messages = {
{
BashExec0 = [===[
while IFS= read -r -d '' PTH; do
printf '%q\n' "$PTH"
done < "${XPLR_PIPE_RESULT_OUT:?}"
echo
read -p "Permanently delete these files? [Y/n]: " ANS
[ "${ANS:-Y}" = "Y" ] || [ "$ANS" = "y" ] || exit 0
echo
"$XPLR" -m ExplorePwd
while IFS= read -r -d '' PTH; do
(while IFS= read -r -d '' PTH; do
PTH_ESC=$(printf %q "$PTH")
if rm -rfv -- "${PTH:?}"; then
"$XPLR" -m 'LogSuccess: %q' "$PTH_ESC deleted"
@ -2195,9 +1940,8 @@ xplr.config.modes.builtin.delete = {
"$XPLR" -m 'LogError: %q' "could not delete $PTH_ESC"
"$XPLR" -m 'FocusPath: %q' "$PTH"
fi
done < "${XPLR_PIPE_RESULT_OUT:?}"
echo
read -p "[press enter to continue]"
done < "${XPLR_PIPE_RESULT_OUT:?}")
read -p "[enter to continue]"
]===],
},
"PopMode",
@ -2208,16 +1952,8 @@ xplr.config.modes.builtin.delete = {
messages = {
{
BashExec0 = [===[
while IFS= read -r -d '' PTH; do
printf '%q\n' "$PTH"
done < "${XPLR_PIPE_RESULT_OUT:?}"
echo
read -p "Permanently delete these files? [Y/n]: " ANS
[ "${ANS:-Y}" = "Y" ] || [ "$ANS" = "y" ] || exit 0
echo
"$XPLR" -m ExplorePwd
while IFS= read -r -d '' PTH; do
(while IFS= read -r -d '' PTH; do
PTH_ESC=$(printf %q "$PTH")
if [ -d "$PTH" ] && [ ! -L "$PTH" ]; then
if rmdir -v -- "${PTH:?}"; then
@ -2234,9 +1970,8 @@ xplr.config.modes.builtin.delete = {
"$XPLR" -m 'FocusPath: %q' "$PTH"
fi
fi
done < "${XPLR_PIPE_RESULT_OUT:?}"
echo
read -p "[press enter to continue]"
done < "${XPLR_PIPE_RESULT_OUT:?}")
read -p "[enter to continue]"
]===],
},
"PopMode",
@ -2730,6 +2465,7 @@ xplr.config.modes.builtin.sort = {
"ExplorePwdAsync",
},
},
["c"] = {
help = "by created",
messages = {
@ -2737,6 +2473,7 @@ xplr.config.modes.builtin.sort = {
"ExplorePwdAsync",
},
},
["C"] = {
help = "by created reverse",
messages = {
@ -2744,6 +2481,7 @@ xplr.config.modes.builtin.sort = {
"ExplorePwdAsync",
},
},
["l"] = {
help = "by last modified",
messages = {
@ -2751,6 +2489,7 @@ xplr.config.modes.builtin.sort = {
"ExplorePwdAsync",
},
},
["L"] = {
help = "by last modified reverse",
messages = {
@ -3124,9 +2863,9 @@ xplr.fn.builtin.fmt_general_selection_item = function(n)
if n.is_dir then
shortened = shortened .. "/"
end
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 })
local meta_style = xplr.util.node_type(n).style
local style = xplr.util.style_mix({ meta_style, ls_style })
return xplr.util.paint(shortened:gsub("\n", nl), style)
end
@ -3148,8 +2887,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 ls_style = xplr.util.lscolor(m.absolute_path)
local style = xplr.util.style_mix({ ls_style, m.style })
local style = xplr.util.lscolor(m.absolute_path)
style = xplr.util.style_mix({ m.style, style })
if m.meta.icon == nil then
r = r .. ""
@ -3171,8 +2910,7 @@ xplr.fn.builtin.fmt_general_table_row_cols_1 = function(m)
if m.is_broken then
r = r .. "×"
else
local symlink_path =
xplr.util.shorten(m.symlink.absolute_path, { base = m.parent })
local symlink_path = xplr.util.shorten(m.symlink.absolute_path)
if m.symlink.is_dir then
symlink_path = symlink_path .. "/"
end
@ -3281,14 +3019,6 @@ xplr.fn.custom = {}
-- { LogSuccess = "Switched layout" },
-- { CallLuaSilently = "custom.some_plugin_with_hooks.on_layout_switch" },
-- }
--
-- -- Add messages to send when the selection changes
-- --
-- -- Type: list of [Message](https://xplr.dev/en/message#message)s
-- on_selection_change = {
-- { LogSuccess = "Selection changed" },
-- { CallLuaSilently = "custom.some_plugin_with_hooks.on_selection_change" },
-- }
-- }
-- ```
@ -3299,15 +3029,3 @@ return {
on_mode_switch = {},
on_layout_switch = {},
}
-- ----------------------------------------------------------------------------
-- > Note:
-- >
-- > It's not recommended to copy the entire configuration, unless you want to
-- > freeze it and miss out on useful updates to the defaults.
-- >
-- > Instead, you can use this as a reference to overwrite only the parts you
-- > want to update.
-- >
-- > If you still want to copy the entire configuration, make sure to put your
-- > customization before the return statement.

@ -18,18 +18,6 @@ pub enum Key {
F10,
F11,
F12,
F13,
F14,
F15,
F16,
F17,
F18,
F19,
F20,
F21,
F22,
F23,
F24,
Num0,
Num1,
@ -351,19 +339,7 @@ impl Key {
KeyCode::F(9) => Key::F9,
KeyCode::F(10) => Key::F10,
KeyCode::F(11) => Key::F11,
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::F(12) => Key::F12,
KeyCode::Backspace => Key::Backspace,
KeyCode::Left => Key::Left,
@ -647,7 +623,7 @@ impl Key {
Self::ShiftZ => Some('Z'),
Self::Space => Some(' '),
Self::Special(c) => Some(*c),
Self::Special(c) => Some(c.to_owned()),
_ => None,
}
@ -731,6 +707,12 @@ impl From<char> for Key {
}
}
impl From<String> for Key {
fn from(string: String) -> Self {
string.into()
}
}
impl From<&str> for Key {
fn from(string: &str) -> Self {
if string.len() == 1 {

@ -7,7 +7,6 @@ pub mod cli;
pub mod compat;
pub mod config;
pub mod directory_buffer;
pub mod dirs;
pub mod event_reader;
pub mod explorer;
pub mod input;

@ -7,7 +7,7 @@ use anyhow::Result;
use mlua::Lua;
use mlua::LuaSerdeExt;
use mlua::SerializeOptions;
use serde::de::DeserializeOwned;
use serde::Deserialize;
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: DeserializeOwned>(
pub fn call<'lua, R: Deserialize<'lua>>(
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.9", "foo path").is_ok());
assert!(check_version("0.21.1", "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.9", "foo path").is_err());
assert!(check_version("0.20.1", "foo path").is_err());
// Prev bugfix release is OK
assert!(check_version("0.21.8", "foo path").is_ok());
assert!(check_version("0.21.0", "foo path").is_ok());
// Next major release is ERR
assert!(check_version("1.20.9", "foo path").is_err());
assert!(check_version("1.20.1", "foo path").is_err());
// Next minor release is ERR
assert!(check_version("0.22.9", "foo path").is_err());
assert!(check_version("0.22.1", "foo path").is_err());
// Next bugfix release is ERR (Change when we get to v1)
assert!(check_version("0.21.10", "foo path").is_err());
assert!(check_version("0.21.2", "foo path").is_err());
}
}

@ -13,7 +13,6 @@ 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;
@ -29,10 +28,6 @@ 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 }
@ -69,30 +64,6 @@ 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
@ -160,7 +131,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_file()))?;
lua.create_function(move |_, path: String| Ok(PathBuf::from(path).is_dir()))?;
util.set("is_file", func)?;
Ok(util)
}
@ -489,7 +460,7 @@ pub fn explore<'a>(util: Table<'a>, lua: &Lua) -> Result<Table<'a>> {
///
/// ```lua
/// xplr.util.shell_execute("pwd")
/// -- { stdout = "/present/working/directory", stderr = "", returncode = 0 }
/// -- "/present/working/directory"
///
/// xplr.util.shell_execute("bash", {"-c", "xplr --help"})
/// -- { stdout = "xplr...", stderr = "", returncode = 0 }
@ -654,7 +625,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]
/// Type: function( path:string ) -> [Style][3]|nil
///
/// Example:
///
@ -663,11 +634,9 @@ 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 = LS_COLORS
.style_for_path(path)
.map(Style::from)
.unwrap_or_default();
let style = lscolors.style_for_path(path).map(Style::from);
lua::serialize(lua, &style).map_err(LuaError::custom)
})?;
util.set("lscolor", func)?;
@ -869,7 +838,6 @@ 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,22 +277,6 @@ 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:
@ -354,7 +338,7 @@ pub enum ExternalMsg {
/// Update the input buffer using cursor based operations.
///
/// Type: { UpdateInputBuffer = [Input Operation](https://xplr.dev/en/input-operation) }
/// Type: { UpdateInputBuffer = [Input Opertaion](https://xplr.dev/en/input-operation) }
///
/// Example:
///
@ -380,7 +364,7 @@ pub enum ExternalMsg {
/// - YAML: `BufferInput: foo`
BufferInput(String),
/// Append/buffer the character read from a keyboard input into the
/// Append/buffer the characted read from a keyboard input into the
/// input buffer.
///
/// Example:
@ -767,7 +751,7 @@ pub enum ExternalMsg {
/// Add a [filter](https://xplr.dev/en/filtering#filter) to exclude nodes
/// while exploring directories.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
/// Filters get automatically cleared when changing directories.
///
/// Type: { AddNodeFilter = { filter = [Filter](https://xplr.dev/en/filtering#filter), input = "string" }
@ -779,7 +763,7 @@ pub enum ExternalMsg {
AddNodeFilter(NodeFilterApplicable),
/// Remove an existing [filter](https://xplr.dev/en/filtering#filter).
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
///
/// Type: { RemoveNodeFilter = { filter = [Filter](https://xplr.dev/en/filtering), input = "string" }
///
@ -791,7 +775,7 @@ pub enum ExternalMsg {
/// Remove a [filter](https://xplr.dev/en/filtering#filter) if it exists,
/// else, add a it.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
///
/// Type: { ToggleNodeFilter = { filter = [Filter](https://xplr.dev/en/filtering), input = "string" }
///
@ -803,7 +787,7 @@ pub enum ExternalMsg {
/// Add a node [filter](https://xplr.dev/en/filtering#filter) reading the
/// input from the buffer.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
///
/// Type: { AddNodeFilterFromInput = [Filter](https://xplr.dev/en/filtering) }
///
@ -815,7 +799,7 @@ pub enum ExternalMsg {
/// Remove a node [filter](https://xplr.dev/en/filtering#filter) reading
/// the input from the buffer.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
///
/// Type: { RemoveNodeFilterFromInput = [Filter](https://xplr.dev/en/filtering) }
///
@ -826,7 +810,7 @@ pub enum ExternalMsg {
RemoveNodeFilterFromInput(NodeFilter),
/// Remove the last node [filter](https://xplr.dev/en/filtering).
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
///
/// Example:
///
@ -836,7 +820,7 @@ pub enum ExternalMsg {
/// Reset the node [filters](https://xplr.dev/en/filtering) back to the
/// default configuration.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
///
/// Example:
///
@ -845,7 +829,7 @@ pub enum ExternalMsg {
ResetNodeFilters,
/// Clear all the node [filters](https://xplr.dev/en/filtering).
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
///
/// Example:
///
@ -857,7 +841,7 @@ pub enum ExternalMsg {
/// Add a [sorter](https://xplr.dev/en/sorting#sorter) to sort nodes while
/// exploring directories.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
///
/// Type: { AddNodeSorter = { sorter = [Sorter](https://xplr.dev/en/sorting#sorter), reverse = bool } }
///
@ -868,7 +852,7 @@ pub enum ExternalMsg {
AddNodeSorter(NodeSorterApplicable),
/// Remove an existing [sorter](https://xplr.dev/en/sorting#sorter).
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
///
/// Type: { RemoveNodeSorter = [Sorter](https://xplr.dev/en/sorting#sorter) }
///
@ -879,7 +863,7 @@ pub enum ExternalMsg {
RemoveNodeSorter(NodeSorter),
/// Reverse a node [sorter](https://xplr.dev/en/sorting#sorter).
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
///
/// Type: { ReverseNodeSorter = [Sorter](https://xplr.dev/en/sorting#sorter) }
///
@ -891,7 +875,7 @@ pub enum ExternalMsg {
/// Remove a [sorter](https://xplr.dev/en/sorting#sorter) if it exists,
/// else, add a it.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
///
/// Type: { ToggleNodeSorter = { sorter = [Sorter](https://xplr.dev/en/sorting#sorter), reverse = bool } }
///
@ -902,7 +886,7 @@ pub enum ExternalMsg {
ToggleNodeSorter(NodeSorterApplicable),
/// Reverse the node [sorters](https://xplr.dev/en/sorting#sorter).
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
///
/// Example:
///
@ -911,7 +895,7 @@ pub enum ExternalMsg {
ReverseNodeSorters,
/// Remove the last node [sorter](https://xplr.dev/en/sorting#sorter).
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
///
/// Example:
///
@ -921,7 +905,7 @@ pub enum ExternalMsg {
/// Reset the node [sorters](https://xplr.dev/en/sorting#sorter) back to
/// the default configuration.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
///
/// Example:
///
@ -930,7 +914,7 @@ pub enum ExternalMsg {
ResetNodeSorters,
/// Clear all the node [sorters](https://xplr.dev/en/sorting#sorter).
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
///
/// Example:
///
@ -941,7 +925,7 @@ pub enum ExternalMsg {
/// ### Search Operations --------------------------------------------------
/// Search files using the current or default (fuzzy) search algorithm.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
/// It gets reset automatically when changing directory.
///
/// Type: { Search = "string" }
@ -962,7 +946,7 @@ pub enum ExternalMsg {
/// Search files using fuzzy match algorithm.
/// It keeps the filters, but overrides the sorters.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
/// It gets reset automatically when changing directory.
///
/// Type: { SearchFuzzy = "string" }
@ -974,7 +958,7 @@ pub enum ExternalMsg {
SearchFuzzy(String),
/// Calls `SearchFuzzy` with the input taken from the input buffer.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
/// It gets reset automatically when changing directory.
///
/// Example:
@ -984,7 +968,7 @@ pub enum ExternalMsg {
SearchFuzzyFromInput,
/// Like `SearchFuzzy`, but doesn't not perform rank based sorting.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
/// It gets reset automatically when changing directory.
///
/// Type: { SearchFuzzyUnordered = "string" }
@ -996,7 +980,7 @@ pub enum ExternalMsg {
SearchFuzzyUnordered(String),
/// Calls `SearchFuzzyUnordered` with the input taken from the input buffer.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
/// It gets reset automatically when changing directory.
///
/// Example:
@ -1007,7 +991,7 @@ pub enum ExternalMsg {
/// Search files using regex match algorithm.
/// It keeps the filters, but overrides the sorters.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
/// It gets reset automatically when changing directory.
///
/// Type: { SearchRegex = "string" }
@ -1019,7 +1003,7 @@ pub enum ExternalMsg {
SearchRegex(String),
/// Calls `SearchRegex` with the input taken from the input buffer.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
/// It gets reset automatically when changing directory.
///
/// Example:
@ -1029,7 +1013,7 @@ pub enum ExternalMsg {
SearchRegexFromInput,
/// Like `SearchRegex`, but doesn't not perform rank based sorting.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
/// It gets reset automatically when changing directory.
///
/// Type: { SearchRegexUnordered = "string" }
@ -1041,7 +1025,7 @@ pub enum ExternalMsg {
SearchRegexUnordered(String),
/// Calls `SearchRegexUnordered` with the input taken from the input buffer.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
/// It gets reset automatically when changing directory.
///
/// Example:
@ -1052,7 +1036,7 @@ pub enum ExternalMsg {
/// Toggles between different search algorithms, without changing the input
/// buffer
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
///
/// Example:
///
@ -1061,7 +1045,7 @@ pub enum ExternalMsg {
ToggleSearchAlgorithm,
/// Enables ranked search without changing the input buffer.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
///
/// Example:
///
@ -1070,7 +1054,7 @@ pub enum ExternalMsg {
EnableSearchOrder,
/// Disabled ranked search without changing the input buffer.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitly.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
///
/// Example:
///
@ -1151,7 +1135,7 @@ pub enum ExternalMsg {
/// - YAML: `StopFifo`
StopFifo,
/// Toggle between {Start|Stop}Fifo
/// Toggle betwen {Start|Stop}Fifo
///
/// Type: { ToggleFifo = "string" }
///

@ -7,5 +7,4 @@ pub enum InternalMsg {
AddLastFocus(String, Option<String>),
SetDirectory(DirectoryBuffer),
HandleKey(Key),
RefreshSelection,
}

@ -17,6 +17,7 @@ pub enum MsgOut {
CallLuaSilently(String),
LuaEval(String),
LuaEvalSilently(String),
Enque(Task),
EnableMouse,
DisableMouse,
ToggleMouse,
@ -33,5 +34,4 @@ pub enum MsgOut {
PrintSelectionAndQuit,
PrintResultAndQuit,
PrintAppStateAndQuit,
Enqueue(Task),
}

@ -1,4 +1,3 @@
use crate::dirs;
use anyhow::{bail, Result};
use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
@ -39,8 +38,8 @@ where
}
(None, _) => comps.push(Component::ParentDir),
(Some(a), Some(b)) if comps.is_empty() && a == b => (),
(Some(a), Some(Component::CurDir)) => comps.push(a),
(Some(_), Some(Component::ParentDir)) => {
(Some(a), Some(b)) if b == Component::CurDir => comps.push(a),
(Some(_), Some(b)) if b == Component::ParentDir => {
let path = path.to_string_lossy();
let base = base.to_string_lossy();
bail!("{base} is not a parent of {path}")
@ -216,20 +215,17 @@ mod tests {
#[test]
fn test_relative_to_parent() {
let path = std::env::current_dir().unwrap().join("docs");
let path = std::env::current_dir().unwrap();
let parent = path.parent().unwrap();
let base = default().with_base(path.to_str().unwrap());
let relative = relative_to(parent, Some(&base)).unwrap();
let relative = relative_to(parent, NONE).unwrap();
assert_eq!(relative, PathBuf::from(".."));
let relative =
relative_to(parent, Some(&base.clone().with_prefix_dots())).unwrap();
let relative = relative_to(parent, Some(&default().with_prefix_dots())).unwrap();
assert_eq!(relative, PathBuf::from(".."));
let relative =
relative_to(parent, Some(&base.clone().without_suffix_dots())).unwrap();
relative_to(parent, Some(&default().without_suffix_dots())).unwrap();
assert_eq!(
relative,
PathBuf::from("../..").join(parent.file_name().unwrap())
@ -237,7 +233,7 @@ mod tests {
let relative = relative_to(
parent,
Some(&base.clone().with_prefix_dots().without_suffix_dots()),
Some(&default().with_prefix_dots().without_suffix_dots()),
)
.unwrap();
assert_eq!(

@ -8,8 +8,7 @@ use crate::explorer;
use crate::lua;
use crate::pipe;
use crate::pwd_watcher;
use crate::ui::NO_COLOR;
use crate::ui::UI;
use crate::ui;
use crate::yaml;
use anyhow::{bail, Error, Result};
use crossterm::event;
@ -41,14 +40,15 @@ pub fn get_tty() -> Result<fs::File> {
// returns physical path. As a workaround, this function tries to use `PWD`
// environment variable that is configured by shell.
fn get_current_dir() -> Result<PathBuf, std::io::Error> {
let cur = std::env::current_dir();
if let Ok(pwd) = std::env::var("PWD") {
if pwd.is_empty() {
std::env::current_dir()
cur
} else {
Ok(PathBuf::from(pwd))
}
} else {
std::env::current_dir()
cur
}
}
@ -286,7 +286,7 @@ impl Runner {
tx_pwd_watcher.send(app.pwd.clone())?;
let mut result = Ok(None);
let session_path = app.session_path.clone();
let session_path = app.session_path.to_owned();
term::enable_raw_mode()?;
@ -342,9 +342,6 @@ impl Runner {
None,
))?;
// UI
let mut ui = UI::new(&lua);
'outer: for task in rx_msg_in {
match app.handle_task(task) {
Ok(a) => {
@ -352,7 +349,9 @@ impl Runner {
while let Some(msg) = app.msg_out.pop_front() {
use app::MsgOut::*;
match msg {
Enqueue(task) => {
// NOTE: Do not schedule critical tasks via tx_msg_in in this loop.
// Try handling them immediately.
Enque(task) => {
tx_msg_in.send(task)?;
}
@ -415,7 +414,7 @@ impl Runner {
}
ScrollUpHalf => {
app = app.focus_previous_by_relative_index(
app = app.focus_next_by_relative_index(
terminal.size()?.height as usize / 2,
)?;
}
@ -474,13 +473,13 @@ impl Runner {
}
if app.pwd != last_pwd {
last_pwd.clone_from(&app.pwd);
last_pwd = app.pwd.clone();
// $PWD watcher
tx_pwd_watcher.send(app.pwd.clone())?;
// OSC 7: Change CWD
if !(*NO_COLOR) {
if !(*ui::NO_COLOR) {
write!(
terminal.backend_mut(),
"\x1b]7;file://{}{}\x1b\\",
@ -497,7 +496,7 @@ impl Runner {
}
// UI
terminal.draw(|f| ui.draw(f, &app))?;
terminal.draw(|f| ui::draw(f, &app, &lua))?;
}
EnableMouse => {

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