aboutsummaryrefslogtreecommitdiffstats
path: root/src/parser.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser.rs')
-rw-r--r--src/parser.rs37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/parser.rs b/src/parser.rs
index 9e11175..daea8fc 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -65,13 +65,35 @@ impl KeyCode {
}
#[derive(Debug, PartialEq)]
-enum KeyboardKey {
+pub enum KeyboardKey {
Character(Character),
KeyCode(KeyCode),
}
+impl KeyboardKey {
+ // fn map<K, F>(&self, f: F) -> &Self
+ // where
+ // K: KeyCodeConvertible,
+ // F: Fn(K),
+ // {
+ // match self {
+ // KeyboardKey::Character(c) => f(c.0),
+ // KeyboardKey::KeyCode(k) => f(k.0),
+ // }
+ //
+ // self
+ // }
+
+ // pub fn extract<K: KeyCodeConvertible + Copy>(&self) -> Box<K> {
+ // return match self {
+ // KeyboardKey::Character(c) => Box::new(c.0),
+ // KeyboardKey::KeyCode(k) => Box::new(k.0),
+ // }
+ // }
+}
+
#[derive(Debug, PartialEq)]
-struct KeyboardKeyWithModifiers {
+pub struct KeyboardKeyWithModifiers {
key: KeyboardKey,
flags: Vec<Flag>,
}
@@ -83,6 +105,17 @@ impl KeyboardKeyWithModifiers {
flags: modifiers,
}
}
+
+ pub fn tap(&self) {
+ match self.key {
+ KeyboardKey::Character(ref c) => {
+ autopilot::key::tap(c.0, &self.flags, 0)
+ },
+ KeyboardKey::KeyCode(ref k) => {
+ autopilot::key::tap(k.0, &self.flags, 0)
+ },
+ }
+ }
}
#[derive(Debug, PartialEq)]