diff options
| author | Jules Aguillon | 2025-02-23 18:00:44 +0100 |
|---|---|---|
| committer | Jules Aguillon | 2025-02-23 18:00:44 +0100 |
| commit | ca25cc55f6bc2c7b3100da2f7bf18a078a23f55e (patch) | |
| tree | e3e94c2fa073e44063b66d86f8be4789620714ad /test/juloo.keyboard2 | |
| parent | 68be82a4f92f47300b9960cf9cf65040c96f17ed (diff) | |
| download | unexpected-keyboard-ca25cc55f6bc2c7b3100da2f7bf18a078a23f55e.tar.gz unexpected-keyboard-ca25cc55f6bc2c7b3100da2f7bf18a078a23f55e.zip | |
Apply compose sequences to String keys
This is mostly useful for characters that do not fit on a single 16-bit
char.
Shift sequences for 𝕨𝕩𝕗𝕘𝕤 are added for illustration.
Diffstat (limited to 'test/juloo.keyboard2')
| -rw-r--r-- | test/juloo.keyboard2/ComposeKeyTest.java | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/test/juloo.keyboard2/ComposeKeyTest.java b/test/juloo.keyboard2/ComposeKeyTest.java index 3d0b371..a3d1ddb 100644 --- a/test/juloo.keyboard2/ComposeKeyTest.java +++ b/test/juloo.keyboard2/ComposeKeyTest.java @@ -42,22 +42,21 @@ public class ComposeKeyTest assertEquals(apply("ய", state), KeyValue.makeStringKey("௰", KeyValue.FLAG_SMALLER_FONT)); } - KeyValue apply(String seq) throws Exception + @Test + public void stringKeys() throws Exception + { + int state = ComposeKeyData.shift; + assertEquals(apply("𝕨", state), KeyValue.makeStringKey("𝕎")); + assertEquals(apply("𝕩", state), KeyValue.makeStringKey("𝕏")); + } + + KeyValue apply(String seq) { - return apply(seq, ComposeKeyData.compose); + return ComposeKey.apply(ComposeKeyData.compose, seq); } - KeyValue apply(String seq, int state) throws Exception + KeyValue apply(String seq, int state) { - KeyValue r = null; - for (int i = 0; i < seq.length(); i++) - { - r = ComposeKey.apply(state, seq.charAt(i)); - if (r.getKind() == KeyValue.Kind.Compose_pending) - state = r.getPendingCompose(); - else if (i + 1 < seq.length()) - throw new Exception("Sequence too long: " + seq); - } - return r; + return ComposeKey.apply(state, seq); } } |
