1
- from talon import Module , actions
1
+ from talon import Context , Module , actions
2
2
3
3
mod = Module ()
4
4
7
7
"Application supporting cursorless commands" ,
8
8
)
9
9
10
+ global_ctx = Context ()
11
+
12
+ cursorless_ctx = Context ()
13
+ cursorless_ctx .matches = r"""
14
+ tag: user.cursorless
15
+ """
16
+
10
17
11
18
@mod .action_class
12
19
class Actions :
@@ -16,8 +23,67 @@ def private_cursorless_show_settings_in_ide():
16
23
def private_cursorless_show_sidebar ():
17
24
"""Show Cursorless-specific settings in ide"""
18
25
26
+ def private_cursorless_notify_docs_opened ():
27
+ """Notify the ide that the docs were opened in case the tutorial is waiting for that event"""
28
+ ...
29
+
19
30
def private_cursorless_show_command_statistics ():
20
31
"""Show Cursorless command statistics"""
21
32
actions .user .private_cursorless_run_rpc_command_no_wait (
22
33
"cursorless.analyzeCommandHistory"
23
34
)
35
+
36
+ def private_cursorless_start_tutorial ():
37
+ """Start the introductory Cursorless tutorial"""
38
+ actions .user .private_cursorless_run_rpc_command_no_wait (
39
+ "cursorless.tutorial.start" , "unit-1-basics"
40
+ )
41
+
42
+ def private_cursorless_tutorial_next ():
43
+ """Cursorless tutorial: next"""
44
+ actions .user .private_cursorless_run_rpc_command_no_wait (
45
+ "cursorless.tutorial.next"
46
+ )
47
+
48
+ def private_cursorless_tutorial_previous ():
49
+ """Cursorless tutorial: previous"""
50
+ actions .user .private_cursorless_run_rpc_command_no_wait (
51
+ "cursorless.tutorial.previous"
52
+ )
53
+
54
+ def private_cursorless_tutorial_restart ():
55
+ """Cursorless tutorial: restart"""
56
+ actions .user .private_cursorless_run_rpc_command_no_wait (
57
+ "cursorless.tutorial.restart"
58
+ )
59
+
60
+ def private_cursorless_tutorial_resume ():
61
+ """Cursorless tutorial: resume"""
62
+ actions .user .private_cursorless_run_rpc_command_no_wait (
63
+ "cursorless.tutorial.resume"
64
+ )
65
+
66
+ def private_cursorless_tutorial_list ():
67
+ """Cursorless tutorial: list all available tutorials"""
68
+ actions .user .private_cursorless_run_rpc_command_no_wait (
69
+ "cursorless.tutorial.list"
70
+ )
71
+
72
+ def private_cursorless_tutorial_start_by_number (number : int ): # pyright: ignore [reportGeneralTypeIssues]
73
+ """Start Cursorless tutorial by number"""
74
+ actions .user .private_cursorless_run_rpc_command_no_wait (
75
+ "cursorless.tutorial.start" , number - 1
76
+ )
77
+
78
+
79
+ @global_ctx .action_class ("user" )
80
+ class GlobalActions :
81
+ def private_cursorless_notify_docs_opened ():
82
+ # Do nothing if we're not in a Cursorless context
83
+ pass
84
+
85
+
86
+ @cursorless_ctx .action_class ("user" )
87
+ class CursorlessActions :
88
+ def private_cursorless_notify_docs_opened ():
89
+ actions .user .private_cursorless_run_rpc_command_no_wait ("cursorless.docsOpened" )
0 commit comments