-
Notifications
You must be signed in to change notification settings - Fork 0
/
macro_utilities.py
38 lines (22 loc) · 929 Bytes
/
macro_utilities.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from dragonfly.engines.backend_natlink.dictation import (NatlinkDictationContainer)
from dragonfly import (Key, Text, Choice)
def sleep_exit(sleep):
return Key("escape/%d" % sleep)
def replace_percentage(sleep):
return sleep_exit(sleep) + Text("F%%s")
def replace_in_text(text, character="$", sleep=1):
return Text(text) + sleep_exit(sleep) + Text("F%ss" % character)
comment_choice_map = {
"to do": "@TODO:",
"worn": "@WARN:",
"research": "@RESEARCH:",
"note": "@NOTE:",
}
def comment_choice(name="comment_type"):
return Choice(name, comment_choice_map)
def with_dictation(value, on_dictation, on_other):
return on_dictation(value) if is_dictation(value) else on_other(value)
def execute_with_dictation(value, on_dictation, on_other):
with_dictation(value, on_dictation, on_other).execute()
def is_dictation(value):
return isinstance(value, NatlinkDictationContainer)