-
Notifications
You must be signed in to change notification settings - Fork 30
/
_app_terminator.py
88 lines (72 loc) · 2.72 KB
/
_app_terminator.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
84
85
86
87
88
"""A command module for Dragonfly, for controlling the Terminator Linux application:
http://gnometerminator.blogspot.com/p/introduction.html
-----------------------------------------------------------------------------
Licensed under the LGPL3.
"""
from dragonfly import AppContext, Function, Grammar, IntegerRef, Key, MappingRule
import lib.config
config = lib.config.get_config()
if config.get("aenea.enabled", False) == True:
from aenea import Key # @Reimport
from aenea.proxy_contexts import ProxyAppContext as NixAppContext
rules = MappingRule(
mapping = {
# Miscellaneous.
"[start|exit] full screen": Key("f11"),
"search": Key("cs-f"),
"(toggle|show|hide) (scroll|scrollbar)": Key("cs-s"),
# Window management.
"new window": Key("cs-i"),
"close window": Key("cs-q"),
# Tab management.
"new tab": Key("cs-t"),
"close tab": Key("cs-w"),
"rename tab": Key("c-r"),
"[switch to] next tab": Key("c-pgdown"),
"[switch to] previous tab": Key("c-pgup"),
"move tab left": Key("cs-pgup"),
"move tab right": Key("cs-pgdown"),
# View management.
"split horizontally": Key("cs-o"),
"split vertically": Key("cs-e"),
"close view": Key("cs-w"),
"[switch to] next view": Key("c-tab"),
"[switch to] previous view": Key("cs-tab"),
"[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"),
"clear (view|tab|window|terminal)": Key("cs-g"),
"resize left [<n>]": Key("cs-left:%(n)d"),
"resize right [<n>]": Key("cs-right:%(n)d"),
"resize up [<n>]": Key("cs-up:%(n)d"),
"resize down [<n>]": Key("cs-down:%(n)d"),
# Zoom.
"(zoom|focus|unzoom|unfocus) (view|tab|terminal)": Key("cs-z"),
"zoom (100 percent|reset|normal)": Key("c-0"),
"zoom in": Key("c-plus"),
"zoom out": Key("c-minus"),
# Cursor grouping.
"group all": Key("w-g"),
"ungroup all": Key("ws-g"),
"group tab": Key("w-t"),
"ungroup tab": Key("ws-t"),
# Copy & paste.
"copy [that]": Key("cs-c"),
"paste [that]": Key("cs-v"),
},
extras=[
IntegerRef("n", 1, 100),
],
)
# This is a Linux-only application, so only enable the grammar if Aenea is enabled.
if config.get("aenea.enabled", False) == True:
context = NixAppContext(executable="python")
grammar = Grammar("Terminator general", context=context)
grammar.add_rule(rules)
grammar.load()
def unload():
global grammar
if grammar:
grammar.unload()
grammar = None