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/KeyModifier.java | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'srcs/juloo.keyboard2/KeyModifier.java') diff --git a/srcs/juloo.keyboard2/KeyModifier.java b/srcs/juloo.keyboard2/KeyModifier.java index a3c499b..70f7315 100644 --- a/srcs/juloo.keyboard2/KeyModifier.java +++ b/srcs/juloo.keyboard2/KeyModifier.java @@ -10,10 +10,6 @@ public final class KeyModifier private static HashMap> _cache = new HashMap>(); - /** The current compose state. Whether a compose is pending is signaled by - the [COMPOSE_PENDING] modifier. */ - static int _compose_pending = -1; - /** Modify a key according to modifiers. */ public static KeyValue modify(KeyValue k, Pointers.Modifiers mods) { @@ -33,8 +29,6 @@ public final class KeyModifier /* Keys with an empty string are placeholder keys. */ if (r.getString().length() == 0) return null; - if (mods.has(KeyValue.Modifier.COMPOSE_PENDING)) - r = ComposeKey.apply(_compose_pending, r); return r; } @@ -44,6 +38,8 @@ public final class KeyModifier { case Modifier: return modify(k, mod.getModifier()); + case Compose_pending: + return ComposeKey.apply(mod.getPendingCompose(), k); } return k; } @@ -118,11 +114,6 @@ public final class KeyModifier } } - public static void set_compose_pending(int state) - { - _compose_pending = state; - } - private static KeyValue apply_map_char(KeyValue k, Map_char map) { switch (k.getKind()) -- cgit v1.2.3