mirror of
https://github.com/Julow/Unexpected-Keyboard.git
synced 2024-11-22 15:23:11 +01:00
Fix placeholder key not replaced
Since fecc4dd
, placeholder keys can't be compared by reference.
Add a placeholder kind and defined placeholder values.
This commit is contained in:
parent
5f283cd0cd
commit
2539feadcd
@ -122,17 +122,7 @@ class KeyModifier
|
||||
case Char: name = apply_fn_char(k.getChar()); break;
|
||||
case Keyevent: name = apply_fn_keyevent(k.getKeyevent()); break;
|
||||
case Event: name = apply_fn_event(k.getEvent()); break;
|
||||
case String:
|
||||
switch (k.getString())
|
||||
{
|
||||
case "":
|
||||
if (k == KeyValue.getKeyByName("f11_placeholder"))
|
||||
name = "f11";
|
||||
else if (k == KeyValue.getKeyByName("f12_placeholder"))
|
||||
name = "f12";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Placeholder: name = apply_fn_placeholder(k.getPlaceholder()); break;
|
||||
}
|
||||
return (name == null) ? k : KeyValue.getKeyByName(name);
|
||||
}
|
||||
@ -160,6 +150,16 @@ class KeyModifier
|
||||
}
|
||||
}
|
||||
|
||||
private static String apply_fn_placeholder(KeyValue.Placeholder p)
|
||||
{
|
||||
switch (p)
|
||||
{
|
||||
case F11: return "f11";
|
||||
case F12: return "f12";
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** Return the name of modified key, or [null]. */
|
||||
private static String apply_fn_char(char c)
|
||||
{
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user