summaryrefslogtreecommitdiffstats
path: root/src/verb/verb_store.rs
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2020-09-24 22:25:23 +0200
committerCanop <cano.petrole@gmail.com>2020-09-24 22:25:23 +0200
commit6c376ca883a70aa4b646ebcedfea6a87ac52b2d7 (patch)
tree6f92b01cb3d9abe37ac2254997a2ee4356c07616 /src/verb/verb_store.rs
parent60b742fceda175bd1b357280535b27ba5e915d94 (diff)
allow cmd sequences in verb execution
The syntax changed. Instead of `execution` (which is still allowed), `internal`, `external` and `cmd` are now prefered. The syntax of the `cmd` property is the same than the `--cmd` launch argument, with the added possibility to have dynamic parts. Two examples of sequence based verbs: [[verbs]] name = "myplaces" key = "ctrl-g" cmd = ":focus ~;:!focus /" [[verbs]] name = "backup" invocation = "bu {name}" cmd = ":cp {file}-back_{name};:!focus {file}-back_{name}" apply_to = "directory" Fix #277
Diffstat (limited to 'src/verb/verb_store.rs')
-rw-r--r--src/verb/verb_store.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/verb/verb_store.rs b/src/verb/verb_store.rs
index f736df3..73e86c1 100644
--- a/src/verb/verb_store.rs
+++ b/src/verb/verb_store.rs
@@ -50,11 +50,20 @@ impl VerbStore {
self.verbs.extend(builtin_verbs());
}
- pub fn search<'v>(&'v self, prefix: &str) -> PrefixSearchResult<'v, &Verb> {
+ pub fn search<'v>(
+ &'v self,
+ prefix: &str,
+ stype: Option<SelectionType>,
+ ) -> PrefixSearchResult<'v, &Verb> {
let mut found_index = 0;
let mut nb_found = 0;
let mut completions: Vec<&str> = Vec::new();
for (index, verb) in self.verbs.iter().enumerate() {
+ if let Some(stype) = stype {
+ if !stype.respects(verb.selection_condition) {
+ continue;
+ }
+ }
for name in &verb.names {
if name.starts_with(prefix) {
if name == prefix {