-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_simple.py
46 lines (37 loc) · 1.17 KB
/
_simple.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
# Simple commands that should always be working
import time
mod_init_time = time.time()
print 'loading _simple module'
def timing_stats(msg):
print '%s:'%msg, (time.time() - mod_init_time)
#import pkg_resources
import natlink
import natlinkmain
from dragonfly import (Grammar, MappingRule, Config, Section, Item, Key)
#---------------------------------------------------------------------------
release = Key("shift:up, ctrl:up")
def T(s, pause=0.0002, **kws):
return Text(s, pause=pause, **kws)
def K(*args, **kws):
return Key(*args, **kws)
class CharRule(MappingRule):
mapping = {
"slap": Key("enter")
, "chook": Key("backspace")
, "quit": Key("escape")
, "save": release + Key("c-s")
, "paste": release + Key("c-v")
, "copy": release + Key("c-c")
, "cut": release + Key("c-x")
, "select all": release + Key("c-a")
, "(undo | scratch)": release + Key("c-z")
, "redo": release + Key("c-y")
}
#---------------------------------------------------------------------------
grammar = Grammar("Simple")
grammar.add_rule(CharRule())
grammar.load()
def unload():
global grammar
if grammar: grammar.unload()
grammar = None