summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-01-17 17:05:29 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-01-17 17:05:45 +0100
commit50c4ab8defaac96174e9d5782b032091c6f37a36 (patch)
treee06739dde40e20e27f6e1144a32f1c58bba7b1ef
parentb47bcc4967097535b4b740c2e00c752498c3e39f (diff)
Make bindings able to handle multiple caller strings
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--src/bindings.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/bindings.rs b/src/bindings.rs
index 3b4587c..9907bdc 100644
--- a/src/bindings.rs
+++ b/src/bindings.rs
@@ -20,7 +20,7 @@ use crate::main_view::MainView;
pub fn get_bindings() -> Bindings {
Bindings(vec![
Binding {
- chars: vec!['q'],
+ chars: ["quit", "q"].iter().map(ToString::to_string).collect(),
callback: Callback::from_fn(|siv: &mut Cursive| {
trace!("Callback called: q");
let continue_running = siv.call_on_name(crate::main_view::MAIN_VIEW_NAME, |mv: &mut MainView| {
@@ -49,7 +49,7 @@ pub fn get_bindings() -> Bindings {
},
Binding {
- chars: vec!['o'],
+ chars: ["open", "o"].iter().map(ToString::to_string).collect(),
callback: Callback::from_fn(MainView::add_notmuch_query_layer),
}
])
@@ -72,12 +72,12 @@ impl Bindings {
#[derive(Clone)]
pub struct Binding {
- chars: Vec<char>,
+ chars: Vec<String>,
callback: Callback,
}
impl Binding {
- pub fn for_events(chars: Vec<char>, callback: Callback) -> Binding {
+ pub fn for_events(chars: Vec<String>, callback: Callback) -> Binding {
Binding { chars, callback }
}
}
@@ -103,7 +103,8 @@ impl BindingCaller {
.iter()
.find(|binding| {
trace!("chars {:?} == state {:?}", binding.chars, self.state);
- binding.chars == self.state
+ let state_str = self.state.iter().collect::<String>();
+ binding.chars.iter().any(|state| *state == state_str)
})
.map(|binding| {
trace!("Binding found");