-
Notifications
You must be signed in to change notification settings - Fork 0
/
modes.py
67 lines (56 loc) · 2.53 KB
/
modes.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from talon import Context, Module, app, actions, speech_system
from talon.grammar import Phrase
from typing import Union
mod = Module()
modes = {
"admin": "enable extra administration commands terminal (docker, etc)",
"debug": "a way to force debugger commands to be loaded",
"gdb": "a way to force gdb commands to be loaded",
"ida": "a way to force ida commands to be loaded",
"presentation": "a more strict form of sleep where only a more strict wake up command works",
"windbg": "a way to force windbg commands to be loaded",
}
for key, value in modes.items():
mod.mode(key, value)
@mod.action_class
class Actions:
def talon_mode():
"""For windows and Mac with Dragon, enables Talon commands and Dragon's command mode."""
actions.speech.enable()
engine = speech_system.engine.name
# app.notify(engine)
if "dragon" in engine:
if app.platform == "mac":
actions.user.engine_sleep()
elif app.platform == "windows":
actions.user.engine_wake()
# note: this may not do anything for all versions of Dragon. Requires Pro.
actions.user.engine_mimic("switch to command mode")
def dragon_mode():
"""For windows and Mac with Dragon, disables Talon commands and exits Dragon's command mode"""
engine = speech_system.engine.name
# app.notify(engine)
if "dragon" in engine:
# app.notify("dragon mode")
actions.speech.disable()
if app.platform == "mac":
actions.user.engine_wake()
elif app.platform == "windows":
actions.user.engine_wake()
# note: this may not do anything for all versions of Dragon. Requires Pro.
actions.user.engine_mimic("start normal mode")
# Andreas Arvidsson sticky dictate mode
# -----------------------------------------------------------------------------------
def command_mode(phrase: Union[Phrase, str] = None):
"""Enter command mode and re-evaluate phrase"""
actions.mode.disable("dictation")
actions.mode.enable("command")
if phrase:
actions.user.rephrase(phrase, run_async=True)
def dictation_mode(phrase: Union[Phrase, str] = None):
"""Enter dictation mode and re-evaluate phrase"""
actions.user.dictation_format_reset()
actions.mode.disable("command")
actions.mode.enable("dictation")
if phrase:
actions.user.rephrase(phrase, run_async=True)