espanso/src/engine.rs

19 lines
455 B
Rust
Raw Normal View History

use crate::matcher::{Match, MatchReceiver};
use crate::keyboard::KeyboardSender;
pub struct Engine<'a>{
2019-09-01 18:46:46 +00:00
sender: &'a dyn KeyboardSender
}
impl <'a> Engine<'a> {
2019-09-01 18:46:46 +00:00
pub fn new(sender: &'a dyn KeyboardSender) -> Engine<'a> {
Engine{sender}
}
}
impl <'a> MatchReceiver for Engine<'a>{
2019-08-31 15:00:23 +00:00
fn on_match(&self, m: &Match) {
self.sender.delete_string(m.trigger.len() as i32);
self.sender.send_string(m.result.as_str());
}
}