summaryrefslogtreecommitdiffstats
path: root/src/verb/builtin.rs
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2020-05-01 14:01:02 +0200
committerCanop <cano.petrole@gmail.com>2020-05-01 21:31:53 +0200
commit0199162bc8d4fee5bb7f07fbb41570df95205057 (patch)
tree74c6bb798700b7dc7cc21c0173319f6ee51ba02c /src/verb/builtin.rs
parentcf52bbe7dc19cba78d65f431caa2af36c23da589 (diff)
command/verb/apply refactoring
* simpler, with immutable commands * more commands can be triggered by shortcuts * one can apply verbs to the input (using shortcuts)
Diffstat (limited to 'src/verb/builtin.rs')
-rw-r--r--src/verb/builtin.rs152
1 files changed, 41 insertions, 111 deletions
diff --git a/src/verb/builtin.rs b/src/verb/builtin.rs
index 04e41f5..783b146 100644
--- a/src/verb/builtin.rs
+++ b/src/verb/builtin.rs
@@ -1,146 +1,76 @@
-
-use {
- crate::{
- keys::*,
- },
- super::Verb,
-};
+use {super::Verb, crate::keys::*};
/// declare the built_in verbs, the ones which are available
/// in standard (they still may be overriden by configuration)
pub fn builtin_verbs() -> Vec<Verb> {
- use super::{
- ExternalExecutionMode::*,
- Internal::*,
- };
+ use super::{ExternalExecutionMode::*, Internal::*};
vec![
-
Verb::internal(back),
-
Verb::from(super::cd::CD.clone())
.with_description("change directory and quit (mapped to *alt*-*enter*)"),
-
#[cfg(unix)]
- Verb::external(
- "chmod {args}",
- "chmod {args} {file}",
- StayInBroot,
- ).unwrap(),
-
- Verb::internal(close_tab)
- .with_key(BACK_TAB),
-
+ Verb::external("chmod {args}", "chmod {args} {file}", StayInBroot).unwrap(),
+ Verb::internal(complete).with_key(TAB),
+ Verb::internal(close_panel)
+ //.with_key(BACK_TAB),
+ .with_control_key('w'),
Verb::external(
"cp {newpath}",
"/bin/cp -r {file} {newpath:path-from-parent}",
StayInBroot,
- ).unwrap(),
-
+ )
+ .unwrap(),
Verb::internal(focus) // hardcoded Enter
.with_shortcut("goto"),
-
- Verb::internal_bang(focus, true)
- .with_key(TAB),
-
+ Verb::internal_bang(focus, true).with_key(TAB),
Verb::internal(focus_root),
-
- Verb::internal(help)
- .with_key(F1)
- .with_shortcut("?"),
-
- Verb::internal(line_down)
- .with_key(DOWN),
-
- Verb::internal(line_up)
- .with_key(UP),
-
+ Verb::internal(help).with_key(F1).with_shortcut("?"),
+ Verb::internal(line_down).with_key(DOWN),
+ Verb::internal(line_up).with_key(UP),
Verb::external(
"mkdir {subpath}",
"/bin/mkdir -p {subpath:path-from-directory}",
StayInBroot,
- ).unwrap()
- .with_shortcut("md"),
-
+ )
+ .unwrap()
+ .with_shortcut("md"),
Verb::external(
"mv {newpath}",
"/bin/mv {file} {newpath:path-from-parent}",
StayInBroot,
- ).unwrap(),
-
+ )
+ .unwrap(),
+ Verb::internal(open_panel).with_control_key('p'),
Verb::internal(open_stay)
+ .with_key(ENTER)
.with_shortcut("os"),
-
Verb::internal(open_leave)
+ .with_key(ALT_ENTER)
.with_shortcut("ol"),
-
- Verb::internal(parent)
- .with_shortcut("p"),
-
- Verb::internal(page_down)
- .with_key(PAGE_DOWN),
-
- Verb::internal(page_up)
- .with_key(PAGE_UP),
-
- Verb::internal(parent)
- .with_shortcut("p"),
-
- Verb::internal(print_path)
- .with_shortcut("pp"),
-
- Verb::internal(print_relative_path)
- .with_shortcut("prp"),
-
- Verb::internal(print_tree)
- .with_shortcut("pt"),
-
+ Verb::internal(parent).with_shortcut("p"),
+ Verb::internal(page_down).with_key(PAGE_DOWN),
+ Verb::internal(page_up).with_key(PAGE_UP),
+ Verb::internal(parent).with_shortcut("p"),
+ Verb::internal(print_path).with_shortcut("pp"),
+ Verb::internal(print_relative_path).with_shortcut("prp"),
+ Verb::internal(print_tree).with_shortcut("pt"),
Verb::internal(quit)
.with_key(CTRL_C)
.with_key(CTRL_Q)
.with_shortcut("q"),
-
- Verb::internal(refresh)
- .with_key(F5),
-
- Verb::external(
- "rm",
- "/bin/rm -rf {file}",
- StayInBroot,
- ).unwrap(),
-
- Verb::internal(toggle_dates)
- .with_shortcut("dates"),
-
- Verb::internal(toggle_files)
- .with_shortcut("files"),
-
- Verb::internal(toggle_git_ignore)
- .with_shortcut("gi"),
-
- Verb::internal(toggle_git_file_info)
- .with_shortcut("gf"),
-
- Verb::internal(toggle_git_status)
- .with_shortcut("gs"),
-
- Verb::internal(toggle_hidden)
- .with_shortcut("h"),
-
+ Verb::internal(refresh).with_key(F5),
+ Verb::external("rm", "/bin/rm -rf {file}", StayInBroot).unwrap(),
+ Verb::internal(toggle_dates).with_shortcut("dates"),
+ Verb::internal(toggle_files).with_shortcut("files"),
+ Verb::internal(toggle_git_ignore).with_shortcut("gi"),
+ Verb::internal(toggle_git_file_info).with_shortcut("gf"),
+ Verb::internal(toggle_git_status).with_shortcut("gs"),
+ Verb::internal(toggle_hidden).with_shortcut("h"),
#[cfg(unix)]
- Verb::internal(toggle_perm)
- .with_shortcut("perm"),
-
- Verb::internal(toggle_sizes)
- .with_shortcut("sizes"),
-
- Verb::internal(toggle_trim_root)
- .with_shortcut("t"),
-
- Verb::internal(total_search)
- .with_key(CTRL_S),
-
- Verb::internal(up_tree)
- .with_shortcut("up"),
-
+ Verb::internal(toggle_perm).with_shortcut("perm"),
+ Verb::internal(toggle_sizes).with_shortcut("sizes"),
+ Verb::internal(toggle_trim_root).with_shortcut("t"),
+ Verb::internal(total_search).with_key(CTRL_S),
+ Verb::internal(up_tree).with_shortcut("up"),
]
}