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/ComposeKey.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'srcs/juloo.keyboard2/ComposeKey.java') diff --git a/srcs/juloo.keyboard2/ComposeKey.java b/srcs/juloo.keyboard2/ComposeKey.java index dd805a5..ef5a7f2 100644 --- a/srcs/juloo.keyboard2/ComposeKey.java +++ b/srcs/juloo.keyboard2/ComposeKey.java @@ -4,31 +4,26 @@ import java.util.Arrays; public final class ComposeKey { - /** Apply the pending compose sequence to [kv]. Returns [null] if [kv] is not - part of the pending sequence. */ + /** Apply the pending compose sequence to [kv]. */ public static KeyValue apply(int state, KeyValue kv) { switch (kv.getKind()) { case Char: KeyValue res = apply(state, kv.getChar()); - // Dim characters not part of any sequence instead of removing them. + // Grey-out characters not part of any sequence. if (res == null) return kv.withFlags(kv.getFlags() | KeyValue.FLAG_GREYED); return res; - /* These keys must not be removed. */ + /* These keys are not greyed. */ case Event: case Modifier: + case Compose_pending: return kv; - /* These keys cannot be part of sequences. */ - case String: - case Keyevent: - case Editing: - case Placeholder: + /* Other keys cannot be part of sequences. */ + default: return kv.withFlags(kv.getFlags() | KeyValue.FLAG_GREYED); - case Compose_pending: return null; } - return null; } /** Apply the pending compose sequence to char [c]. */ -- cgit v1.2.3