use crate::services::hotkey::Hotkey;
use crate::services::hotkey::HotkeyScope;
pub trait HasHotkeys {
fn hotkeys(&self) -> Vec<Hotkey>;
fn hotkeys_for_scope(&self, scope: &HotkeyScope) -> Vec<Hotkey> {
self.hotkeys()
.into_iter()
.filter(|h| match scope {
HotkeyScope::Global => matches!(h.scope, HotkeyScope::Global),
HotkeyScope::Modal(m) => {
matches!(&h.scope, HotkeyScope::Modal(s) if *s == *m)
}
HotkeyScope::Tab(t) => matches!(&h.scope, HotkeyScope::Tab(s) if *s == *t),
HotkeyScope::Custom(c) => {
matches!(&h.scope, HotkeyScope::Custom(s) if *s == *c)
}
})
.collect()
}
}