mirror of
https://github.com/sayanarijit/xplr.git
synced 2024-10-03 22:07:22 +03:00
Sync branch (#687)
* Update awesome-plugins.md * Update awesome-plugins.md * Visit deep level branches (#686) * Visit deep level branches - Press `)` to pass `NextVisitedDeepBranch` - Press `(` to pass `LastVisitedDeepBranch` * Last -> Previous * Upgrade pkgs * Clippy fixes * Fix clippy err --------- Co-authored-by: Dmitry Savosh <d.savosh@gmail.com>
This commit is contained in:
parent
75dabeb283
commit
414b45e4fd
796
Cargo.lock
generated
796
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
30
Cargo.toml
30
Cargo.toml
@ -22,29 +22,29 @@ categories = ['command-line-interface', 'command-line-utilities']
|
||||
include = ['src/**/*', 'docs/en/src/**/*', 'LICENSE', 'README.md']
|
||||
|
||||
[dependencies]
|
||||
libc = "0.2.147"
|
||||
libc = "0.2.151"
|
||||
humansize = "2.1.3"
|
||||
natord = "1.0.9"
|
||||
anyhow = "1.0.72"
|
||||
serde_yaml = "0.9.25"
|
||||
anyhow = "1.0.79"
|
||||
serde_yaml = "0.9.30"
|
||||
crossterm = { version = "0.27.0", features = [], default-features = false }
|
||||
ansi-to-tui = "3.1.0"
|
||||
regex = "1.9.3"
|
||||
regex = "1.10.2"
|
||||
gethostname = "0.4.3"
|
||||
serde_json = "1.0.104"
|
||||
path-absolutize = "3.1.0"
|
||||
which = "4.4.0"
|
||||
serde_json = "1.0.110"
|
||||
path-absolutize = "3.1.1"
|
||||
which = "5.0.0"
|
||||
nu-ansi-term = "0.49.0"
|
||||
textwrap = "0.16"
|
||||
snailquote = "0.3.1"
|
||||
skim = { version = "0.10.4", default-features = false }
|
||||
time = { version = "0.3.25", features = ["serde", "local-offset", "formatting", "macros"] }
|
||||
time = { version = "0.3.31", features = ["serde", "local-offset", "formatting", "macros"] }
|
||||
jf = "0.6.2"
|
||||
xdg = "2.5.2"
|
||||
home = "0.5.5"
|
||||
home = "0.5.9"
|
||||
|
||||
[dependencies.lscolors]
|
||||
version = "0.15.0"
|
||||
version = "0.16.0"
|
||||
default-features = false
|
||||
features = ["nu-ansi-term"]
|
||||
|
||||
@ -57,22 +57,22 @@ version = "2.0.4"
|
||||
default-features = false
|
||||
|
||||
[dependencies.tui]
|
||||
version = "0.22.0"
|
||||
version = "0.25.0"
|
||||
default-features = false
|
||||
features = ['crossterm', 'serde']
|
||||
features = ['crossterm', 'serde', 'underline-color']
|
||||
package = 'ratatui'
|
||||
|
||||
[dependencies.serde]
|
||||
version = "1.0.183"
|
||||
version = "1.0.194"
|
||||
features = []
|
||||
default-features = false
|
||||
|
||||
[dependencies.indexmap]
|
||||
version = "2.0.0"
|
||||
version = "2.1.0"
|
||||
features = ['serde']
|
||||
|
||||
[dependencies.mlua]
|
||||
version = "0.8.9"
|
||||
version = "0.9.2"
|
||||
features = ['luajit', 'vendored', 'serialize', 'send']
|
||||
|
||||
[dependencies.tui-input]
|
||||
|
@ -49,12 +49,14 @@ of the following plugins work for you, it's very easy to
|
||||
- [**sayanarijit/material-landscape.xplr**][19] Material Landscape
|
||||
- [**sayanarijit/material-landscape2.xplr**][20] Material Landscape 2
|
||||
- [**sayanarijit/zentable.xplr**][31] A clean, distraction free xplr table UI
|
||||
- [**dy-sh/dysh-style.xplr**][63] Complements xplr theme with icons and highlighting.
|
||||
- [**prncss-xyz/icons.xplr**][30] An icon theme for xplr.
|
||||
- [**dtomvan/extra-icons.xplr**][50] Adds more icons to icons.xplr, compatible
|
||||
with zentable.xplr.
|
||||
- [**hartan/web-devicons.xplr**][59] Adds [nvim-web-devicons][60] to xplr with
|
||||
optional coloring
|
||||
- [**duganchen/one-table-column.xplr**][62] Moves file stats to a status bar.
|
||||
- [**dy-sh/get-rid-of-index.xplr**][64] Removes the index column.
|
||||
|
||||
## Also See:
|
||||
|
||||
@ -122,3 +124,5 @@ of the following plugins work for you, it's very easy to
|
||||
[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
|
||||
|
@ -16,14 +16,16 @@ of [modes][4] and the key mappings for each mode.
|
||||
|
||||
| key | remaps | action |
|
||||
| --------- | ------ | ------------------- |
|
||||
| ( | | prev deep branch |
|
||||
| ) | | next deep branch |
|
||||
| . | | show hidden |
|
||||
| / | ctrl-f | search |
|
||||
| : | | action |
|
||||
| ? | | global help menu |
|
||||
| ? | f1 | global help menu |
|
||||
| G | | go to bottom |
|
||||
| V | ctrl-a | select/unselect all |
|
||||
| ctrl-d | | duplicate as |
|
||||
| ctrl-i | | next visited path |
|
||||
| ctrl-i | tab | next visited path |
|
||||
| ctrl-n | | next selection |
|
||||
| ctrl-o | | last visited path |
|
||||
| ctrl-p | | prev selection |
|
||||
@ -49,55 +51,161 @@ of [modes][4] and the key mappings for each mode.
|
||||
| ~ | | go home |
|
||||
| [0-9] | | input |
|
||||
|
||||
### duplicate_as
|
||||
|
||||
| key | remaps | action |
|
||||
| ----- | ------ | ---------------- |
|
||||
| enter | | submit |
|
||||
| f1 | | global help menu |
|
||||
| tab | | try complete |
|
||||
|
||||
### filter
|
||||
|
||||
| key | remaps | action |
|
||||
| --------- | ------ | ---------------------------------- |
|
||||
| R | | relative path does not match regex |
|
||||
| backspace | | remove last filter |
|
||||
| ctrl-r | | reset filters |
|
||||
| ctrl-u | | clear filters |
|
||||
| f1 | | global help menu |
|
||||
| r | | relative path does match regex |
|
||||
|
||||
### action
|
||||
|
||||
| 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 |
|
||||
|
||||
### create
|
||||
|
||||
| key | remaps | action |
|
||||
| --- | ------ | ---------------- |
|
||||
| d | | create directory |
|
||||
| f | | create file |
|
||||
| f1 | | global help menu |
|
||||
|
||||
### switch_layout
|
||||
|
||||
| key | remaps | action |
|
||||
| --- | ------ | -------------------- |
|
||||
| 1 | | default |
|
||||
| 2 | | no help menu |
|
||||
| 3 | | no selection panel |
|
||||
| 4 | | no help or selection |
|
||||
| f1 | | global help menu |
|
||||
|
||||
### selection_ops
|
||||
|
||||
| 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 |
|
||||
|
||||
### delete
|
||||
|
||||
| key | remaps | action |
|
||||
| --- | ------ | ---------------- |
|
||||
| D | | force delete |
|
||||
| d | | delete |
|
||||
| f1 | | global help menu |
|
||||
|
||||
### number
|
||||
|
||||
| key | remaps | action |
|
||||
| ----- | ------ | ---------------- |
|
||||
| down | j | to down |
|
||||
| enter | | to index |
|
||||
| f1 | | global help menu |
|
||||
| k | up | to up |
|
||||
| [0-9] | | input |
|
||||
|
||||
### create_directory
|
||||
|
||||
| key | remaps | action |
|
||||
| ----- | ------ | ---------------- |
|
||||
| enter | | submit |
|
||||
| f1 | | global help menu |
|
||||
| tab | | try complete |
|
||||
|
||||
### recover
|
||||
|
||||
| key | remaps | action |
|
||||
| --- | ------ | ---------------- |
|
||||
| f1 | | global help menu |
|
||||
|
||||
### rename
|
||||
|
||||
| key | remaps | action |
|
||||
| ----- | ------ | ---------------- |
|
||||
| enter | | submit |
|
||||
| f1 | | global help menu |
|
||||
| tab | | try complete |
|
||||
|
||||
### vroot
|
||||
|
||||
| key | remaps | action |
|
||||
| ------ | ------ | ------------ |
|
||||
| ------ | ------ | ---------------- |
|
||||
| . | | vroot $PWD |
|
||||
| / | | vroot / |
|
||||
| ctrl-r | | reset vroot |
|
||||
| ctrl-u | | unset vroot |
|
||||
| f1 | | global help menu |
|
||||
| v | | toggle vroot |
|
||||
| ~ | | vroot $HOME |
|
||||
|
||||
### relative_path_does_match_regex
|
||||
|
||||
| key | remaps | action |
|
||||
| ----- | ------ | ------ |
|
||||
| ----- | ------ | ---------------- |
|
||||
| enter | | submit |
|
||||
| f1 | | global help menu |
|
||||
|
||||
### go_to_path
|
||||
### relative_path_does_not_match_regex
|
||||
|
||||
| key | remaps | action |
|
||||
| ----- | ------ | ------------ |
|
||||
| ----- | ------ | ---------------- |
|
||||
| enter | | submit |
|
||||
| tab | | try complete |
|
||||
|
||||
### duplicate_as
|
||||
|
||||
| key | remaps | action |
|
||||
| ----- | ------ | ------------ |
|
||||
| enter | | submit |
|
||||
| tab | | try complete |
|
||||
| f1 | | global help menu |
|
||||
|
||||
### debug_error
|
||||
|
||||
| key | remaps | action |
|
||||
| ----- | ------ | ------------------- |
|
||||
| enter | | open logs in editor |
|
||||
| f1 | | global help menu |
|
||||
| q | | quit |
|
||||
|
||||
### selection_ops
|
||||
### edit_permissions
|
||||
|
||||
| key | remaps | action |
|
||||
| --- | ------ | --------------- |
|
||||
| c | | copy here |
|
||||
| e | | edit selection |
|
||||
| h | | hardlink here |
|
||||
| l | | list selection |
|
||||
| m | | move here |
|
||||
| s | | softlink here |
|
||||
| u | | clear selection |
|
||||
| ------ | ------ | ---------------- |
|
||||
| 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 |
|
||||
|
||||
### sort
|
||||
|
||||
@ -117,6 +225,7 @@ of [modes][4] and the key mappings for each mode.
|
||||
| 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 |
|
||||
@ -126,57 +235,24 @@ of [modes][4] and the key mappings for each mode.
|
||||
### go_to
|
||||
|
||||
| key | remaps | action |
|
||||
| --- | ------ | -------------- |
|
||||
| --- | ------ | ---------------- |
|
||||
| f | | follow symlink |
|
||||
| f1 | | global help menu |
|
||||
| g | | top |
|
||||
| i | | initial $PWD |
|
||||
| p | | path |
|
||||
| x | | open in gui |
|
||||
|
||||
### edit_permissions
|
||||
### quit
|
||||
|
||||
| key | remaps | action |
|
||||
| ------ | ------ | ------ |
|
||||
| G | | -group |
|
||||
| M | | min |
|
||||
| O | | -other |
|
||||
| U | | -user |
|
||||
| ctrl-r | | reset |
|
||||
| enter | | submit |
|
||||
| g | | +group |
|
||||
| m | | max |
|
||||
| o | | +other |
|
||||
| u | | +user |
|
||||
|
||||
### switch_layout
|
||||
|
||||
| key | remaps | action |
|
||||
| --- | ------ | -------------------- |
|
||||
| 1 | | default |
|
||||
| 2 | | no help menu |
|
||||
| 3 | | no selection panel |
|
||||
| 4 | | no help or selection |
|
||||
|
||||
### create
|
||||
|
||||
| key | remaps | action |
|
||||
| --- | ------ | ---------------- |
|
||||
| d | | create directory |
|
||||
| f | | create file |
|
||||
|
||||
### create_directory
|
||||
|
||||
| key | remaps | action |
|
||||
| ----- | ------ | ------------ |
|
||||
| enter | | submit |
|
||||
| tab | | try complete |
|
||||
|
||||
### create_file
|
||||
|
||||
| key | remaps | action |
|
||||
| ----- | ------ | ------------ |
|
||||
| enter | | submit |
|
||||
| tab | | try complete |
|
||||
| ----- | ------ | ----------------------- |
|
||||
| enter | | just quit |
|
||||
| f | | quit printing focus |
|
||||
| f1 | | global help menu |
|
||||
| p | | quit printing pwd |
|
||||
| r | | quit printing result |
|
||||
| s | | quit printing selection |
|
||||
|
||||
### search
|
||||
|
||||
@ -191,75 +267,23 @@ 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 |
|
||||
|
||||
### number
|
||||
### go_to_path
|
||||
|
||||
| key | remaps | action |
|
||||
| ----- | ------ | -------- |
|
||||
| down | j | to down |
|
||||
| enter | | to index |
|
||||
| k | up | to up |
|
||||
| [0-9] | | input |
|
||||
|
||||
### action
|
||||
|
||||
| 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
|
||||
|
||||
| key | remaps | action |
|
||||
| --------- | ------ | ---------------------------------- |
|
||||
| R | | relative path does not match regex |
|
||||
| backspace | | remove last filter |
|
||||
| ctrl-r | | reset filters |
|
||||
| ctrl-u | | clear filters |
|
||||
| r | | relative path does match regex |
|
||||
|
||||
### rename
|
||||
|
||||
| key | remaps | action |
|
||||
| ----- | ------ | ------------ |
|
||||
| ----- | ------ | ---------------- |
|
||||
| enter | | submit |
|
||||
| f1 | | global help menu |
|
||||
| tab | | try complete |
|
||||
|
||||
### relative_path_does_not_match_regex
|
||||
### create_file
|
||||
|
||||
| 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 |
|
||||
| --- | ------ | ------------ |
|
||||
| D | | force delete |
|
||||
| d | | delete |
|
||||
| f1 | | global help menu |
|
||||
| tab | | try complete |
|
||||
|
@ -320,6 +320,24 @@ Example:
|
||||
- Lua: `"NextVisitedPath"`
|
||||
- YAML: `NextVisitedPath`
|
||||
|
||||
#### PreviousVisitedDeepBranch
|
||||
|
||||
Go to the previous deep level branch.
|
||||
|
||||
Example:
|
||||
|
||||
- Lua: `"PreviousVisitedDeepBranch"`
|
||||
- YAML: `PreviousVisitedDeepBranch`
|
||||
|
||||
#### NextVisitedDeepBranch
|
||||
|
||||
Go to the next deep level branch.
|
||||
|
||||
Example:
|
||||
|
||||
- Lua: `"NextVisitedDeepBranch"`
|
||||
- YAML: `NextVisitedDeepBranch`
|
||||
|
||||
#### FollowSymlink
|
||||
|
||||
Follow the symlink under focus to its actual location.
|
||||
|
@ -2,11 +2,11 @@
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1689422397,
|
||||
"narHash": "sha256-fnopownlSBGTBYxGdTdUPM215yG/UEEj3wgheBLIbHs=",
|
||||
"lastModified": 1704262187,
|
||||
"narHash": "sha256-N4j9qghlp/Eb3Z11WF7Cb9U91AXwpascUbLH7YKMcLc=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "45ae0efbbce2aada6d5e8de6ace0c803b08ac9c7",
|
||||
"rev": "65f0d241783c94a08e4c9a3870736fc8854dd520",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
73
src/app.rs
73
src/app.rs
@ -135,6 +135,10 @@ impl History {
|
||||
self
|
||||
}
|
||||
|
||||
fn peek(&self) -> Option<&String> {
|
||||
self.paths.get(self.loc)
|
||||
}
|
||||
|
||||
fn push(mut self, path: String) -> Self {
|
||||
if self.peek() != Some(&path) {
|
||||
self.paths = self.paths.into_iter().take(self.loc + 1).collect();
|
||||
@ -167,8 +171,47 @@ impl History {
|
||||
self.cleanup()
|
||||
}
|
||||
|
||||
fn peek(&self) -> Option<&String> {
|
||||
self.paths.get(self.loc)
|
||||
fn _is_deepest_dir(&self, path: &str) -> bool {
|
||||
return !self
|
||||
.paths
|
||||
.iter()
|
||||
.any(|p| p.ends_with('/') && p.starts_with(path) && path != p);
|
||||
}
|
||||
|
||||
fn _uniq_deep_dirs(&self) -> IndexSet<String> {
|
||||
self.paths
|
||||
.clone()
|
||||
.into_iter()
|
||||
.filter(|p| p.ends_with('/') && self._is_deepest_dir(p))
|
||||
.collect::<IndexSet<String>>()
|
||||
}
|
||||
|
||||
fn visit_next_deep_branch(self, pwd: &str) -> Self {
|
||||
let uniq_deep_dirs = self._uniq_deep_dirs();
|
||||
|
||||
if let Some(path) = uniq_deep_dirs
|
||||
.iter()
|
||||
.skip_while(|p| p.trim_end_matches('/') != pwd)
|
||||
.nth(1)
|
||||
{
|
||||
self.push(path.to_string())
|
||||
} else {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_previous_deep_branch(self, pwd: &str) -> Self {
|
||||
let uniq_deep_dirs = self._uniq_deep_dirs();
|
||||
if let Some(path) = uniq_deep_dirs
|
||||
.iter()
|
||||
.rev()
|
||||
.skip_while(|p| p.trim_end_matches('/') != pwd)
|
||||
.nth(1)
|
||||
{
|
||||
self.push(path.to_string())
|
||||
} else {
|
||||
self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -271,9 +314,7 @@ impl App {
|
||||
}
|
||||
};
|
||||
|
||||
let config_files = config_file
|
||||
.into_iter()
|
||||
.chain(extra_config_files.into_iter());
|
||||
let config_files = config_file.into_iter().chain(extra_config_files);
|
||||
|
||||
let mut load_errs = vec![];
|
||||
for config_file in config_files {
|
||||
@ -505,6 +546,8 @@ impl App {
|
||||
Back => self.back(),
|
||||
LastVisitedPath => self.last_visited_path(),
|
||||
NextVisitedPath => self.next_visited_path(),
|
||||
PreviousVisitedDeepBranch => self.previous_visited_deep_branch(),
|
||||
NextVisitedDeepBranch => self.next_visited_deep_branch(),
|
||||
FollowSymlink => self.follow_symlink(),
|
||||
SetVroot(p) => self.set_vroot(&p),
|
||||
UnsetVroot => self.unset_vroot(),
|
||||
@ -1082,6 +1125,24 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
fn previous_visited_deep_branch(mut self) -> Result<Self> {
|
||||
self.history = self.history.visit_previous_deep_branch(&self.pwd);
|
||||
if let Some(path) = self.history.peek().cloned() {
|
||||
self.change_directory(path.trim_end_matches('/'), false)
|
||||
} else {
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
|
||||
fn next_visited_deep_branch(mut self) -> Result<Self> {
|
||||
self.history = self.history.visit_next_deep_branch(&self.pwd);
|
||||
if let Some(path) = self.history.peek().cloned() {
|
||||
self.change_directory(path.trim_end_matches('/'), false)
|
||||
} else {
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
|
||||
fn set_input_prompt(mut self, p: String) -> Result<Self> {
|
||||
self.input.prompt = p;
|
||||
Ok(self)
|
||||
@ -2039,7 +2100,7 @@ impl App {
|
||||
let read_only = self.config.general.read_only;
|
||||
let global_kb = &self.config.general.global_key_bindings;
|
||||
|
||||
let modes = builtin.into_iter().chain(custom.into_iter());
|
||||
let modes = builtin.into_iter().chain(custom);
|
||||
|
||||
std::iter::once((self.mode.name.clone(), self.mode.clone()))
|
||||
.chain(modes)
|
||||
|
@ -185,7 +185,7 @@ pub fn pipe_msg_in(args: Vec<String>) -> Result<()> {
|
||||
.cloned()
|
||||
.context("failed to detect delimmiter")?;
|
||||
|
||||
msg.push(delimiter.try_into()?);
|
||||
msg.push(delimiter.into());
|
||||
File::options()
|
||||
.append(true)
|
||||
.open(&path)?
|
||||
|
@ -9,7 +9,6 @@ use crate::ui::Constraint;
|
||||
use crate::ui::ContentRendererArg;
|
||||
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;
|
||||
@ -60,8 +59,8 @@ pub struct CustomContent {
|
||||
}
|
||||
|
||||
/// A cursed function from crate::ui.
|
||||
pub fn draw_custom_content<B: Backend>(
|
||||
f: &mut Frame<B>,
|
||||
pub fn draw_custom_content(
|
||||
f: &mut Frame,
|
||||
screen_size: TuiRect,
|
||||
layout_size: TuiRect,
|
||||
app: &app::App,
|
||||
@ -165,8 +164,7 @@ pub fn draw_custom_content<B: Backend>(
|
||||
.map(|w| w.to_tui(screen_size, layout_size))
|
||||
.collect::<Vec<TuiConstraint>>();
|
||||
|
||||
let content = Table::new(rows)
|
||||
.widths(&widths)
|
||||
let content = Table::new(rows, widths)
|
||||
.column_spacing(col_spacing.unwrap_or(1))
|
||||
.block(block(
|
||||
config,
|
||||
@ -209,7 +207,7 @@ pub fn draw_custom_content<B: Backend>(
|
||||
.map(|w| w.to_tui(screen_size, layout_size))
|
||||
.collect::<Vec<TuiConstraint>>();
|
||||
|
||||
let mut content = Table::new(rows).widths(&widths).block(block(
|
||||
let mut content = Table::new(rows, &widths).block(block(
|
||||
config,
|
||||
title.map(|t| format!(" {t} ")).unwrap_or_default(),
|
||||
));
|
||||
|
@ -18,7 +18,8 @@ pub fn config_dir() -> Option<PathBuf> {
|
||||
pub fn runtime_dir() -> PathBuf {
|
||||
let Some(dir) = BASE_DIRS
|
||||
.as_ref()
|
||||
.and_then(|base| base.get_runtime_directory().ok()) else {
|
||||
.and_then(|base| base.get_runtime_directory().ok())
|
||||
else {
|
||||
return env::temp_dir();
|
||||
};
|
||||
dir.to_owned()
|
||||
|
12
src/init.lua
12
src/init.lua
@ -1123,6 +1123,18 @@ xplr.config.modes.builtin.default = {
|
||||
"LastVisitedPath",
|
||||
},
|
||||
},
|
||||
[")"] = {
|
||||
help = "next deep branch",
|
||||
messages = {
|
||||
"NextVisitedDeepBranch",
|
||||
},
|
||||
},
|
||||
["("] = {
|
||||
help = "prev deep branch",
|
||||
messages = {
|
||||
"PreviousVisitedDeepBranch",
|
||||
},
|
||||
},
|
||||
["ctrl-r"] = {
|
||||
help = "refresh screen",
|
||||
messages = {
|
||||
|
@ -7,7 +7,7 @@ use anyhow::Result;
|
||||
use mlua::Lua;
|
||||
use mlua::LuaSerdeExt;
|
||||
use mlua::SerializeOptions;
|
||||
use serde::Deserialize;
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde::Serialize;
|
||||
use std::fs;
|
||||
|
||||
@ -81,7 +81,7 @@ pub fn init(lua: &Lua) -> Result<(Config, Option<Hooks>)> {
|
||||
|
||||
let hooks: Option<Hooks> = lua
|
||||
.load(DEFAULT_LUA_SCRIPT)
|
||||
.set_name("xplr init")?
|
||||
.set_name("xplr init")
|
||||
.call(())
|
||||
.and_then(|v| lua.from_value(v))?;
|
||||
|
||||
@ -98,7 +98,7 @@ pub fn extend(lua: &Lua, path: &str) -> Result<(Config, Option<Hooks>)> {
|
||||
|
||||
let hooks: Option<Hooks> = lua
|
||||
.load(&script)
|
||||
.set_name(path)?
|
||||
.set_name(path)
|
||||
.call(())
|
||||
.and_then(|v| lua.from_value(v))?;
|
||||
|
||||
@ -138,7 +138,7 @@ pub fn resolve_fn<'lua>(
|
||||
resolve_fn_recursive(globals, path.split('.'))
|
||||
}
|
||||
|
||||
pub fn call<'lua, R: Deserialize<'lua>>(
|
||||
pub fn call<'lua, R: DeserializeOwned>(
|
||||
lua: &'lua Lua,
|
||||
func: &str,
|
||||
arg: mlua::Value<'lua>,
|
||||
|
@ -277,6 +277,22 @@ pub enum ExternalMsg {
|
||||
/// - YAML: `NextVisitedPath`
|
||||
NextVisitedPath,
|
||||
|
||||
/// Go to the previous deep level branch.
|
||||
///
|
||||
/// Example:
|
||||
///
|
||||
/// - Lua: `"PreviousVisitedDeepBranch"`
|
||||
/// - YAML: `PreviousVisitedDeepBranch`
|
||||
PreviousVisitedDeepBranch,
|
||||
|
||||
/// Go to the next deep level branch.
|
||||
///
|
||||
/// Example:
|
||||
///
|
||||
/// - Lua: `"NextVisitedDeepBranch"`
|
||||
/// - YAML: `NextVisitedDeepBranch`
|
||||
NextVisitedDeepBranch,
|
||||
|
||||
/// Follow the symlink under focus to its actual location.
|
||||
///
|
||||
/// Example:
|
||||
|
@ -39,8 +39,8 @@ where
|
||||
}
|
||||
(None, _) => comps.push(Component::ParentDir),
|
||||
(Some(a), Some(b)) if comps.is_empty() && a == b => (),
|
||||
(Some(a), Some(b)) if b == Component::CurDir => comps.push(a),
|
||||
(Some(_), Some(b)) if b == Component::ParentDir => {
|
||||
(Some(a), Some(Component::CurDir)) => comps.push(a),
|
||||
(Some(_), Some(Component::ParentDir)) => {
|
||||
let path = path.to_string_lossy();
|
||||
let base = base.to_string_lossy();
|
||||
bail!("{base} is not a parent of {path}")
|
||||
@ -242,7 +242,7 @@ mod tests {
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
relative,
|
||||
PathBuf::from("../..").join(parent.clone().file_name().unwrap())
|
||||
PathBuf::from("../..").join(parent.file_name().unwrap())
|
||||
);
|
||||
}
|
||||
|
||||
|
66
src/ui.rs
66
src/ui.rs
@ -16,7 +16,6 @@ use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::ops::BitXor;
|
||||
use time::macros::format_description;
|
||||
use tui::backend::Backend;
|
||||
use tui::layout::Rect as TuiRect;
|
||||
use tui::layout::{Constraint as TuiConstraint, Direction, Layout as TuiLayout};
|
||||
use tui::style::{Color, Modifier as TuiModifier, Style as TuiStyle};
|
||||
@ -666,8 +665,8 @@ pub fn block<'a>(config: PanelUiConfig, default_title: String) -> Block<'a> {
|
||||
.border_style(config.border_style.into())
|
||||
}
|
||||
|
||||
fn draw_table<B: Backend>(
|
||||
f: &mut Frame<B>,
|
||||
fn draw_table(
|
||||
f: &mut Frame,
|
||||
screen_size: TuiRect,
|
||||
layout_size: TuiRect,
|
||||
app: &app::App,
|
||||
@ -822,8 +821,7 @@ fn draw_table<B: Backend>(
|
||||
format!("({node_count}) ")
|
||||
};
|
||||
|
||||
let table = Table::new(rows)
|
||||
.widths(&table_constraints)
|
||||
let table = Table::new(rows, table_constraints)
|
||||
.style(app_config.general.table.style.to_owned().into())
|
||||
.highlight_style(app_config.general.focus_ui.style.to_owned().into())
|
||||
.column_spacing(app_config.general.table.col_spacing.unwrap_or_default())
|
||||
@ -855,8 +853,8 @@ fn draw_table<B: Backend>(
|
||||
f.render_widget(table, layout_size);
|
||||
}
|
||||
|
||||
fn draw_selection<B: Backend>(
|
||||
f: &mut Frame<B>,
|
||||
fn draw_selection(
|
||||
f: &mut Frame,
|
||||
_screen_size: TuiRect,
|
||||
layout_size: TuiRect,
|
||||
app: &app::App,
|
||||
@ -911,8 +909,8 @@ fn draw_selection<B: Backend>(
|
||||
f.render_widget(selection_list, layout_size);
|
||||
}
|
||||
|
||||
fn draw_help_menu<B: Backend>(
|
||||
f: &mut Frame<B>,
|
||||
fn draw_help_menu(
|
||||
f: &mut Frame,
|
||||
_screen_size: TuiRect,
|
||||
layout_size: TuiRect,
|
||||
app: &app::App,
|
||||
@ -941,25 +939,24 @@ fn draw_help_menu<B: Backend>(
|
||||
})
|
||||
.collect::<Vec<Row>>();
|
||||
|
||||
let help_menu = Table::new(help_menu_rows)
|
||||
.block(block(
|
||||
config,
|
||||
format!(" Help [{}{}] ", &app.mode.name, read_only_indicator(app)),
|
||||
))
|
||||
.widths(if app.config.general.hide_remaps_in_help_menu {
|
||||
&[TuiConstraint::Percentage(20), TuiConstraint::Percentage(80)]
|
||||
let widths = if app.config.general.hide_remaps_in_help_menu {
|
||||
vec![TuiConstraint::Percentage(20), TuiConstraint::Percentage(80)]
|
||||
} else {
|
||||
&[
|
||||
vec![
|
||||
TuiConstraint::Percentage(20),
|
||||
TuiConstraint::Percentage(20),
|
||||
TuiConstraint::Percentage(60),
|
||||
]
|
||||
});
|
||||
};
|
||||
let help_menu = Table::new(help_menu_rows, widths).block(block(
|
||||
config,
|
||||
format!(" Help [{}{}] ", &app.mode.name, read_only_indicator(app)),
|
||||
));
|
||||
f.render_widget(help_menu, layout_size);
|
||||
}
|
||||
|
||||
fn draw_input_buffer<B: Backend>(
|
||||
f: &mut Frame<B>,
|
||||
fn draw_input_buffer(
|
||||
f: &mut Frame,
|
||||
_screen_size: TuiRect,
|
||||
layout_size: TuiRect,
|
||||
app: &app::App,
|
||||
@ -1020,8 +1017,8 @@ fn draw_input_buffer<B: Backend>(
|
||||
};
|
||||
}
|
||||
|
||||
fn draw_sort_n_filter<B: Backend>(
|
||||
f: &mut Frame<B>,
|
||||
fn draw_sort_n_filter(
|
||||
f: &mut Frame,
|
||||
_screen_size: TuiRect,
|
||||
layout_size: TuiRect,
|
||||
app: &app::App,
|
||||
@ -1142,8 +1139,8 @@ fn draw_sort_n_filter<B: Backend>(
|
||||
f.render_widget(p, layout_size);
|
||||
}
|
||||
|
||||
fn draw_logs<B: Backend>(
|
||||
f: &mut Frame<B>,
|
||||
fn draw_logs(
|
||||
f: &mut Frame,
|
||||
_screen_size: TuiRect,
|
||||
layout_size: TuiRect,
|
||||
app: &app::App,
|
||||
@ -1218,8 +1215,8 @@ fn draw_logs<B: Backend>(
|
||||
f.render_widget(logs_list, layout_size);
|
||||
}
|
||||
|
||||
pub fn draw_nothing<B: Backend>(
|
||||
f: &mut Frame<B>,
|
||||
pub fn draw_nothing(
|
||||
f: &mut Frame,
|
||||
_screen_size: TuiRect,
|
||||
layout_size: TuiRect,
|
||||
app: &app::App,
|
||||
@ -1231,8 +1228,8 @@ pub fn draw_nothing<B: Backend>(
|
||||
f.render_widget(nothing, layout_size);
|
||||
}
|
||||
|
||||
pub fn draw_dynamic<B: Backend>(
|
||||
f: &mut Frame<B>,
|
||||
pub fn draw_dynamic(
|
||||
f: &mut Frame,
|
||||
screen_size: TuiRect,
|
||||
layout_size: TuiRect,
|
||||
app: &app::App,
|
||||
@ -1255,8 +1252,8 @@ pub fn draw_dynamic<B: Backend>(
|
||||
draw_static(f, screen_size, layout_size, app, panel, lua);
|
||||
}
|
||||
|
||||
pub fn draw_static<B: Backend>(
|
||||
f: &mut Frame<B>,
|
||||
pub fn draw_static(
|
||||
f: &mut Frame,
|
||||
screen_size: TuiRect,
|
||||
layout_size: TuiRect,
|
||||
app: &app::App,
|
||||
@ -1309,8 +1306,7 @@ pub fn draw_static<B: Backend>(
|
||||
.map(|w| w.to_tui(screen_size, layout_size))
|
||||
.collect::<Vec<TuiConstraint>>();
|
||||
|
||||
let content = Table::new(rows)
|
||||
.widths(&widths)
|
||||
let content = Table::new(rows, widths)
|
||||
.column_spacing(col_spacing.unwrap_or(1))
|
||||
.block(block(config, "".into()));
|
||||
|
||||
@ -1349,9 +1345,9 @@ pub struct ContentRendererArg {
|
||||
pub layout_size: Rect,
|
||||
}
|
||||
|
||||
pub fn draw_layout<B: Backend>(
|
||||
pub fn draw_layout(
|
||||
layout: Layout,
|
||||
f: &mut Frame<B>,
|
||||
f: &mut Frame,
|
||||
screen_size: TuiRect,
|
||||
layout_size: TuiRect,
|
||||
app: &app::App,
|
||||
@ -1445,7 +1441,7 @@ pub fn draw_layout<B: Backend>(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn draw<B: Backend>(f: &mut Frame<B>, app: &app::App, lua: &Lua) {
|
||||
pub fn draw(f: &mut Frame, app: &app::App, lua: &Lua) {
|
||||
let screen_size = f.size();
|
||||
let layout = app.mode.layout.as_ref().unwrap_or(&app.layout).to_owned();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user