-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecutor.rs
More file actions
23 lines (20 loc) · 765 Bytes
/
Copy pathexecutor.rs
File metadata and controls
23 lines (20 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use crate::{ binding::BindingTable, gesture::GestureEvent, macros::MacroRegistry };
/// Consumes `GestureEvent`s and triggers macro plans via registry.
pub struct Executor<'a> {
pub bindings: &'a BindingTable,
pub registry: &'a MacroRegistry,
}
impl<'a> Executor<'a> {
pub fn new(bindings: &'a BindingTable, registry: &'a MacroRegistry) -> Self {
Self { bindings, registry }
}
/// Execute the macro bound to the gesture (if any). Returns `true` if a macro was run.
pub fn handle(&self, ge: &GestureEvent) -> bool {
if let Some(mid) = self.bindings.resolve(&ge.key, &ge.gesture) {
if let Some(plan) = self.registry.get(mid) {
return plan.execute();
}
}
false
}
}