From 55cb5f5315c9183f6e4821daa26997e329e30fd8 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Fri, 28 Feb 2025 00:35:43 +0100 Subject: Make key symbol smaller when 2 characters long or more This was the case for string keys but not for macros or keys with custom symbols. --- srcs/juloo.keyboard2/KeyValue.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'srcs') diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java index 7c5dada..2c5a03b 100644 --- a/srcs/juloo.keyboard2/KeyValue.java +++ b/srcs/juloo.keyboard2/KeyValue.java @@ -233,7 +233,8 @@ public final class KeyValue implements Comparable /* Update the char and the symbol. */ public KeyValue withChar(char c) { - return new KeyValue(String.valueOf(c), Kind.Char, c, getFlags()); + return new KeyValue(String.valueOf(c), Kind.Char, c, + getFlags() & ~(FLAG_KEY_FONT | FLAG_SMALLER_FONT)); } public KeyValue withKeyevent(int code) @@ -248,6 +249,7 @@ public final class KeyValue implements Comparable public KeyValue withSymbol(String symbol) { + int flags = getFlags() & ~(FLAG_KEY_FONT | FLAG_SMALLER_FONT); switch (getKind()) { case Char: @@ -259,11 +261,13 @@ public final class KeyValue implements Comparable case Modifier: case Editing: case Placeholder: - return new KeyValue(symbol, _code, _code, getFlags()); + if (symbol.length() > 1) + flags |= FLAG_SMALLER_FONT; + return new KeyValue(symbol, _code, _code, flags); case Macro: - return makeMacro(symbol, getMacro(), 0); + return makeMacro(symbol, getMacro(), flags); default: - return makeMacro(symbol, new KeyValue[]{ this }, 0); + return makeMacro(symbol, new KeyValue[]{ this }, flags); } } @@ -477,6 +481,8 @@ public final class KeyValue implements Comparable public static KeyValue makeMacro(String symbol, KeyValue[] keys, int flags) { + if (symbol.length() > 1) + flags |= FLAG_SMALLER_FONT; return new KeyValue(new Macro(keys, symbol), Kind.Macro, 0, flags); } -- cgit v1.2.3