diff options
| author | Jules Aguillon | 2024-03-18 01:00:22 +0100 |
|---|---|---|
| committer | Jules Aguillon | 2024-03-18 01:00:22 +0100 |
| commit | e604f6fd57d85f46dd46da9da192646660547bc2 (patch) | |
| tree | 23e27096cc85ec85d865ef7f13afb6f7422b8c2c /srcs/juloo.keyboard2/KeyValue.java | |
| parent | dc3a303af1ef72602b58292e5cc938944d6954ba (diff) | |
| download | unexpected-keyboard-e604f6fd57d85f46dd46da9da192646660547bc2.tar.gz unexpected-keyboard-e604f6fd57d85f46dd46da9da192646660547bc2.zip | |
refactor: Implement Compose without global state
Thanks to the previous commit, a modifier key can now be more complex
than just a KeyValue.Modifier. This allows a more elegant implementation
of the compose key, that could be taken as a base for other features
(eg. unicode hex entry, hangul)
The COMPOSE_PENDING modifier is removed as keys of kind Compose_pending
can act as a modifier. This has the advantage of highlighting the key
that was last pressed in the sequence.
Rules are added to Pointers: Non-special but latchable keys must clear
latches and cannot be locked with a long press. These rules were not
needed before but were intended.
Diffstat (limited to 'srcs/juloo.keyboard2/KeyValue.java')
| -rw-r--r-- | srcs/juloo.keyboard2/KeyValue.java | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java index f63f558..2a00a59 100644 --- a/srcs/juloo.keyboard2/KeyValue.java +++ b/srcs/juloo.keyboard2/KeyValue.java @@ -26,7 +26,6 @@ public final class KeyValue implements Comparable<KeyValue> // Must be evaluated in the reverse order of their values. public static enum Modifier { - COMPOSE_PENDING, SHIFT, CTRL, ALT, @@ -89,8 +88,8 @@ public final class KeyValue implements Comparable<KeyValue> public static enum Kind { - Char, String, Keyevent, Event, Modifier, Editing, Placeholder, - Compose_pending + Char, String, Keyevent, Event, Compose_pending, Modifier, Editing, + Placeholder } private static final int FLAGS_OFFSET = 19; @@ -340,7 +339,13 @@ public final class KeyValue implements Comparable<KeyValue> public static KeyValue makeComposePending(String symbol, int state, int flags) { return new KeyValue(symbol, Kind.Compose_pending, state, - flags | FLAG_SPECIAL); + flags | FLAG_LATCH); + } + + public static KeyValue makeComposePending(int symbol, int state, int flags) + { + return makeComposePending(String.valueOf((char)symbol), state, + flags | FLAG_KEY_FONT); } /** Make a key that types a string. A char key is returned for a string of @@ -505,7 +510,7 @@ public final class KeyValue implements Comparable<KeyValue> case "autofill": return editingKey("auto", Editing.AUTOFILL); /* The compose key */ - case "compose": return modifierKey(0xE016, Modifier.COMPOSE_PENDING, FLAG_SECONDARY | FLAG_SMALLER_FONT); + case "compose": return makeComposePending(0xE016, 0, FLAG_SECONDARY | FLAG_SMALLER_FONT | FLAG_SPECIAL); /* Placeholder keys */ case "removed": return placeholderKey(Placeholder.REMOVED); |
