From 40498e7b4cbd1b3e9e677f19d638638b6db3d2f9 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sun, 20 Aug 2023 00:44:22 +0200 Subject: Refactor: Allow combining diacritics modifiers Change the API of `KeyModifier.Map_char` to allow returning a string instead of a single 16 bits char. This allows to return combining diacritics. This also gets rid of `apply_map_or_dead_char`, maps can have their own fallback. --- srcs/juloo.keyboard2/KeyValue.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'srcs/juloo.keyboard2/KeyValue.java') diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java index 0972214..10ce481 100644 --- a/srcs/juloo.keyboard2/KeyValue.java +++ b/srcs/juloo.keyboard2/KeyValue.java @@ -182,11 +182,6 @@ final class KeyValue return new KeyValue(String.valueOf(c), Kind.Char, c, getFlags()); } - public KeyValue withString(String s) - { - return new KeyValue(s, Kind.String, 0, getFlags()); - } - public KeyValue withSymbol(String s) { return new KeyValue(s, (_code & KIND_BITS), (_code & VALUE_BITS), getFlags()); @@ -302,13 +297,19 @@ final class KeyValue return new KeyValue("", Kind.Placeholder, id.ordinal(), 0); } - /** Make a key that types a string. */ public static KeyValue makeStringKey(String str) + { + return makeStringKey(str, 0); + } + + /** Make a key that types a string. A char key is returned for a string of + length 1. */ + public static KeyValue makeStringKey(String str, int flags) { if (str.length() == 1) - return new KeyValue(str, Kind.Char, str.charAt(0), 0); + return new KeyValue(str, Kind.Char, str.charAt(0), flags); else - return new KeyValue(str, Kind.String, 0, FLAG_SMALLER_FONT); + return new KeyValue(str, Kind.String, 0, flags | FLAG_SMALLER_FONT); } public static KeyValue getKeyByName(String name) -- cgit v1.2.3