abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/KeyValue.java
diff options
context:
space:
mode:
authorJules Aguillon2023-01-30 21:29:59 +0100
committerJules Aguillon2023-01-30 21:29:59 +0100
commit2539feadcd370e98d3750f6b6b06664e0eb14d0b (patch)
treede190a6645c6843484269d733437dfa49efcbbbd /srcs/juloo.keyboard2/KeyValue.java
parent5f283cd0cd3df4761b924ffae91c59862d4ecc89 (diff)
downloadunexpected-keyboard-2539feadcd370e98d3750f6b6b06664e0eb14d0b.tar.gz
unexpected-keyboard-2539feadcd370e98d3750f6b6b06664e0eb14d0b.zip
Fix placeholder key not replaced
Since fecc4dd, placeholder keys can't be compared by reference. Add a placeholder kind and defined placeholder values.
Diffstat (limited to 'srcs/juloo.keyboard2/KeyValue.java')
-rw-r--r--srcs/juloo.keyboard2/KeyValue.java30
1 files changed, 19 insertions, 11 deletions
diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java
index 21a3baf..4a6223e 100644
--- a/srcs/juloo.keyboard2/KeyValue.java
+++ b/srcs/juloo.keyboard2/KeyValue.java
@@ -68,9 +68,16 @@ final class KeyValue
AUTOFILL,
}
+ public static enum Placeholder
+ {
+ REMOVED,
+ F11,
+ F12
+ }
+
public static enum Kind
{
- Char, String, Keyevent, Event, Modifier, Editing
+ Char, String, Keyevent, Event, Modifier, Editing, Placeholder
}
// Behavior flags.
@@ -154,6 +161,11 @@ final class KeyValue
return Editing.values()[(_code & VALUE_BITS)];
}
+ public Placeholder getPlaceholder()
+ {
+ return Placeholder.values()[(_code & VALUE_BITS)];
+ }
+
/* Update the char and the symbol. */
public KeyValue withChar(char c)
{
@@ -257,14 +269,10 @@ final class KeyValue
FLAG_SPECIAL | FLAG_SECONDARY | FLAG_SMALLER_FONT);
}
- // Within VALUE_BITS
- private static int placeholder_unique_id = 0;
-
- /** Use a unique id as the value because the symbol is shared between every
- placeholders (it is the empty string). */
- private static KeyValue placeholderKey()
+ /** A key that do nothing but has a unique ID. */
+ private static KeyValue placeholderKey(Placeholder id)
{
- return new KeyValue("", Kind.String, placeholder_unique_id++, 0);
+ return new KeyValue("", Kind.Placeholder, id.ordinal(), 0);
}
private static KeyValue fallbackMakeKey(String name)
@@ -349,9 +357,9 @@ final class KeyValue
case "space": return charKey("\r", ' ', FLAG_KEY_FONT | FLAG_SECONDARY);
case "nbsp": return charKey("\u237d", '\u00a0', FLAG_SMALLER_FONT);
- case "removed": return placeholderKey();
- case "f11_placeholder": return placeholderKey();
- case "f12_placeholder": return placeholderKey();
+ case "removed": return placeholderKey(Placeholder.REMOVED);
+ case "f11_placeholder": return placeholderKey(Placeholder.F11);
+ case "f12_placeholder": return placeholderKey(Placeholder.F12);
case "copy": return editingKey("copy", Editing.COPY);
case "paste": return editingKey("paste", Editing.PASTE);