espanso/src/engine.rs

19 lines
504 B
Rust
Raw Normal View History

use crate::matcher::{Match, MatchReceiver};
use crate::keyboard::KeyboardSender;
2019-09-05 15:20:52 +00:00
pub struct Engine<S> where S: KeyboardSender {
sender: S
}
2019-09-05 15:20:52 +00:00
impl <S> Engine<S> where S: KeyboardSender{
pub fn new(sender: S) -> Engine<S> where S: KeyboardSender {
Engine{sender}
}
}
2019-09-05 15:20:52 +00:00
impl <S> MatchReceiver for Engine<S> where S: KeyboardSender{
2019-08-31 15:00:23 +00:00
fn on_match(&self, m: &Match) {
self.sender.delete_string(m.trigger.len() as i32);
2019-09-01 20:00:31 +00:00
self.sender.send_string(m.replace.as_str());
}
}