abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/KeyModifier.java
diff options
context:
space:
mode:
authorJules Aguillon2024-02-11 20:46:36 +0100
committerJules Aguillon2024-02-17 23:28:31 +0100
commit8c290732607692cd94247f7e3e9c80fad1dfe516 (patch)
tree1903ef13cc72626d0b12c712f9d15aede6fc67b4 /srcs/juloo.keyboard2/KeyModifier.java
parent38deb810f94d0e2fea91add4cd53fdd615d19d64 (diff)
downloadunexpected-keyboard-8c290732607692cd94247f7e3e9c80fad1dfe516.tar.gz
unexpected-keyboard-8c290732607692cd94247f7e3e9c80fad1dfe516.zip
Compose key
The COMPOSE_PENDING modifier indicate whether a compose sequence is in progress. The new key of kind Compose_pending sets the current state of the sequence. The compose sequences are compiled into a state machine by a python script into a compact encoding. The state of the pending compose is determined by the index of a state.
Diffstat (limited to 'srcs/juloo.keyboard2/KeyModifier.java')
-rw-r--r--srcs/juloo.keyboard2/KeyModifier.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/srcs/juloo.keyboard2/KeyModifier.java b/srcs/juloo.keyboard2/KeyModifier.java
index 51e7051..94f096b 100644
--- a/srcs/juloo.keyboard2/KeyModifier.java
+++ b/srcs/juloo.keyboard2/KeyModifier.java
@@ -10,6 +10,10 @@ public final class KeyModifier
private static HashMap<KeyValue, HashMap<Pointers.Modifiers, KeyValue>> _cache =
new HashMap<KeyValue, HashMap<Pointers.Modifiers, KeyValue>>();
+ /** The current compose state. Whether a compose is pending is signaled by
+ the [COMPOSE_PENDING] modifier. */
+ static int _compose_pending = -1;
+
/** Modify a key according to modifiers. */
public static KeyValue modify(KeyValue k, Pointers.Modifiers mods)
{
@@ -27,7 +31,11 @@ public final class KeyModifier
ks.put(mods, r);
}
/* Keys with an empty string are placeholder keys. */
- return (r.getString().length() == 0) ? null : r;
+ if (r.getString().length() == 0)
+ return null;
+ if (mods.has(KeyValue.Modifier.COMPOSE_PENDING))
+ r = ComposeKey.apply(_compose_pending, r);
+ return r;
}
public static KeyValue modify(KeyValue k, KeyValue.Modifier mod)
@@ -99,6 +107,11 @@ public final class KeyModifier
}
}
+ public static void set_compose_pending(int state)
+ {
+ _compose_pending = state;
+ }
+
private static KeyValue apply_map_char(KeyValue k, Map_char map)
{
switch (k.getKind())