espanso/src/engine.rs

21 lines
583 B
Rust
Raw Normal View History

use crate::matcher::{Match, MatchReceiver};
use crate::keyboard::KeyboardSender;
2019-09-05 18:54:19 +00:00
use crate::config::Configs;
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-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-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());
}
}