summaryrefslogtreecommitdiffstats
path: root/src/verb/verb.rs
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2021-05-29 18:50:12 +0200
committerCanop <cano.petrole@gmail.com>2021-05-29 18:50:12 +0200
commit07e95eab0ad33e035c7efe39442f18d1eff6e23c (patch)
tree58f103b4a5c3e00823b531692cc4421a176dacdd /src/verb/verb.rs
parent2cae879e39eee7f9caa3c0546a1114bc5ddf4c02 (diff)
:rename verb (and what makes it possible)
new auto_exec verb argument new standard verb arguments: file-name, file-stem, file-extension and file-dot-extension
Diffstat (limited to 'src/verb/verb.rs')
-rw-r--r--src/verb/verb.rs18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/verb/verb.rs b/src/verb/verb.rs
index e083691..9dfc09a 100644
--- a/src/verb/verb.rs
+++ b/src/verb/verb.rs
@@ -54,6 +54,10 @@ pub struct Verb {
/// whether we need to have a secondary panel for execution
/// (which is the case when the execution pattern has {other-panel-file})
pub needs_another_panel: bool,
+
+ /// if true (default) verbs are directly executed when
+ /// triggered with a keyboard shortcut
+ pub auto_exec: bool,
}
impl Verb {
@@ -68,18 +72,21 @@ impl Verb {
if let Some(ref invocation_parser) = invocation_parser {
names.push(invocation_parser.name().to_string());
}
- let (needs_selection, needs_another_panel) = match &execution {
+ let (
+ needs_selection,
+ needs_another_panel,
+ ) = match &execution {
VerbExecution::Internal(ie) => (
ie.needs_selection(),
false,
),
VerbExecution::External(ee) => (
ee.exec_pattern.has_selection_group(),
- ee.exec_pattern.has_other_panel_group()
+ ee.exec_pattern.has_other_panel_group(),
),
VerbExecution::Sequence(se) => (
se.sequence.has_selection_group(),
- se.sequence.has_other_panel_group()
+ se.sequence.has_other_panel_group(),
)
};
Ok(Self {
@@ -92,6 +99,7 @@ impl Verb {
selection_condition: SelectionType::Any,
needs_selection,
needs_another_panel,
+ auto_exec: true,
})
}
fn update_key_desc(&mut self) {
@@ -147,6 +155,10 @@ impl Verb {
self.needs_another_panel = true;
self
}
+ pub fn with_auto_exec(mut self, b: bool) -> Self {
+ self.auto_exec = b;
+ self
+ }
/// Assuming the verb has been matched, check whether the arguments
/// are OK according to the regex. Return none when there's no problem