diff options
| author | Jules Aguillon | 2025-02-28 00:35:43 +0100 |
|---|---|---|
| committer | Jules Aguillon | 2025-02-28 00:36:14 +0100 |
| commit | 55cb5f5315c9183f6e4821daa26997e329e30fd8 (patch) | |
| tree | c17500664e69a78b5b9231704a1473bccc4a5523 /srcs/juloo.keyboard2/KeyValue.java | |
| parent | b7d1508d7b74b3d634b8f3a547d56c27e10f80c8 (diff) | |
| download | unexpected-keyboard-55cb5f5315c9183f6e4821daa26997e329e30fd8.tar.gz unexpected-keyboard-55cb5f5315c9183f6e4821daa26997e329e30fd8.zip | |
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.
Diffstat (limited to 'srcs/juloo.keyboard2/KeyValue.java')
| -rw-r--r-- | srcs/juloo.keyboard2/KeyValue.java | 14 |
1 files changed, 10 insertions, 4 deletions
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<KeyValue> /* 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<KeyValue> 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<KeyValue> 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<KeyValue> 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); } |
