Skip to content

Commit d060c59

Browse files
authored
Merge pull request #46 from ensan-hcl/release/1.1
Release 1.1
2 parents ecdb09d + f753ee2 commit d060c59

File tree

10 files changed

+173
-63
lines changed

10 files changed

+173
-63
lines changed

json/howToMake.md

+2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
| normal | 通常の入力キーの色です。 |
6868
| special | タブ移動キーや削除キーの色です。 |
6969
| selected | 選択中のタブや押されているキーの色です。 |
70+
| unimportant | 重要度の低いキーの色です。 |
7071

7172
### アクション
7273

@@ -101,6 +102,7 @@ azooKeyでは`"input"`の他にいくつかの動作を行うことができま
101102
| toggle_tab_bar | なし | タブバーの表示をtoggleします。 |
102103
| toggle_caps_lock_state | なし | caps lockをtoggleします。 |
103104
| dismiss_keyboard | なし | キーボードを閉じます。 |
105+
| launch_application | scheme_type: str<br />target: str | scheme_typeで指定されたアプリケーションをscheme://(target)として開きます。scheme_typeには`"azooKey"``"shortcuts"`のみを指定できます。 |
104106

105107
続く`"longpress_actions"`はほぼ`"press_actions"`と同じです。
106108

python/README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
## 環境
1+
# 環境
22

33
Python3.9以上。
4+
5+
# テスト
6+
7+
```bash
8+
python3 -m unittest
9+
```

