abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/ExtraKeys.java
diff options
context:
space:
mode:
authorJules Aguillon2023-09-15 18:00:27 +0200
committerJules Aguillon2023-09-15 18:00:27 +0200
commit66b1bdc9c90e1f29ecec096286136b527ec6b8ed (patch)
tree581d6f693ba487a91775725e7d6e3ffe7437c2b1 /srcs/juloo.keyboard2/ExtraKeys.java
parentd771e9d2c7de7d62f5514995f4a224e1e293a376 (diff)
downloadunexpected-keyboard-66b1bdc9c90e1f29ecec096286136b527ec6b8ed.tar.gz
unexpected-keyboard-66b1bdc9c90e1f29ecec096286136b527ec6b8ed.zip
Refactor: Preferred positions for extra keys
The new PreferredPos class represents where an extra key should be placed Currently used to place keys at the same positions they were placed before.
Diffstat (limited to 'srcs/juloo.keyboard2/ExtraKeys.java')
-rw-r--r--srcs/juloo.keyboard2/ExtraKeys.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/srcs/juloo.keyboard2/ExtraKeys.java b/srcs/juloo.keyboard2/ExtraKeys.java
index cfac362..aa2e38f 100644
--- a/srcs/juloo.keyboard2/ExtraKeys.java
+++ b/srcs/juloo.keyboard2/ExtraKeys.java
@@ -22,7 +22,7 @@ class ExtraKeys
/** Add the keys that should be added to the keyboard into [dst]. Keys
already added to [dst] might have an impact, see [ExtraKey.compute]. */
- public void compute(Set<KeyValue> dst, Query q)
+ public void compute(Map<KeyValue, KeyboardData.PreferredPos> dst, Query q)
{
for (ExtraKey k : _ks)
k.compute(dst, q);
@@ -72,7 +72,7 @@ class ExtraKeys
}
/** Whether the key should be added to the keyboard. */
- public void compute(Set<KeyValue> dst, Query q)
+ public void compute(Map<KeyValue, KeyboardData.PreferredPos> dst, Query q)
{
// Add the alternative if it's the only one. The list of alternatives is
// enforced to be complete by the merging step. The same [kv] will not
@@ -80,11 +80,14 @@ class ExtraKeys
// alternatives.
// Selecting the dead key in the "Add key to the keyboard" option would
// disable this behavior for a key.
- boolean use_alternative = (alternatives.size() == 1 && !dst.contains(kv));
+ boolean use_alternative = (alternatives.size() == 1 && !dst.containsKey(kv));
if
((q.script == null || script == null || q.script.equals(script))
&& (alternatives.size() == 0 || !q.present.containsAll(alternatives)))
- dst.add(use_alternative ? alternatives.get(0) : kv);
+ {
+ KeyValue kv_ = use_alternative ? alternatives.get(0) : kv;
+ dst.put(kv_, KeyboardData.PreferredPos.DEFAULT);
+ }
}
/** Return a new key from two. [kv] are expected to be equal. [script] is