diff options
| author | Jules Aguillon | 2024-02-11 20:46:36 +0100 |
|---|---|---|
| committer | Jules Aguillon | 2024-02-17 23:28:31 +0100 |
| commit | 8c290732607692cd94247f7e3e9c80fad1dfe516 (patch) | |
| tree | 1903ef13cc72626d0b12c712f9d15aede6fc67b4 /srcs/juloo.keyboard2/Keyboard2View.java | |
| parent | 38deb810f94d0e2fea91add4cd53fdd615d19d64 (diff) | |
| download | unexpected-keyboard-8c290732607692cd94247f7e3e9c80fad1dfe516.tar.gz unexpected-keyboard-8c290732607692cd94247f7e3e9c80fad1dfe516.zip | |
Compose key
The COMPOSE_PENDING modifier indicate whether a compose sequence is in
progress. The new key of kind Compose_pending sets the current state of
the sequence.
The compose sequences are compiled into a state machine by a python
script into a compact encoding.
The state of the pending compose is determined by the index of a state.
Diffstat (limited to 'srcs/juloo.keyboard2/Keyboard2View.java')
| -rw-r--r-- | srcs/juloo.keyboard2/Keyboard2View.java | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java index fb95412..88b718c 100644 --- a/srcs/juloo.keyboard2/Keyboard2View.java +++ b/srcs/juloo.keyboard2/Keyboard2View.java @@ -25,6 +25,10 @@ public class Keyboard2View extends View private KeyValue _shift_kv; private KeyboardData.Key _shift_key; + /** Used to add fake pointers. */ + private KeyValue _compose_kv; + private KeyboardData.Key _compose_key; + private Pointers _pointers; private Pointers.Modifiers _mods; @@ -98,6 +102,8 @@ public class Keyboard2View extends View _shift_kv = _shift_kv.withFlags(_shift_kv.getFlags() | KeyValue.FLAG_LOCK); _shift_key = _keyboard.findKeyWithValue(_shift_kv); } + _compose_kv = KeyValue.getKeyByName("compose"); + _compose_key = _keyboard.findKeyWithValue(_compose_kv); reset(); } @@ -109,26 +115,38 @@ public class Keyboard2View extends View invalidate(); } - /** Called by auto-capitalisation. */ - public void set_shift_state(boolean state, boolean lock) + void set_fake_ptr_latched(KeyboardData.Key key, KeyValue kv, boolean latched, + boolean lock) { - if (_keyboard == null || _shift_key == null) + if (_keyboard == null || key == null) return; - int flags = _pointers.getKeyFlags(_shift_key, _shift_kv); - if (state) + int flags = _pointers.getKeyFlags(key, kv); + if (latched) { if (flags != -1 && !lock) return; // Don't replace an existing pointer - _pointers.add_fake_pointer(_shift_kv, _shift_key, lock); + _pointers.add_fake_pointer(kv, key, lock); } else { if ((flags & KeyValue.FLAG_FAKE_PTR) == 0) return; // Don't remove locked pointers - _pointers.remove_fake_pointer(_shift_kv, _shift_key); + _pointers.remove_fake_pointer(kv, key); } } + /** Called by auto-capitalisation. */ + public void set_shift_state(boolean latched, boolean lock) + { + set_fake_ptr_latched(_shift_key, _shift_kv, latched, lock); + } + + /** Called from [KeyEventHandler]. */ + public void set_compose_pending(boolean pending) + { + set_fake_ptr_latched(_compose_key, _compose_kv, pending, false); + } + public KeyValue modifyKey(KeyValue k, Pointers.Modifiers mods) { if (_keyboard.modmap != null) |
