Add builtin vroot mode

Also fix ResetVroot
pull/524/head
Arijit Basu 2 years ago
parent eba9de5a44
commit 289556f452
No known key found for this signature in database
GPG Key ID: 0F8EF5258DC38077

@ -14,42 +14,106 @@ of [modes][4] and the key mappings for each mode.
### default ### default
| key | remaps | action | | key | remaps | action |
| ------ | ------ | ------------------- | | --------- | ------ | ------------------- |
| . | | show hidden | | . | | show hidden |
| / | ctrl-f | search | | / | ctrl-f | search |
| : | | action | | : | | action |
| ? | | global help menu | | ? | | global help menu |
| G | | go to bottom | | G | | go to bottom |
| V | ctrl-a | select/unselect all | | V | ctrl-a | select/unselect all |
| ctrl-d | | duplicate as | | ctrl-d | | duplicate as |
| ctrl-i | tab | next visited path | | ctrl-i | tab | next visited path |
| ctrl-o | | last visited path | | ctrl-o | | last visited path |
| ctrl-r | | refresh screen | | ctrl-r | | refresh screen |
| ctrl-u | | clear selection | | ctrl-u | | clear selection |
| ctrl-w | | switch layout | | ctrl-w | | switch layout |
| d | | delete | | d | | delete |
| down | j | down | | down | j | down |
| enter | | quit with result | | enter | | quit with result |
| f | | filter | | f | | filter |
| g | | go to | | g | | go to |
| h | left | back | | h | left | back |
| k | up | up | | k | up | up |
| l | right | enter | | l | right | enter |
| q | | quit | | page-down | | scroll down |
| r | | rename | | page-up | | scroll up |
| s | | sort | | q | | quit |
| space | v | toggle selection | | r | | rename |
| ~ | | go home | | s | | sort |
| [0-9] | | input | | space | v | toggle selection |
| { | | scroll up half |
| } | | scroll down half |
| ~ | | go home |
| [0-9] | | input |
### go_to_path ### 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 |
### vroot
| key | remaps | action |
| ------ | ------ | ----------- |
| . | | vroot $PWD |
| / | | vroot / |
| ctrl-r | | reset vroot |
| ~ | | vroot ~ |
### create_file
| key | remaps | action | | key | remaps | action |
| ----- | ------ | ------------ | | ----- | ------ | ------------ |
| enter | | submit | | enter | | submit |
| tab | | try complete | | tab | | try complete |
### selection_ops
| key | remaps | action |
| --- | ------ | --------------- |
| c | | copy here |
| m | | move here |
| u | | clear selection |
### create
| key | remaps | action |
| --- | ------ | ---------------- |
| d | | create directory |
| f | | create file |
### quit
| key | remaps | action |
| ----- | ------ | ----------------------- |
| enter | | just quit |
| f | | quit printing focus |
| p | | quit printing pwd |
| r | | quit printing result |
| s | | quit printing selection |
### switch_layout
| key | remaps | action |
| --- | ------ | -------------------- |
| 1 | | default |
| 2 | | no help menu |
| 3 | | no selection panel |
| 4 | | no help or selection |
### delete
| key | remaps | action |
| --- | ------ | ------------ |
| D | | force delete |
| d | | delete |
### relative_path_does_not_match_regex ### relative_path_does_not_match_regex
| key | remaps | action | | key | remaps | action |
@ -65,13 +129,18 @@ of [modes][4] and the key mappings for each mode.
| k | up | to up | | k | up | to up |
| [0-9] | | input | | [0-9] | | input |
### selection_ops ### relative_path_does_match_regex
| key | remaps | action |
| ----- | ------ | ------ |
| enter | | submit |
| key | remaps | action | ### create_directory
| --- | ------ | ----------- |
| c | | copy here | | key | remaps | action |
| m | | move here | | ----- | ------ | ------------ |
| x | | open in gui | | enter | | submit |
| tab | | try complete |
### duplicate_as ### duplicate_as
@ -80,27 +149,19 @@ of [modes][4] and the key mappings for each mode.
| enter | | submit | | enter | | submit |
| tab | | try complete | | tab | | try complete |
### action ### rename
| key | remaps | action | | key | remaps | action |
| ----- | ------ | -------------------- | | ----- | ------ | ------------ |
| ! | | shell | | enter | | submit |
| c | | create | | tab | | try complete |
| e | | open in editor |
| l | | logs |
| m | | toggle mouse |
| q | | quit options |
| s | | selection operations |
| [0-9] | | go to index |
### go_to ### go_to_path
| key | remaps | action | | key | remaps | action |
| --- | ------ | -------------- | | ----- | ------ | ------------ |
| f | | follow symlink | | enter | | submit |
| g | | top | | tab | | try complete |
| p | | path |
| x | | open in gui |
### sort ### sort
@ -126,29 +187,6 @@ of [modes][4] and the key mappings for each mode.
| r | | by relative path | | r | | by relative path |
| s | | by size | | s | | by size |
### rename
| key | remaps | action |
| ----- | ------ | ------------ |
| enter | | submit |
| tab | | try complete |
### debug_error
| key | remaps | action |
| ----- | ------ | ------------------- |
| enter | | open logs in editor |
| q | | quit |
### switch_layout
| key | remaps | action |
| --- | ------ | -------------------- |
| 1 | | default |
| 2 | | no help menu |
| 3 | | no selection panel |
| 4 | | no help or selection |
### search ### search
| key | remaps | action | | key | remaps | action |
@ -161,61 +199,37 @@ of [modes][4] and the key mappings for each mode.
| right | | enter | | right | | enter |
| tab | | toggle selection | | tab | | toggle selection |
### create_file ### debug_error
| key | remaps | action | | key | remaps | action |
| ----- | ------ | ------------ | | ----- | ------ | ------------------- |
| enter | | submit | | enter | | open logs in editor |
| tab | | try complete | | q | | quit |
### action
| key | remaps | action |
| ----- | ------ | -------------------- |
| ! | | shell |
| c | | create |
| e | | open in editor |
| l | | logs |
| m | | toggle mouse |
| q | | quit options |
| s | | selection operations |
| v | | vroot |
| [0-9] | | go to index |
### recover ### recover
| key | remaps | action | | key | remaps | action |
| --- | ------ | ------ | | --- | ------ | ------ |
### create ### go_to
| key | remaps | action |
| --- | ------ | ---------------- |
| d | | create directory |
| f | | create file |
### 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 |
### delete
| key | remaps | action |
| --- | ------ | ------------ |
| D | | force delete |
| d | | delete |
### create_directory
| key | remaps | action |
| ----- | ------ | ------------ |
| enter | | submit |
| tab | | try complete |
### quit
| key | remaps | action |
| ----- | ------ | ----------------------- |
| enter | | just quit |
| f | | quit printing focus |
| p | | quit printing pwd |
| r | | quit printing result |
| s | | quit printing selection |
### relative_path_does_match_regex
| key | remaps | action | | key | remaps | action |
| ----- | ------ | ------ | | --- | ------ | -------------- |
| enter | | submit | | f | | follow symlink |
| g | | top |
| p | | path |
| x | | open in gui |

