forked from chajadan/DragonflyRules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_docNav.py
42 lines (34 loc) · 1.07 KB
/
_docNav.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
from dragonfly import *
import Base
import inspect
from chajLib.ui import docnav
grammar = Base.ContinuousGrammar("text buffer manipulations grammar")
#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 CaretCalls(Base.QuickContinuousCalls):
mapping = [
["after left <RunOn>", docnav.caret_after_left, "target"],
["after right <RunOn>", docnav.caret_after_right, "target"],
["before left <RunOn>", docnav.caret_before_left, "target"],
["before right <RunOn>", docnav.caret_before_right, "target"],
]
@GrammarRule
class SelectCalls(Base.QuickContinuousCalls):
mapping = [
["select left through <RunOn>", docnav.select_through_left, "target"],
["select right through <RunOn>", docnav.select_through_right, "target"],
]
grammar.load()
def unload():
global grammar
if grammar:
grammar.unload()
grammar = None