11from ...actions .actions import ACTION_LIST_NAMES
2- from ..get_list import get_raw_list , make_dict_readable
2+ from ..get_list import ListItemDescriptor , get_raw_list , make_dict_readable
33
44
5- def get_actions ():
5+ def get_actions () -> list [ ListItemDescriptor ] :
66 all_actions = {}
77 for name in ACTION_LIST_NAMES :
88 all_actions .update (get_raw_list (name ))
@@ -28,111 +28,144 @@ def get_actions():
2828 if value in multiple_target_action_names
2929 }
3030
31- swap_connective = list (get_raw_list ("swap_connective" ).keys ())[0 ]
31+ swap_connectives = list (get_raw_list ("swap_connective" ).keys ())
32+ swap_connective = swap_connectives [0 ] if swap_connectives else None
3233
33- return [
34- * make_dict_readable (
35- "action" ,
36- simple_actions ,
37- {
38- "editNewLineAfter" : "Edit new line/scope after" ,
39- "editNewLineBefore" : "Edit new line/scope before" ,
40- },
41- ),
42- {
43- "id" : "replaceWithTarget" ,
44- "type" : "action" ,
45- "variations" : [
46- {
47- "spokenForm" : f"{ complex_actions ['replaceWithTarget' ]} <target> <destination>" ,
48- "description" : "Copy <target> to <destination>" ,
49- },
50- {
51- "spokenForm" : f"{ complex_actions ['replaceWithTarget' ]} <target>" ,
52- "description" : "Insert copy of <target> at cursor" ,
53- },
54- ],
55- },
56- {
57- "id" : "pasteFromClipboard" ,
58- "type" : "action" ,
59- "variations" : [
60- {
61- "spokenForm" : f"{ complex_actions ['pasteFromClipboard' ]} <destination>" ,
62- "description" : "Paste from clipboard at <destination>" ,
63- }
64- ],
65- },
66- {
67- "id" : "moveToTarget" ,
68- "type" : "action" ,
69- "variations" : [
70- {
71- "spokenForm" : f"{ complex_actions ['moveToTarget' ]} <target> <destination>" ,
72- "description" : "Move <target> to <destination>" ,
73- },
74- {
75- "spokenForm" : f"{ complex_actions ['moveToTarget' ]} <target>" ,
76- "description" : "Move <target> to cursor position" ,
77- },
78- ],
79- },
80- {
81- "id" : "swapTargets" ,
82- "type" : "action" ,
83- "variations" : [
84- {
85- "spokenForm" : f"{ complex_actions ['swapTargets' ]} <target 1> { swap_connective } <target 2>" ,
86- "description" : "Swap <target 1> with <target 2>" ,
87- },
88- {
89- "spokenForm" : f"{ complex_actions ['swapTargets' ]} { swap_connective } <target>" ,
90- "description" : "Swap selection with <target>" ,
91- },
92- ],
93- },
34+ items = make_dict_readable (
35+ "action" ,
36+ simple_actions ,
9437 {
95- "id" : "applyFormatter" ,
96- "type" : "action" ,
97- "variations" : [
98- {
99- "spokenForm" : f"{ complex_actions ['applyFormatter' ]} <formatter> at <target>" ,
100- "description" : "Reformat <target> as <formatter>" ,
101- }
102- ],
38+ "editNewLineAfter" : "Edit new line/scope after" ,
39+ "editNewLineBefore" : "Edit new line/scope before" ,
10340 },
104- {
105- "id" : "callAsFunction" ,
106- "type" : "action" ,
107- "variations" : [
108- {
109- "spokenForm" : f"{ complex_actions ['callAsFunction' ]} <target>" ,
110- "description" : "Call <target> on selection" ,
111- },
112- {
113- "spokenForm" : f"{ complex_actions ['callAsFunction' ]} <target 1> on <target 2>" ,
114- "description" : "Call <target 1> on <target 2>" ,
115- },
116- ],
117- },
118- {
119- "id" : "wrapWithPairedDelimiter" ,
120- "type" : "action" ,
121- "variations" : [
122- {
123- "spokenForm" : f"<pair> { complex_actions ['wrapWithPairedDelimiter' ]} <target>" ,
124- "description" : "Wrap <target> with <pair>" ,
125- }
126- ],
127- },
128- {
129- "id" : "rewrap" ,
130- "type" : "action" ,
131- "variations" : [
132- {
133- "spokenForm" : f"<pair> { complex_actions ['rewrap' ]} <target>" ,
134- "description" : "Rewrap <target> with <pair>" ,
135- }
136- ],
137- },
138- ]
41+ )
42+
43+ if "replaceWithTarget" in complex_actions :
44+ items .append (
45+ {
46+ "id" : "replaceWithTarget" ,
47+ "type" : "action" ,
48+ "variations" : [
49+ {
50+ "spokenForm" : f"{ complex_actions ['replaceWithTarget' ]} <target> <destination>" ,
51+ "description" : "Copy <target> to <destination>" ,
52+ },
53+ {
54+ "spokenForm" : f"{ complex_actions ['replaceWithTarget' ]} <target>" ,
55+ "description" : "Insert copy of <target> at cursor" ,
56+ },
57+ ],
58+ }
59+ )
60+
61+ if "pasteFromClipboard" in complex_actions :
62+ items .append (
63+ {
64+ "id" : "pasteFromClipboard" ,
65+ "type" : "action" ,
66+ "variations" : [
67+ {
68+ "spokenForm" : f"{ complex_actions ['pasteFromClipboard' ]} <destination>" ,
69+ "description" : "Paste from clipboard at <destination>" ,
70+ }
71+ ],
72+ }
73+ )
74+
75+ if "moveToTarget" in complex_actions :
76+ items .append (
77+ {
78+ "id" : "moveToTarget" ,
79+ "type" : "action" ,
80+ "variations" : [
81+ {
82+ "spokenForm" : f"{ complex_actions ['moveToTarget' ]} <target> <destination>" ,
83+ "description" : "Move <target> to <destination>" ,
84+ },
85+ {
86+ "spokenForm" : f"{ complex_actions ['moveToTarget' ]} <target>" ,
87+ "description" : "Move <target> to cursor position" ,
88+ },
89+ ],
90+ }
91+ )
92+
93+ if "swapTargets" in complex_actions and swap_connective :
94+ items .append (
95+ {
96+ "id" : "swapTargets" ,
97+ "type" : "action" ,
98+ "variations" : [
99+ {
100+ "spokenForm" : f"{ complex_actions ['swapTargets' ]} <target 1> { swap_connective } <target 2>" ,
101+ "description" : "Swap <target 1> with <target 2>" ,
102+ },
103+ {
104+ "spokenForm" : f"{ complex_actions ['swapTargets' ]} { swap_connective } <target>" ,
105+ "description" : "Swap selection with <target>" ,
106+ },
107+ ],
108+ }
109+ )
110+
111+ if "applyFormatter" in complex_actions :
112+ items .append (
113+ {
114+ "id" : "applyFormatter" ,
115+ "type" : "action" ,
116+ "variations" : [
117+ {
118+ "spokenForm" : f"{ complex_actions .get ('applyFormatter' )} <formatter> at <target>" ,
119+ "description" : "Reformat <target> as <formatter>" ,
120+ }
121+ ],
122+ }
123+ )
124+
125+ if "callAsFunction" in complex_actions :
126+ items .append (
127+ {
128+ "id" : "callAsFunction" ,
129+ "type" : "action" ,
130+ "variations" : [
131+ {
132+ "spokenForm" : f"{ complex_actions ['callAsFunction' ]} <target>" ,
133+ "description" : "Call <target> on selection" ,
134+ },
135+ {
136+ "spokenForm" : f"{ complex_actions ['callAsFunction' ]} <target 1> on <target 2>" ,
137+ "description" : "Call <target 1> on <target 2>" ,
138+ },
139+ ],
140+ }
141+ )
142+
143+ if "wrapWithPairedDelimiter" in complex_actions :
144+ items .append (
145+ {
146+ "id" : "wrapWithPairedDelimiter" ,
147+ "type" : "action" ,
148+ "variations" : [
149+ {
150+ "spokenForm" : f"<pair> { complex_actions ['wrapWithPairedDelimiter' ]} <target>" ,
151+ "description" : "Wrap <target> with <pair>" ,
152+ }
153+ ],
154+ }
155+ )
156+
157+ if "rewrap" in complex_actions :
158+ items .append (
159+ {
160+ "id" : "rewrap" ,
161+ "type" : "action" ,
162+ "variations" : [
163+ {
164+ "spokenForm" : f"<pair> { complex_actions ['rewrap' ]} <target>" ,
165+ "description" : "Rewrap <target> with <pair>" ,
166+ }
167+ ],
168+ }
169+ )
170+
171+ return items
0 commit comments