2019-08-31 14:07:45 +00:00
|
|
|
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-08-31 14:07:45 +00:00
|
|
|
}
|
|
|
|
|
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 {
|
2019-08-31 14:07:45 +00:00
|
|
|
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) {
|
2019-08-31 14:07:45 +00:00
|
|
|
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());
|
2019-08-31 14:07:45 +00:00
|
|
|
}
|
|
|
|
}
|