-
Notifications
You must be signed in to change notification settings - Fork 0
/
global.py
115 lines (94 loc) · 3.37 KB
/
global.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
from Dragon import *
script = Script("global.dvc")
script.append(List("lowercase", List.lowercase))
script.append(List("alnum", List.alnum))
script.append(List("digit", List.digits))
script.append(List("1-20", [str(i) for i in range(1, 21)]))
script.append(List("character", List.alnum + "/"))
heard = { "open commands" : "open command browser",
"open words" : "open vocabulary editor",
"firefox" : "switch to Firefox"
}
for (k,v) in heard.items():
script.append(Command(k, HeardWord(v)))
cmd = { Key("enter") : "enter",
Key("escape") : "escape",
Key("tab") : "tab",
Key("backspace") : "backspace",
", " : "comma space" }
key = { Key.enter : "enter",
Key.escape : "escape",
Key.tab : "tab",
Key.delete : "delete",
Key.space : "space",
Key.right : "right",
Key.left : "left",
Key.up : "up",
Key.down : "down",
Key.delete : "delete",
Key.backspace : "backspace"
}
symbols = { "." : "dot",
"." : "point",
"^" : "caret",
"/" : "slash",
"$" : "dollar",
"%" : "percent",
"*" : "star",
"&" : "ampersand",
"\\" : "backslash",
"#" : "pound",
"," : "comma",
"-" : "hyphen",
"_" : "underscore",
#"~": "tilde"
}
script.append(List("special-symbol", symbols.values()))
script.append(Command("<special-symbol>",
Var("cmd", Argument(0)),
Transform(Var("cmd"), symbols),
Var("cmd"),
HeardWord("\No-Caps"),
HeardWord("\No-Space")
))
script.append(Command("<special-symbol> <special-symbol>",
Var("s1", Argument(0)),
Var("s2", Argument(1)),
Transform(Var("s1"), symbols),
Transform(Var("s2"), symbols),
[Var("s1"), Var("s2")],
HeardWord("\No-Caps"),
HeardWord("\No-Space")
))
# script.append(Command("<special-symbol> <alnum>",
# Var("cmd", Argument(0)),
# Transform(Var("cmd"), symbols),
# [Var("cmd"), Argument(1)]))
# script.append(Command("<alnum> <special-symbol>",
# Var("cmd", Argument(1)),
# Transform(Var("cmd"), symbols),
# [Argument(0), Var("cmd")]))
script.append(Command("brakets <alnum>", [ "[", Argument(0), "]"]))
script.append(Command("braces <alnum>", [ "{{", Argument(0), "}}"]))
script.append(Command("parens <alnum>", [ "(", Argument(0), ")"]))
script.append(Command("quotes <alnum>", [ "'", Argument(0), "'"]))
script.append(List("number", ["number", "num", "choose"]))
script.append(Command("<number> <digit>", [Argument(1)]))
script.append(Command("<number> <digit> <digit>",
[Argument(1), Argument(2)]))
script.append(Command("<number> <digit> <digit> <digit>",
[Argument(1), Argument(2), Argument(3)]))
script.append(List("alt", [ "alt", "meta" ]))
script.append(Command("<alt> tab", Key.Alt("Tab")))
script.append(Command("<alt> <character>", Key.Alt(Argument(1)) ))
script.append(Command("control <lowercase>",
Key.Ctrl(Argument(0)), HeardWord("\No-Caps") ))
script.append(List("key", key.values()))
script.append(Command("<key> <1-20>", Loop(0, Argument(1), ["{", Argument(0), "}"])))
script.append(Command("<1-20> <key>", Loop(0, Argument(0), ["{", Argument(1), "}"])))
script.append(List("global-cmd", [v or k for (k,v) in cmd.items()]))
script.append(Command("<global-cmd>",
Var("cmd", Argument(0)),
Transform(Var("cmd"), cmd), Var("cmd")))
script.append(Command("cap <lowercase>", Function.UCase(Argument(0))))
print script