-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathWDExpress.py
83 lines (70 loc) · 2.35 KB
/
WDExpress.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
print "importing " + __file__
from dragonfly import *
import inspect
import BaseGrammars
from BaseRules import *
grammar_context = AppContext(executable="WDExpress")
grammar = BaseGrammars.ContinuousGrammar("Visual Studio express grammar", grammar_context)
#decorator
def GrammarRule(rule):
if inspect.isclass(rule):
if issubclass(rule, (BaseQuickRules,)):
rule(grammar)
elif issubclass(rule, ContinuousGrammarRule):
grammar.add_rule(rule())
elif issubclass(rule, (Rule, MappingRule, CompoundRule)):
grammar.add_rule(rule())
else:
raise TypeError("Unexpected rule type added to grammar: " + str(inspect.getmro(rule)))
else:
grammar.add_rule(rule)
# @GrammarRule
# class RecentProjectsRule(ContinuousRule):
# spec = "recent projects"
# def _process_recognition(self, node, extras):
# Key("c-f, j").execute()
@GrammarRule
class ShortcutRules(QuickContinuousRules):
mapping = {
"add new item": Key("cs-a"),
"build solution": Key("f7"),
"find all references": Mouse("left:1") + Key("c-k, c-r"),
"comment selection": Key("c-e, c-c"),
"uncomment selection": Key("c-e, c-u"),
"go to definition": Key("f12"),
"go to declaration": Key("ca-f12"),
"toggle file": Key("c-k, c-o"), # swaps from cpp to h file, and vice versa
"recent projects": Key("a-f, j"),
"save all": Key("cs-s"),
"build this project only": Key("a-b, j, b"),
"rebuild this project only": Key("a-b, j, r"),
"clean this project only": Key("a-b, j, c"),
"parameter info": Key("c-k, c-p"),
"recent projects": Key("a-f, j"),
"go to last project": Key("a-f, j, down, enter"),
}
@GrammarRule
class PreprocessorRules(QuickContinuousRules):
mapping = {
"pragma once": Text("#pragma once"),
}
@GrammarRule
class RulesWithArguments(QuickContinuousRules):
mapping = {
"go to line <n>": Key("c-g") + Text("%(n)s") + Key("enter"),
}
extrasDict = {"n": IntegerRef("n", 1, 100000)}
defaultsDict = {"n": 1}
@GrammarRule
class ContextSpecificRules(QuickContinuousRules):
extrasDict = {
}
defaultsDict = {
}
mapping = {
}
grammar.load()
def unload():
global grammar
if grammar: grammar.unload()
grammar = None