espanso/src/matcher/mod.rs

26 lines
547 B
Rust
Raw Normal View History

2019-08-30 19:24:03 +00:00
use std::sync::mpsc::Receiver;
pub(crate) mod scrolling;
2019-08-30 19:24:03 +00:00
pub struct Match {
pub trigger: String,
pub result: String
}
pub trait MatchReceiver {
fn on_match(&self, m: Match);
2019-08-30 19:24:03 +00:00
}
pub trait Matcher {
fn handle_char(&self, c: char);
fn watch(&self, receiver: &Receiver<char>) {
2019-08-30 19:24:03 +00:00
loop {
match receiver.recv() {
2019-08-30 19:24:03 +00:00
Ok(c) => {
self.handle_char(c);
2019-08-30 19:24:03 +00:00
},
Err(_) => panic!("Keyboard interceptor broke receiver stream."),
2019-08-30 19:24:03 +00:00
}
}
}
}