python/howToMake.md

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ design = KeyDesign(
5757
| normal | 通常の入力キーの色です。 |
5858
| special | タブ移動キーや削除キーの色です。 |
5959
| selected | 選択中のタブや押されているキーの色です。 |
60+
| unimportant | 重要度の低いキーの色です。 |
6061

6162
### アクション
6263

@@ -90,6 +91,7 @@ azooKeyでは`InputAction`の他にいくつかの動作を行うことができ
9091
| ToggleTabBarAction | なし | タブバーの表示をtoggleします。 |
9192
| ToggleCapsLockStateAction | なし | caps lockをtoggleします。 |
9293
| DismissKeyboardAction | なし | キーボードを閉じます。 |
94+
| LaunchApplicationAction | scheme_type: Literal['azooKey', 'shortcuts']<br />target: str | scheme_typeで指定されたアプリケーションをscheme://(target)として開きます。scheme_typeには`"azooKey"``"shortcuts"`のみを指定できます。 |
9395

9496
続く引数の`longpress_actions``LongpressAction`というオブジェクトで、ほぼ`press_actions`と同じです。
9597

python/source/actions.py

+44-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import json
2-
from .json import to_json
31
from enum import Enum, unique
4-
from abc import ABCMeta, abstractmethod
2+
from typing import Literal
53

64

75
class ActionDefaultArguments:
@@ -13,13 +11,15 @@ class ScanDirection(str, Enum):
1311
forward = "forward"
1412
backward = "backward"
1513

14+
1615
class Action:
1716
"""
1817
全てのActionの継承元となるクラス。
1918
metaclassによって、自動的に割り当てられる。
2019
"""
2120
pass
2221

22+
2323
class ActionMeta(type):
2424
"""
2525
全てのActionのメタクラス。
@@ -32,8 +32,10 @@ def __new__(meta, name, bases, attributes):
3232
raise TypeError("Action has no type!")
3333
return type.__new__(meta, name, bases, attributes)
3434

35+
3536
class InputAction(metaclass=ActionMeta):
3637
type = "input"
38+
3739
def __init__(self, text: str):
3840
"""
3941
文字を入力するアクション
@@ -44,8 +46,10 @@ def __init__(self, text: str):
4446
"""
4547
self.text = text
4648

49+
4750
class ReplaceLastCharactersAction(metaclass=ActionMeta):
4851
type = "replace_last_characters"
52+
4953
def __init__(self, table: dict[str, str]):
5054
"""
5155
最後の文字を置換するアクション
@@ -56,19 +60,23 @@ def __init__(self, table: dict[str, str]):
5660
"""
5761
self.table = table
5862

63+
5964
class ReplaceDefaultAction(metaclass=ActionMeta):
6065
"""
6166
azooKeyデフォルトの置換アクション
6267
"""
6368
type = "replace_default"
6469

70+
6571
@unique
6672
class TabType(str, Enum):
6773
system = "system"
6874
custom = "custom"
6975

76+
7077
class MoveTabAction(metaclass=ActionMeta):
7178
type = "move_tab"
79+
7280
def __init__(self, tab_type: TabType, text: str):
7381
"""
7482
タブを移動するアクション
@@ -82,8 +90,10 @@ def __init__(self, tab_type: TabType, text: str):
8290
self.tab_type = tab_type
8391
self.identifier = text
8492

93+
8594
class MoveCursorAction(metaclass=ActionMeta):
8695
type = "move_cursor"
96+
8797
def __init__(self, count: int):
8898
"""
8999
カーソルを移動するアクション
@@ -94,8 +104,10 @@ def __init__(self, count: int):
94104
"""
95105
self.count = count
96106

107+
97108
class SmartMoveCursorAction(metaclass=ActionMeta):
98109
type = "smart_move_cursor"
110+
99111
def __init__(self, direction: ScanDirection, targets: list[str]):
100112
"""
101113
指定した文字の隣までカーソルを移動するアクション
@@ -109,8 +121,28 @@ def __init__(self, direction: ScanDirection, targets: list[str]):
109121
self.direction = direction
110122
self.targets = targets
111123

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+
112143
class DeleteAction(metaclass=ActionMeta):
113144
type = "delete"
145+
114146
def __init__(self, count: int):
115147
"""
116148
文字を削除するアクション
@@ -121,8 +153,10 @@ def __init__(self, count: int):
121153
"""
122154
self.count = count
123155

156+
124157
class SmartDeleteAction(metaclass=ActionMeta):
125158
type = "smart_delete"
159+
126160
def __init__(self, direction: ScanDirection, targets: list[str]):
127161
"""
128162
指定した文字の隣まで文字を削除するアクション
@@ -136,42 +170,49 @@ def __init__(self, direction: ScanDirection, targets: list[str]):
136170
self.direction = direction
137171
self.targets = targets
138172

173+
139174
class SmartDeleteDefaultAction(metaclass=ActionMeta):
140175
"""
141176
azooKeyデフォルトの文頭まで削除アクション
142177
"""
143178
type = "smart_delete_default"
144179

180+
145181
class EnableResizingModeAction(metaclass=ActionMeta):
146182
"""
147183
片手モードの調整を始めるアクション
148184
"""
149185
type = "enable_resizing_mode"
150186

187+
151188
class ToggleCursorBarAction(metaclass=ActionMeta):
152189
"""
153190
カーソルバーの表示状態をtoggleするアクション
154191
"""
155192
type = "toggle_cursor_bar"
156193

194+
157195
class ToggleTabBarAction(metaclass=ActionMeta):
158196
"""
159197
タブバーの表示状態をtoggleするアクション
160198
"""
161199
type = "toggle_tab_bar"
162200

201+
163202
class ToggleCapsLockStateAction(metaclass=ActionMeta):
164203
"""
165204
Caps lockの状態をtoggleするアクション
166205
"""
167206
type = "toggle_caps_lock_state"
168207

208+
169209
class DismissKeyboardAction(metaclass=ActionMeta):
170210
"""
171211
キーボードを閉じるアクション
172212
"""
173213
type = "dismiss_keyboard"
174214

215+
175216
class LongpressAction(object):
176217
def __init__(self, start: list[Action] = [], repeat: list[Action] = []):
177218
"""

python/source/design.py

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class KeyColor(str, Enum):
77
normal = "normal"
88
special = "special"
99
selected = "selected"
10+
unimportant = "unimportant"
1011

1112

1213
class KeyLabel(object):

python/test/test_actions.py

+23-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
from source.json import to_json
2+
from source.actions import *
13
import unittest
24
import sys
5+
import json
36
from pathlib import Path
47
sys.path.append(str(Path('__file__').resolve().parent))
5-
from source.actions import *
6-
from source.json import to_json
78

89

910
class TestActions(unittest.TestCase):
@@ -23,7 +24,8 @@ def test_InputAction(self):
2324
def test_ReplaceLastCharactersAction(self):
2425
"""test method for ReplaceLastCharactersAction
2526
"""
26-
actual = to_json(ReplaceLastCharactersAction({"あ": "ぁ", "か": "が", "😆": "😭"}))
27+
actual = to_json(ReplaceLastCharactersAction(
28+
{"あ": "ぁ", "か": "が", "😆": "😭"}))
2729
expected_json = {
2830
"type": "replace_last_characters",
2931
"table": {"あ": "ぁ", "か": "が", "😆": "😭"}
@@ -33,15 +35,17 @@ def test_ReplaceLastCharactersAction(self):
3335
def test_MoveTabAction(self):
3436
"""test method for MoveTabAction
3537
"""
36-
actual = to_json(MoveTabAction(tab_type=TabType.custom, text="flick_greek"))
38+
actual = to_json(MoveTabAction(
39+
tab_type=TabType.custom, text="flick_greek"))
3740
expected_json = {
3841
"type": "move_tab",
3942
"tab_type": TabType.custom,
4043
"identifier": "flick_greek"
4144
}
4245
self.assertEqual(expected_json, actual)
4346

44-
actual = to_json(MoveTabAction(tab_type=TabType.system, text="flick_kutoten"))
47+
actual = to_json(MoveTabAction(
48+
tab_type=TabType.system, text="flick_kutoten"))
4549
expected_json = {
4650
"type": "move_tab",
4751
"tab_type": TabType.system,
@@ -66,11 +70,23 @@ def test_MoveCursorAction(self):
6670
}
6771
self.assertEqual(expected_json, actual)
6872

73+
def test_LaunchApplicationAction(self):
74+
"""test method for LaunchApplicationAction
75+
"""
76+
actual = to_json(LaunchApplicationAction(
77+
"shortcuts", "run_shortcut?name=take_picture"))
78+
expected_json = {
79+
"type": "launch_application",
80+
"scheme_type": "shortcuts",
81+
"target": "run_shortcut?name=take_picture"
82+
}
83+
self.assertEqual(expected_json, actual)
84+
6985
def test_SmartMoveCursorAction(self):
7086
"""test method for SmartMoveCursorAction
7187
"""
7288
actual = to_json(SmartMoveCursorAction(ScanDirection.forward, targets=[
73-
"!", "?", ".", ",", ":", ";"]))
89+
"!", "?", ".", ",", ":", ";"]))
7490
expected_json = {
7591
"type": "smart_move_cursor",
7692
"direction": ScanDirection.forward,
@@ -99,7 +115,7 @@ def test_SmartDeleteAction(self):
99115
"""test method for SmartDeleteAction
100116
"""
101117
actual = to_json(SmartDeleteAction(ScanDirection.forward, targets=[
102-
"!", "?", ".", ",", ":", ";"]))
118+
"!", "?", ".", ",", ":", ";"]))
103119
expected_json = {
104120
"type": "smart_delete",
105121
"direction": ScanDirection.forward,

python/test/test_design.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
from source.json import to_json
2+
from source.design import *
13
import unittest
24
import sys
35
from pathlib import Path
46
sys.path.append(str(Path('__file__').resolve().parent))
5-
from source.design import *
6-
from source.json import to_json
77

88

99
class TestDesign(unittest.TestCase):
@@ -22,6 +22,9 @@ def test_KeyColor(self):
2222
actual = json.dumps(KeyColor.selected)
2323
self.assertEqual("\"selected\"", actual)
2424

25+
actual = json.dumps(KeyColor.unimportant)
26+
self.assertEqual("\"unimportant\"", actual)
27+
2528
def test_TextLabel(self):
2629
"""test method for TextLabel
2730
"""

swift/howToMake.md

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ design: .init(label: .text("@#/&_"), color: .normal)
4949
| .normal | 通常の入力キーの色です。 |
5050
| .special | タブ移動キーや削除キーの色です。 |
5151
| .selected | 選択中のタブや押されているキーの色です。 |
52+
| .unimportant | 重要度の低いキーの色です。 |
5253

5354
### アクション
5455

@@ -82,6 +83,7 @@ azooKeyでは`input`の他にいくつかの動作を行うことができます
8283
| .toggleTabBar | なし | タブバーの表示をtoggleします。 |
8384
| .toggleCapsLockState | なし | caps lockをtoggleします。 |
8485
| .dismissKeyboard | なし | キーボードを閉じます。 |
86+
| .launchApplication | LaunchItem | 引数で指定されたアプリケーションを開きます。 |
8587

8688
続く引数の`longpress_actions``CodableLongpressActionData`型の値です。定義は以下の通りで、`start``repeat`にそれぞれ行うべき動作を指定します。
8789

0 commit comments

Comments
 (0)