From cc571ea1ca6e583024f9295b131ec199aa66cfd8 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sun, 5 Jun 2022 18:14:50 +0200 Subject: Refactor: Merge KeyValue.char and code fields These two fields couldn't have an interesting value at the same time. As we can no longer rely on a special value to distinguish between what's the kind, the kind of the key is explicitly encoded in the two most significative bits of the _flags field. Extra nice thing: This removes the special values 'EVENT_NONE' and 'CHAR_NONE'. --- srcs/juloo.keyboard2/KeyModifier.java | 16 +++++----------- 1 file changed, 5 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 7d01560..a69b5a1 100644 --- a/srcs/juloo.keyboard2/KeyModifier.java +++ b/srcs/juloo.keyboard2/KeyModifier.java @@ -72,7 +72,7 @@ class KeyModifier case Char: char kc = k.getChar(); char c = map.apply(kc); - return (kc == c) ? k : k.withCharAndSymbol(c); + return (kc == c) ? k : k.withChar(c); default: return k; } } @@ -84,9 +84,7 @@ class KeyModifier case Char: char kc = k.getChar(); char c = (char)KeyCharacterMap.getDeadChar(dead_char, kc); - if (c == 0 || kc == c) - return k; - return k.withCharAndSymbol(c); + return (c == 0 || kc == c) ? k : k.withChar(c); default: return k; } } @@ -96,8 +94,7 @@ class KeyModifier switch (k.getKind()) { case Char: - String s = String.valueOf(k.getChar()) + combining; - return k.withCharAndSymbol(s, KeyValue.CHAR_NONE); + return k.withString(String.valueOf(k.getChar()) + combining); default: return k; } } @@ -111,12 +108,9 @@ class KeyModifier char c = map_char_shift(kc); if (kc == c) c = Character.toUpperCase(kc); - if (kc == c) - return k; - return k.withCharAndSymbol(c); + return (kc == c) ? k : k.withChar(c); case String: - String s = k.getString().toUpperCase(); - return k.withCharAndSymbol(s, KeyValue.CHAR_NONE); + return k.withString(k.getString().toUpperCase()); default: return k; } } -- cgit v1.2.3