-
Notifications
You must be signed in to change notification settings - Fork 30
/
_app_console_z.py
75 lines (63 loc) · 1.99 KB
/
_app_console_z.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
"""A command module for Dragonfly, for controlling ConsoleZ.
-----------------------------------------------------------------------------
Licensed under the LGPL3.
"""
from dragonfly import (
MappingRule,
AppContext,
IntegerRef,
Grammar,
Key, # @UnusedImport
)
rules = MappingRule (
mapping = {
# Miscellaneous.
"open settings": Key("c-s"),
"[start|exit] full screen": Key("f11"),
# Tab management.
"[open] new tab": Key("c-f1"),
"close tab": Key("c-w"),
"rename tab": Key("c-r"),
"[switch to] new tab": Key("c-tab"),
"[switch to] previous tab": Key("cs-tab"),
"(switch to|go to) tab <n>": Key("c-%(n)d"),
# View management.
"split horizontally": Key("cs-o"),
"split vertically": Key("cs-e"),
"close view": Key("cs-w"),
"[switch to] next view": Key("c-pgdown"),
"[switch to] previous view": Key("c-pgup"),
"[switch to] left view": Key("a-left"),
"[switch to] right view": Key("a-right"),
"[switch to] top view": Key("a-up"),
"[switch to] bottom view": Key("a-down"),
# Zoom.
"zoom 100 percent": Key("c-np0"),
"zoom in": Key("c-npadd"),
"zoom out": Key("c-npsub"),
# Cursor grouping.
"group all": Key("c-g"),
"ungroup all": Key("cs-g"),
"group tab": Key("c-t"),
"ungroup tab": Key("cs-t"),
# Copy & paste.
"select all": Key("c-a"),
"clear selection": Key("c-del"),
#"copy (selection|that)": Key("c-insert"),
#"paste (that)": Key("s-insert"),
"dump screen buffer": Key("cs-f1"),
},
extras=[
IntegerRef("n", 1, 100),
],
)
context = AppContext(executable="console")
grammar = Grammar("ConsoleZ", context=context)
grammar.add_rule(rules)
grammar.load()
def unload():
"""Unload function which will be called at unload time."""
global grammar
if grammar:
grammar.unload()
grammar = None