2019-08-31 14:07:45 +00:00
|
|
|
use crate::matcher::{Match, MatchReceiver};
|
|
|
|
use crate::keyboard::KeyboardSender;
|
2019-09-05 18:54:19 +00:00
|
|
|
use crate::config::Configs;
|
2019-08-31 14:07:45 +00:00
|
|
|
|
2019-09-05 15:20:52 +00:00
|
|
|
pub struct Engine<S> where S: KeyboardSender {
|
2019-09-05 18:54:19 +00:00
|
|
|
sender: S,
|
|
|
|
configs: Configs,
|
2019-08-31 14:07:45 +00:00
|
|
|
}
|
|
|
|
|
2019-09-05 15:20:52 +00:00
|
|
|
impl <S> Engine<S> where S: KeyboardSender{
|
2019-09-05 18:54:19 +00:00
|
|
|
pub fn new(sender: S, configs: Configs) -> Engine<S> where S: KeyboardSender {
|
|
|
|
Engine{sender, configs }
|
2019-08-31 14:07:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|