abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/KeyboardData.java
diff options
context:
space:
mode:
authorJules Aguillon2022-07-24 20:02:48 +0200
committerJules Aguillon2022-07-24 20:02:48 +0200
commit324756535e139aacfb9d828a5bc9a2a6fef634ea (patch)
tree717553aab3e9bd5a0536aa8b2e2a3a69d5e335ca /srcs/juloo.keyboard2/KeyboardData.java
parent2d8ed2d85849c95c7d39e0dfe11405bf70eeb395 (diff)
downloadunexpected-keyboard-324756535e139aacfb9d828a5bc9a2a6fef634ea.tar.gz
unexpected-keyboard-324756535e139aacfb9d828a5bc9a2a6fef634ea.zip
Automatic capitalisation at beginning of sentences
Keep track of end-of-sentence characters while typing and automatically enable shift when appropriate. The last few characters just before the cursor need to be queried in some cases: Begin of input, cursor has moved or text is deleted. This might have a performance cost. This normally only enable shift but it also needs to disable shift when the cursor moves.
Diffstat (limited to 'srcs/juloo.keyboard2/KeyboardData.java')
-rw-r--r--srcs/juloo.keyboard2/KeyboardData.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/srcs/juloo.keyboard2/KeyboardData.java b/srcs/juloo.keyboard2/KeyboardData.java
index c95dc51..9b47152 100644
--- a/srcs/juloo.keyboard2/KeyboardData.java
+++ b/srcs/juloo.keyboard2/KeyboardData.java
@@ -43,6 +43,17 @@ class KeyboardData
return new KeyboardData(rows, keysWidth, extra_keys);
}
+ public Key findKeyWithValue(KeyValue kv)
+ {
+ for (Row r : rows)
+ {
+ Key k = r.findKeyWithValue(kv);
+ if (k != null)
+ return k;
+ }
+ return null;
+ }
+
private static void addExtraKeys_to_row(ArrayList<Row> rows, final Iterator<KeyValue> extra_keys, int row_i, final int d)
{
if (!extra_keys.hasNext())
@@ -168,6 +179,14 @@ class KeyboardData
public Key apply(Key k) { return k.scaleWidth(s); }
});
}
+
+ public Key findKeyWithValue(KeyValue kv)
+ {
+ for (Key k : keys)
+ if (k.hasValue(kv))
+ return k;
+ return null;
+ }
}
public static class Key
@@ -291,6 +310,17 @@ class KeyboardData
}
return (c == null) ? null : c.kv;
}
+
+ public boolean hasValue(KeyValue kv)
+ {
+ return (hasValue(key0, kv) || hasValue(key1, kv) || hasValue(key2, kv) ||
+ hasValue(key3, kv) || hasValue(key4, kv));
+ }
+
+ private static boolean hasValue(Corner c, KeyValue kv)
+ {
+ return (c != null && c.kv.equals(kv));
+ }
}
public static final class Corner