-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_vimium.py
58 lines (50 loc) · 1.45 KB
/
_vimium.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
from dragonfly import (Grammar, AppContext, MappingRule, Dictation, IntegerRef,
Key, Text)
import lib.combination
grammar = Grammar("vimium")
window_rule = MappingRule(
name = "window",
mapping = {
# Tab navigation
'browse back': Key("cs-tab"),
'browse next': Key("c-tab"),
'browse <n>': Key("c-%(n)d"),
'browse new': Key("c-t"),
'revive': Key("cs-t"),
'gash <n>': Key("c-tab,c-w:%(n)"),
'gash': Key("c-w"),
'refresh': Key("c-r"),
'address': Key("c-l"),
# Moving around
'slump more': Key("c-d"),
'slump most': Key("pgdown"),
'boost more': Key("c-u"),
'boost most': Key("pgup"),
'top': Key("escape, g, g"),
'bottom': Key("escape, s-g"),
'(passed | past)': Key("a-left"),
'future': Key("a-right"),
# Searching
'braille <text>': Key("escape, slash") + Text("%(text)s") + Key("enter"),
'<n> Noah': Key("%(n)d, n"),
'[<n>] rev': Key("%(n)d, N"),
# page actions
'scope': Key('f'),
'scoping': Key('escape, f'),
'show page atoms': Key("g,s"),
},
extras = [
IntegerRef('n', 1, 99),
Dictation('text'),
],
defaults = {
"n": 1
}
)
grammar.add_rule(window_rule)
grammar.load()
# Unload function which will be called by natlink at unload time.
def unload():
global grammar
if grammar: grammar.unload()
grammar = None