forked from dictation-toolbox/dragonfly-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_app_visual_studio_2010.py
56 lines (43 loc) · 1.65 KB
/
_app_visual_studio_2010.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
"""A command module for Dragonfly, for generic editing help.
-----------------------------------------------------------------------------
This is a heavily modified version of the _multiedit-en.py script at:
http://dragonfly-modules.googlecode.com/svn/trunk/command-modules/documentation/mod-_multiedit.html # @IgnorePep8
Licensed under the LGPL, see http://www.gnu.org/licenses/
"""
from dragonfly import * # @UnusedWildImport
class SeriesMappingRule(CompoundRule):
def __init__(self, mapping, extras=None, defaults=None):
mapping_rule = MappingRule(mapping=mapping, extras=extras,
defaults=defaults, exported=False)
single = RuleRef(rule=mapping_rule)
series = Repetition(single, min=1, max=16, name="series")
compound_spec = "<series>"
compound_extras = [series]
CompoundRule.__init__(self, spec=compound_spec,
extras=compound_extras, exported=True)
def _process_recognition(self, node, extras): # @UnusedVariable
series = extras["series"]
for action in series:
action.execute()
series_rule = SeriesMappingRule(
mapping={
"switch editor": Key("ca-pgup"), # Custom shortcut: 'Window.Windows'.
},
extras=[
IntegerRef("n", 1, 100),
Dictation("text"),
],
defaults={
"n": 1
}
)
context = AppContext(executable="devenv", title="microsoft visual studio")
grammar = Grammar("visual_studio_control", context=context)
grammar.add_rule(series_rule)
grammar.load()
def unload():
"""Unload function which will be called at unload time."""
global grammar
if grammar:
grammar.unload()
grammar = None