/
journal.py
68 lines (55 loc) · 1.46 KB
/
journal.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
from talon.voice import Key, press, Str, Context, Rule, ContextGroup
from .talon_community.utils import (
parse_words_as_integer,
parse_words,
numeral_map,
numerals,
optional_numerals,
text,
m_to_number,
)
import datetime
from .talon_community.misc.speech_toggle import journal
# context = Context('journal')#, group=ContextGroup('dictation'))#, func=lambda app, win: win.doc.endswith('.md'))
atom_hotkey = "cmd-shift-ctrl-alt-t"
def new_entry(m):
press('cmd-down') # Go to end of first line of the file
press('return')
press('return')
press('return')
# Return to just after the date entry
press('up')
Str('# ')(None)
Str(datetime.date.today().isoformat())(None) # Add the current date
# Create spacing from any previous entries
press('return')
# Enter start of new list item
Str('* ')(None)
def new_to_do(m):
press('return')
Str('- [ ] ')(None)
def execute_atom_command(command, parameters=None):
press(atom_hotkey)
press(command)
if parameters:
Str(parameters)(None)
press("enter")
def get_first_word(m):
return str(m.dgndictation[0]._words[0])
def mark_as_done(m):
Key("cmd-left")
Key("right")
Key("right")
Key("right")
Key("right")
Key("delete")
Key("x")
def bullet(m):
press('return')
Str('* ')(None)
journal.keymap({
'new log': new_entry,
'to do new': new_to_do,
'bullet': bullet,
'to do done': mark_as_done,
})