Minor updates

This commit is contained in:
Arijit Basu 2023-01-28 23:54:08 +05:30
parent 1212acdf99
commit d9d2fa15e3
3 changed files with 134 additions and 99 deletions

View File

@ -47,48 +47,37 @@ of [modes][4] and the key mappings for each mode.
| ~ | | go home | | ~ | | go home |
| [0-9] | | input | | [0-9] | | input |
### filter ### recover
| key | remaps | action | | 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 ### rename
| key | remaps | action |
| ------ | ------ | ------------ |
| . | | vroot $PWD |
| / | | vroot / |
| ~ | | vroot $HOME |
| v | | toggle vroot |
| ctrl-r | | reset vroot |
| ctrl-u | | unset vroot |
### create_file
| key | remaps | action | | key | remaps | action |
| ----- | ------ | ------------ | | ----- | ------ | ------------ |
| enter | | submit | | enter | | submit |
| tab | | try complete | | tab | | try complete |
### selection_ops ### create_directory
| key | remaps | action | | key | remaps | action |
| --- | ------ | --------------- | | ----- | ------ | ------------ |
| c | | copy here | | enter | | submit |
| m | | move here | | tab | | try complete |
| u | | clear selection |
### create ### relative_path_does_not_match_regex
| key | remaps | action | | key | remaps | action |
| --- | ------ | ---------------- | | ----- | ------ | ------ |
| d | | create directory | | enter | | submit |
| f | | create file |
### duplicate_as
| key | remaps | action |
| ----- | ------ | ------------ |
| enter | | submit |
| tab | | try complete |
### quit ### quit
@ -100,6 +89,13 @@ of [modes][4] and the key mappings for each mode.
| r | | quit printing result | | r | | quit printing result |
| s | | quit printing selection | | s | | quit printing selection |
### debug_error
| key | remaps | action |
| ----- | ------ | ------------------- |
| enter | | open logs in editor |
| q | | quit |
### switch_layout ### switch_layout
| key | remaps | action | | key | remaps | action |
@ -109,18 +105,19 @@ of [modes][4] and the key mappings for each mode.
| 3 | | no selection panel | | 3 | | no selection panel |
| 4 | | no help or selection | | 4 | | no help or selection |
### delete ### go_to_path
| key | remaps | action | | key | remaps | action |
| --- | ------ | ------------ | | ----- | ------ | ------------ |
| D | | force delete | | enter | | submit |
| d | | delete | | tab | | try complete |
### relative_path_does_not_match_regex ### create
| key | remaps | action | | key | remaps | action |
| ----- | ------ | ------ | | --- | ------ | ---------------- |
| enter | | submit | | d | | create directory |
| f | | create file |
### number ### number
@ -131,39 +128,74 @@ of [modes][4] and the key mappings for each mode.
| k | up | to up | | k | up | to up |
| [0-9] | | input | | [0-9] | | input |
### 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 |
### 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 |
### relative_path_does_match_regex ### relative_path_does_match_regex
| key | remaps | action | | key | remaps | action |
| ----- | ------ | ------ | | ----- | ------ | ------ |
| enter | | submit | | enter | | submit |
### create_directory ### vroot
| key | remaps | action |
| ------ | ------ | ------------ |
| . | | vroot $PWD |
| / | | vroot / |
| ctrl-r | | reset vroot |
| ctrl-u | | unset vroot |
| v | | toggle vroot |
| ~ | | vroot $HOME |
### selection_ops
| key | remaps | action |
| --- | ------ | --------------- |
| c | | copy here |
| h | | hardlink here |
| l | | list selection |
| m | | move here |
| s | | softlink here |
| u | | clear selection |
### create_file
| key | remaps | action | | key | remaps | action |
| ----- | ------ | ------------ | | ----- | ------ | ------------ |
| enter | | submit | | enter | | submit |
| tab | | try complete | | tab | | try complete |
### duplicate_as ### go_to
| key | remaps | action | | key | remaps | action |
| ----- | ------ | ------------ | | --- | ------ | -------------- |
| enter | | submit | | f | | follow symlink |
| tab | | try complete | | g | | top |
| i | | initial $PWD |
### rename | p | | path |
| x | | open in gui |
| key | remaps | action |
| ----- | ------ | ------------ |
| enter | | submit |
| tab | | try complete |
### go_to_path
| key | remaps | action |
| ----- | ------ | ------------ |
| enter | | submit |
| tab | | try complete |
### sort ### sort
@ -189,6 +221,13 @@ of [modes][4] and the key mappings for each mode.
| r | | by relative path | | r | | by relative path |
| s | | by size | | s | | by size |
### delete
| key | remaps | action |
| --- | ------ | ------------ |
| D | | force delete |
| d | | delete |
### search ### search
| key | remaps | action | | key | remaps | action |
@ -200,39 +239,3 @@ of [modes][4] and the key mappings for each mode.
| left | | back | | left | | back |
| right | | enter | | right | | enter |
| tab | | toggle selection | | tab | | toggle selection |
### debug_error
| key | remaps | action |
| ----- | ------ | ------------------- |
| enter | | open logs in editor |
| 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
| key | remaps | action |
| --- | ------ | ------ |
### go_to
| key | remaps | action |
| --- | ------ | -------------- |
| f | | follow symlink |
| g | | top |
| i | | initial $PWD |
| p | | path |
| x | | open in gui |

