diff --git a/assets/special_font.ttf b/assets/special_font.ttf index c21ad29..da9274a 100644 Binary files a/assets/special_font.ttf and b/assets/special_font.ttf differ diff --git a/doc/Possible-key-values.md b/doc/Possible-key-values.md index a5defef..0898341 100644 --- a/doc/Possible-key-values.md +++ b/doc/Possible-key-values.md @@ -87,12 +87,14 @@ These keys are sent to apps, which are free to ignore them. The keyboard does no ## Keyboard editing actions In contrast, these keys perform editing on the text without sending anything to the app. -Value | Meaning -:----------------- | :------ -`cursor_left` | Moves the cursor to the left with the slider gesture. -`cursor_right` | Moves the cursor to the right with the slider gesture. -`cursor_up` | Moves the cursor up with the slider gesture. Warning: this might make the cursor leave the text box. -`cursor_down` | Moves the cursor down with the slider gesture. Warning: this might make the cursor leave the text box. +Value | Meaning +:-------------------- | :------ +`cursor_left` | Moves the cursor to the left with the slider gesture. +`cursor_right` | Moves the cursor to the right with the slider gesture. +`cursor_up` | Moves the cursor up with the slider gesture. Warning: this might make the cursor leave the text box. +`cursor_down` | Moves the cursor down with the slider gesture. Warning: this might make the cursor leave the text box. +`delete_word` | Delete the word to the left of the cursor. +`forward_delete_word` | Delete the word to the right of the cursor. ## Whitespace Value | Meaning diff --git a/srcs/juloo.keyboard2/KeyEventHandler.java b/srcs/juloo.keyboard2/KeyEventHandler.java index 09efd59..a841c30 100644 --- a/srcs/juloo.keyboard2/KeyEventHandler.java +++ b/srcs/juloo.keyboard2/KeyEventHandler.java @@ -146,11 +146,11 @@ public final class KeyEventHandler if (down) { _meta_state = _meta_state | meta_flags; - send_keyevent(KeyEvent.ACTION_DOWN, eventCode); + send_keyevent(KeyEvent.ACTION_DOWN, eventCode, _meta_state); } else { - send_keyevent(KeyEvent.ACTION_UP, eventCode); + send_keyevent(KeyEvent.ACTION_UP, eventCode, _meta_state); _meta_state = _meta_state & ~meta_flags; } } @@ -181,25 +181,28 @@ public final class KeyEventHandler } } - /* - * Don't set KeyEvent.FLAG_SOFT_KEYBOARD. - */ void send_key_down_up(int keyCode) { - send_keyevent(KeyEvent.ACTION_DOWN, keyCode); - send_keyevent(KeyEvent.ACTION_UP, keyCode); + send_key_down_up(keyCode, _meta_state); } - void send_keyevent(int eventAction, int eventCode) + /** Ignores currently pressed system modifiers. */ + void send_key_down_up(int keyCode, int metaState) + { + send_keyevent(KeyEvent.ACTION_DOWN, keyCode, metaState); + send_keyevent(KeyEvent.ACTION_UP, keyCode, metaState); + } + + void send_keyevent(int eventAction, int eventCode, int metaState) { InputConnection conn = _recv.getCurrentInputConnection(); if (conn == null) return; conn.sendKeyEvent(new KeyEvent(1, 1, eventAction, eventCode, 0, - _meta_state, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, + metaState, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE)); if (eventAction == KeyEvent.ACTION_UP) - _autocap.event_sent(eventCode, _meta_state); + _autocap.event_sent(eventCode, metaState); } void send_text(CharSequence text) @@ -236,6 +239,8 @@ public final class KeyEventHandler case REPLACE: send_context_menu_action(android.R.id.replaceText); break; case ASSIST: send_context_menu_action(android.R.id.textAssist); break; case AUTOFILL: send_context_menu_action(android.R.id.autofill); break; + case DELETE_WORD: send_key_down_up(KeyEvent.KEYCODE_DEL, KeyEvent.META_CTRL_ON | KeyEvent.META_CTRL_LEFT_ON); break; + case FORWARD_DELETE_WORD: send_key_down_up(KeyEvent.KEYCODE_FORWARD_DEL, KeyEvent.META_CTRL_ON | KeyEvent.META_CTRL_LEFT_ON); break; } } diff --git a/srcs/juloo.keyboard2/KeyModifier.java b/srcs/juloo.keyboard2/KeyModifier.java index c9de407..bb33cca 100644 --- a/srcs/juloo.keyboard2/KeyModifier.java +++ b/srcs/juloo.keyboard2/KeyModifier.java @@ -381,6 +381,13 @@ public final class KeyModifier case SHIFT: name = "capslock"; break; } break; + case Keyevent: + switch (k.getKeyevent()) + { + case KeyEvent.KEYCODE_DEL: name = "delete_word"; break; + case KeyEvent.KEYCODE_FORWARD_DEL: name = "forward_delete_word"; break; + } + break; } return (name == null) ? k : KeyValue.getKeyByName(name); } diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java index 2c5a03b..413520d 100644 --- a/srcs/juloo.keyboard2/KeyValue.java +++ b/srcs/juloo.keyboard2/KeyValue.java @@ -75,6 +75,8 @@ public final class KeyValue implements Comparable SHARE, ASSIST, AUTOFILL, + DELETE_WORD, + FORWARD_DELETE_WORD, } public static enum Placeholder @@ -707,6 +709,8 @@ public final class KeyValue implements Comparable case "pasteAsPlainText": return editingKey(0xE035, Editing.PASTE_PLAIN); case "undo": return editingKey(0xE036, Editing.UNDO); case "redo": return editingKey(0xE037, Editing.REDO); + case "delete_word": return editingKey(0xE01B, Editing.DELETE_WORD); + case "forward_delete_word": return editingKey(0xE01C, Editing.FORWARD_DELETE_WORD); case "cursor_left": return sliderKey(Slider.Cursor_left, 1); case "cursor_right": return sliderKey(Slider.Cursor_right, 1); case "cursor_up": return sliderKey(Slider.Cursor_up, 1); diff --git a/srcs/special_font/01B.svg b/srcs/special_font/01B.svg new file mode 100644 index 0000000..cd4d245 --- /dev/null +++ b/srcs/special_font/01B.svg @@ -0,0 +1,18 @@ + + + + + + + diff --git a/srcs/special_font/01C.svg b/srcs/special_font/01C.svg new file mode 100644 index 0000000..a92bd85 --- /dev/null +++ b/srcs/special_font/01C.svg @@ -0,0 +1,18 @@ + + + + + + +