Pressing the compose key exits the pending sequence

Allows stopping a compose sequence without typing anything.
This is also a more intuitive behavior rather than starting a new
sequence.
This commit is contained in:
Jules Aguillon 2025-02-04 15:50:17 +01:00
parent 6b40803fa4
commit 0061911ef3
2 changed files with 14 additions and 1 deletions

View File

@ -15,10 +15,12 @@ public final class ComposeKey
if (res == null) if (res == null)
return kv.withFlags(kv.getFlags() | KeyValue.FLAG_GREYED); return kv.withFlags(kv.getFlags() | KeyValue.FLAG_GREYED);
return res; return res;
/* Tapping compose again exits the pending sequence. */
case Compose_pending:
return KeyValue.nothingKey(kv);
/* These keys are not greyed. */ /* These keys are not greyed. */
case Event: case Event:
case Modifier: case Modifier:
case Compose_pending:
return kv; return kv;
/* Other keys cannot be part of sequences. */ /* Other keys cannot be part of sequences. */
default: default:

View File

@ -80,6 +80,7 @@ public final class KeyValue implements Comparable<KeyValue>
public static enum Placeholder public static enum Placeholder
{ {
REMOVED, REMOVED,
NOTHING,
F11, F11,
F12, F12,
SHINDOT, SHINDOT,
@ -380,6 +381,16 @@ public final class KeyValue implements Comparable<KeyValue>
return new KeyValue("", Kind.Placeholder, id.ordinal(), 0); return new KeyValue("", Kind.Placeholder, id.ordinal(), 0);
} }
/** Make a key that does nothing, inheriting the symbol from an other key. */
public static KeyValue nothingKey(KeyValue inherit)
{
// Keep only appearance flags
int flags = inherit.getFlags() & (FLAG_SPECIAL | FLAG_GREYED |
FLAG_KEY_FONT | FLAG_SMALLER_FONT | FLAG_SECONDARY);
return new KeyValue(inherit.getString(), Kind.Placeholder,
Placeholder.NOTHING.ordinal(), flags);
}
public static KeyValue makeStringKey(String str) public static KeyValue makeStringKey(String str)
{ {
return makeStringKey(str, 0); return makeStringKey(str, 0);