@ -783,10 +783,11 @@ impl App {
} }
} }
fn reset_vroot(self) -> Result<Self> { fn reset_vroot(mut self) -> Result<Self> {
if let Some(vroot) = self.initial_vroot.clone() { if let Some(vroot) = self.initial_vroot.clone() {
self.set_vroot(&vroot) self.set_vroot(&vroot)
} else { } else {
self.vroot = None;
Ok(self) Ok(self)
} }
} }

@ -1876,6 +1876,13 @@ xplr.config.modes.builtin.action = {
"ToggleMouse", "ToggleMouse",
}, },
}, },
["v"] = {
help = "vroot",
messages = {
"PopMode",
{ SwitchModeBuiltin = "vroot" },
},
},
["q"] = { ["q"] = {
help = "quit options", help = "quit options",
messages = { messages = {
@ -2311,6 +2318,53 @@ xplr.config.modes.builtin.switch_layout = {
}, },
} }
-- The builtin vroot mode.
--
-- Type: [Mode](https://xplr.dev/en/mode)
xplr.config.modes.builtin.vroot = {
name = "vroot",
key_bindings = {
on_key = {
["."] = {
help = "vroot $PWD",
messages = {
"PopMode",
{
BashExecSilently0 = [===[
"$XPLR" -m 'SetVroot: %q' "${PWD:?}"
]===],
},
},
},
["/"] = {
help = "vroot /",
messages = {
"PopMode",
{ SetVroot = "/" },
},
},
["~"] = {
help = "vroot ~",
messages = {
"PopMode",
{
BashExecSilently0 = [===[
"$XPLR" -m 'SetVroot: %q' "${HOME:?}"
]===],
},
},
},
["ctrl-r"] = {
help = "reset vroot",
messages = {
"PopMode",
"ResetVroot",
},
},
},
},
}
-- This is where you define custom modes. -- This is where you define custom modes.
-- --
-- Type: mapping of the following key-value pairs: -- Type: mapping of the following key-value pairs:

Loading…
Cancel
Save