-
Notifications
You must be signed in to change notification settings - Fork 3
/
code.py
65 lines (52 loc) · 1.71 KB
/
code.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
from talon.voice import Context, Key
languages = ['.php', '.py', '.java', '.yml', '.json']
bundles = ['com.postmanlabs.mac']
ctx = Context('code', func=lambda app, win:
any(app.bundle == b for b in bundles)
or any(win.doc.endswith(l) for l in languages)
)
keymap = {
'sinker': [Key('cmd-right ;')],
'args': ['()', Key('left')],
'angler': ['<>', Key('left')],
'(block | kirblock)': ['{}', Key('left enter')],
'args-block': ['(', Key('enter')],
'brax-block': ['[', Key('enter')],
'coalshock': [':', Key('enter')],
'coal twice': '::',
'ellipsis': '...',
'mintwice': '--',
'plustwice': '++',
'(indirect | reference)': '&',
'([is] equal to | longqual)': ' == ',
'([is] not equal to | banquall)': ' != ',
'trickle': ' === ',
'(ranqual | nockle)': ' !== ',
'(call | prekris)': '()',
'(index | brax)': ['[]', Key('left')],
'(empty dict | kirk)': ['{}', Key('left')],
'(empty array | brackers)': '[]',
'empty dict': '{}',
'minquall': '-=',
'pluqual': '+=',
'starqual': '*=',
'lessqual': ' <= ',
'grayqual': ' >= ',
'(arrow | lambo)': '->',
'shrocket': ' => ',
'state if': ['if ()', Key('left')],
'state else': ['else {}', Key('left enter')],
'state else if': ['else if ()', Key('left')],
'state while': ['while ()', Key('left')],
'state for': ['for ()', Key('left')],
'state for each': ['foreach ()', Key('left')],
'state switch': ['switch ()', Key('left')],
'const': 'const ',
'static': 'static ',
'tip pent': 'int ',
'word no': 'null',
'word printf': 'printf',
'word define': 'def ',
'word import': 'import ',
}
ctx.keymap(keymap)