-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathACISketch.py
64 lines (57 loc) · 1.82 KB
/
ACISketch.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
print "importing " + __file__
from dragonfly import *
import Base
import inspect
import ctypes
import dfconfig
AciAware = ctypes.cdll.LoadLibrary(dfconfig.aciAwareDllPath);
grammar_context = AppContext(executable="ACISketch")
grammar = Base.GlobalGrammar("ACISketch", context=grammar_context)
# decorator
def GrammarRule(Rule):
if inspect.isclass(Rule):
if issubclass(Rule, Base.BaseQuickRules):
Rule(grammar)
else:
grammar.add_rule(Rule())
else:
grammar.add_rule(Rule)
def GoToFirstPage():
AciAware.GoToFirstPage()
@GrammarRule
class AddSingleLabel(Base.RegisteredRule):
spec = "label <RunOn>"
extras = (Dictation("RunOn"),)
def _process_recognition(self, node, extras):
AciAware.AciSketch_AddLabelAtMouseHover.argtypes = [ctypes.c_wchar_p]
words = extras["RunOn"].words
for i, word in enumerate(words):
words[i] = word.capitalize()
label = " ".join(words)
AciAware.AciSketch_AddLabelAtMouseHover(label)
@GrammarRule
class AddMultiLabel(Base.RegisteredRule):
spec = "multi label <RunOn>"
extras = (Dictation("RunOn"),)
def _process_recognition(self, node, extras):
AciAware.AciSketch_AddMultiLabelAtMouseHover.argtypes = [ctypes.c_wchar_p]
words = extras["RunOn"].words
for i, word in enumerate(words):
words[i] = word.capitalize()
label = " ".join(words)
AciAware.AciSketch_AddMultiLabelAtMouseHover(label)
@GrammarRule
class AciSketchRules(Base.QuickContinuousRules):
mapping = {
"show label font": Mouse("right") + Key("l/10, f/10"),
"show labels": Key("alt, v, l"),
}
extrasDict = {
}
defaultsDict = {
}
grammar.load()
def unload():
global grammar
if grammar: grammar.unload()
grammar = None