-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdevenv.py
56 lines (47 loc) · 1.64 KB
/
devenv.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
print "importing " + __file__
from dragonfly import *
import inspect
import Base
grammar_context = AppContext(executable="devenv")
grammar = Base.ContinuousGrammar("Visual Studio Community grammar", 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)
@GrammarRule
class ShortcutRules(Base.QuickContinuousRules):
mapping = {
"add new item": Key("cs-a"),
"build solution": Key("f7"),
"find all references": Mouse("left:1") + Key("apps, a:2, enter"),
"comment selection": Key("c-k, c-c"),
"uncomment selection": Key("c-k, 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("cs-space"),
"go to last project": Key("a-f, j, down, enter"),
"go to line <n>": Key("c-g") + Text("%(n)s") + Key("enter"),
}
extrasDict = {"n": IntegerRef("n", 1, 100000)}
defaultsDict = {"n": 1}
@GrammarRule
class PreprocessorRules(Base.QuickContinuousRules):
mapping = {
"pragma once": Text("#pragma once"),
}
grammar.load()
def unload():
global grammar
if grammar: grammar.unload()
grammar = None