From e604f6fd57d85f46dd46da9da192646660547bc2 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Mon, 18 Mar 2024 01:00:22 +0100 Subject: 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. --- srcs/juloo.keyboard2/KeyValue.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'srcs/juloo.keyboard2/KeyValue.java') 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 // 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 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 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 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); -- cgit v1.2.3