View File

@ -280,3 +280,35 @@ xplr.util.textwrap(
) )
-- { "this will be", " cut off" } -- { "this will be", " cut off" }
``` ```
### xplr.util.layout_replace
Find the target layout in the given layout and replace it with the replacement layout,
returning a new layout.
Type: function( layout:[Layout][4], target:[Layout][4], replacement:[Layout][4] ) -> layout:[Layout][4]
Example:
```lua
local layout = {
Horizontal = {
splits = {
"Table", -- Target
"HelpMenu",
},
config = ...,
}
}
xplr.util.layout_replace(layout, "Table", "Selection")
-- {
-- Horizontal = {
-- splits = {
-- "Selection", -- Replaced
-- "HelpMenu",
-- },
-- config = ...
-- }
-- }
```

View File

@ -43,7 +43,7 @@ pub(crate) fn create_table(lua: &Lua) -> Result<Table> {
util = relative_to(util, lua)?; util = relative_to(util, lua)?;
util = shortened(util, lua)?; util = shortened(util, lua)?;
util = textwrap(util, lua)?; util = textwrap(util, lua)?;
util = layout_replaced(util, lua)?; util = layout_replace(util, lua)?;
Ok(util) Ok(util)
} }
@ -532,7 +532,7 @@ pub fn textwrap<'a>(util: Table<'a>, lua: &Lua) -> Result<Table<'a>> {
/// } /// }
/// } /// }
/// ///
/// xplr.util.layout_replaced(layout, "Table", "Selection") /// xplr.util.layout_replace(layout, "Table", "Selection")
/// -- { /// -- {
/// -- Horizontal = { /// -- Horizontal = {
/// -- splits = { /// -- splits = {
@ -543,7 +543,7 @@ pub fn textwrap<'a>(util: Table<'a>, lua: &Lua) -> Result<Table<'a>> {
/// -- } /// -- }
/// -- } /// -- }
/// ``` /// ```
pub fn layout_replaced<'a>(util: Table<'a>, lua: &Lua) -> Result<Table<'a>> { pub fn layout_replace<'a>(util: Table<'a>, lua: &Lua) -> Result<Table<'a>> {
let func = lua.create_function( let func = lua.create_function(
move |lua, (layout, target, replacement): (Table, Table, Table)| { move |lua, (layout, target, replacement): (Table, Table, Table)| {
let layout: Layout = lua.from_value(Value::Table(layout))?; let layout: Layout = lua.from_value(Value::Table(layout))?;