1
- import json
2
- from .json import to_json
3
1
from enum import Enum , unique
4
- from abc import ABCMeta , abstractmethod
2
+ from typing import Literal
5
3
6
4
7
5
class ActionDefaultArguments :
@@ -13,13 +11,15 @@ class ScanDirection(str, Enum):
13
11
forward = "forward"
14
12
backward = "backward"
15
13
14
+
16
15
class Action :
17
16
"""
18
17
全てのActionの継承元となるクラス。
19
18
metaclassによって、自動的に割り当てられる。
20
19
"""
21
20
pass
22
21
22
+
23
23
class ActionMeta (type ):
24
24
"""
25
25
全てのActionのメタクラス。
@@ -32,8 +32,10 @@ def __new__(meta, name, bases, attributes):
32
32
raise TypeError ("Action has no type!" )
33
33
return type .__new__ (meta , name , bases , attributes )
34
34
35
+
35
36
class InputAction (metaclass = ActionMeta ):
36
37
type = "input"
38
+
37
39
def __init__ (self , text : str ):
38
40
"""
39
41
文字を入力するアクション
@@ -44,8 +46,10 @@ def __init__(self, text: str):
44
46
"""
45
47
self .text = text
46
48
49
+
47
50
class ReplaceLastCharactersAction (metaclass = ActionMeta ):
48
51
type = "replace_last_characters"
52
+
49
53
def __init__ (self , table : dict [str , str ]):
50
54
"""
51
55
最後の文字を置換するアクション
@@ -56,19 +60,23 @@ def __init__(self, table: dict[str, str]):
56
60
"""
57
61
self .table = table
58
62
63
+
59
64
class ReplaceDefaultAction (metaclass = ActionMeta ):
60
65
"""
61
66
azooKeyデフォルトの置換アクション
62
67
"""
63
68
type = "replace_default"
64
69
70
+
65
71
@unique
66
72
class TabType (str , Enum ):
67
73
system = "system"
68
74
custom = "custom"
69
75
76
+
70
77
class MoveTabAction (metaclass = ActionMeta ):
71
78
type = "move_tab"
79
+
72
80
def __init__ (self , tab_type : TabType , text : str ):
73
81
"""
74
82
タブを移動するアクション
@@ -82,8 +90,10 @@ def __init__(self, tab_type: TabType, text: str):
82
90
self .tab_type = tab_type
83
91
self .identifier = text
84
92
93
+
85
94
class MoveCursorAction (metaclass = ActionMeta ):
86
95
type = "move_cursor"
96
+
87
97
def __init__ (self , count : int ):
88
98
"""
89
99
カーソルを移動するアクション
@@ -94,8 +104,10 @@ def __init__(self, count: int):
94
104
"""
95
105
self .count = count
96
106
107
+
97
108
class SmartMoveCursorAction (metaclass = ActionMeta ):
98
109
type = "smart_move_cursor"
110
+
99
111
def __init__ (self , direction : ScanDirection , targets : list [str ]):
100
112
"""
101
113
指定した文字の隣までカーソルを移動するアクション
@@ -109,8 +121,28 @@ def __init__(self, direction: ScanDirection, targets: list[str]):
109
121
self .direction = direction
110
122
self .targets = targets
111
123
124
+
125
+ class LaunchApplicationAction (metaclass = ActionMeta ):
126
+ type = "launch_application"
127
+
128
+ def __init__ (self , scheme_type : Literal ['azooKey' , 'shortcuts' ], target : str ):
129
+ """
130
+ アプリケーションを起動するアクション。
131
+ schemeとしてazooKeyを選んだ場合、'azooKey://' + targetを開く。
132
+ schemeとしてshortcutsを選んだ場合、'shortcuts://' + targetを開く。
133
+ target = run-shortcut?name=<ショートカット名>とすることで、任意のショートカットを開くことができる。
134
+ Parameters
135
+ ----------
136
+ scheme_type: Literal['azooKey', 'shortcuts']
137
+ target: str
138
+ """
139
+ self .scheme_type = scheme_type
140
+ self .target = target
141
+
142
+
112
143
class DeleteAction (metaclass = ActionMeta ):
113
144
type = "delete"
145
+
114
146
def __init__ (self , count : int ):
115
147
"""
116
148
文字を削除するアクション
@@ -121,8 +153,10 @@ def __init__(self, count: int):
121
153
"""
122
154
self .count = count
123
155
156
+
124
157
class SmartDeleteAction (metaclass = ActionMeta ):
125
158
type = "smart_delete"
159
+
126
160
def __init__ (self , direction : ScanDirection , targets : list [str ]):
127
161
"""
128
162
指定した文字の隣まで文字を削除するアクション
@@ -136,42 +170,49 @@ def __init__(self, direction: ScanDirection, targets: list[str]):
136
170
self .direction = direction
137
171
self .targets = targets
138
172
173
+
139
174
class SmartDeleteDefaultAction (metaclass = ActionMeta ):
140
175
"""
141
176
azooKeyデフォルトの文頭まで削除アクション
142
177
"""
143
178
type = "smart_delete_default"
144
179
180
+
145
181
class EnableResizingModeAction (metaclass = ActionMeta ):
146
182
"""
147
183
片手モードの調整を始めるアクション
148
184
"""
149
185
type = "enable_resizing_mode"
150
186
187
+
151
188
class ToggleCursorBarAction (metaclass = ActionMeta ):
152
189
"""
153
190
カーソルバーの表示状態をtoggleするアクション
154
191
"""
155
192
type = "toggle_cursor_bar"
156
193
194
+
157
195
class ToggleTabBarAction (metaclass = ActionMeta ):
158
196
"""
159
197
タブバーの表示状態をtoggleするアクション
160
198
"""
161
199
type = "toggle_tab_bar"
162
200
201
+
163
202
class ToggleCapsLockStateAction (metaclass = ActionMeta ):
164
203
"""
165
204
Caps lockの状態をtoggleするアクション
166
205
"""
167
206
type = "toggle_caps_lock_state"
168
207
208
+
169
209
class DismissKeyboardAction (metaclass = ActionMeta ):
170
210
"""
171
211
キーボードを閉じるアクション
172
212
"""
173
213
type = "dismiss_keyboard"
174
214
215
+
175
216
class LongpressAction (object ):
176
217
def __init__ (self , start : list [Action ] = [], repeat : list [Action ] = []):
177
218
"""
0 commit comments