-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvs-code.py
65 lines (45 loc) · 1.76 KB
/
vs-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, press, Str
from user.utils import parse_words_as_integer
context = Context('VSCode', bundle='com.microsoft.VSCode')
def jump_to_line(m):
line_number = parse_words_as_integer(m._words[1:])
if line_number == None:
return
# Zeroth line should go to first line
if line_number == 0:
line_number = 1
# TODO: Directly interface with VSCode to accomplish the following
# Open the jump to line input
press('ctrl-g')
# TODO: If requesting line that is beyond the end of the focused document, jump to last line instead
# Enter whole line number data as if from keyboard
Str(str(line_number))(None)
# Confirm the navigation
press('enter')
# Position cursor at the beginning of meaningful text on the current line (Mac OS X)
press('cmd-right')
press('cmd-left')
def jump_to_next_word_instance(m):
press('escape')
press('cmd-f')
Str(' '.join([str(s) for s in m.dgndictation[0]._words]))(None)
press('escape')
context.keymap({
# Navigating text
'pizza (0 | oh | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9)+': jump_to_line,
'[toggle] terminal': Key('alt-f12'),
# # Selecting text
# 'select line': Key('cmd-right cmd-shift-left'),
# 'select start': Key('cmd-shift-left'),
# 'select end': Key('cmd-shift-right'),
# 'select word': Key('alt-shift-right'),
# 'select left word': Key('alt-shift-left'),
# 'select right': Key('shift-right'),
# 'select left': Key('shift-left'),
'select instances': Key('cmd-shift-l'),
'(top | go to top)': Key('cmd-up'),
# Finding text
'(previous | last)': Key('cmd-shift-g'),
'find next <dgndictation>': jump_to_next_word_instance,
'(dupe | duplicate)': Key('cmd-d'),
})