From 324756535e139aacfb9d828a5bc9a2a6fef634ea Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sun, 24 Jul 2022 20:02:48 +0200 Subject: 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. --- srcs/juloo.keyboard2/KeyboardData.java | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'srcs/juloo.keyboard2/KeyboardData.java') 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 rows, final Iterator 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 -- cgit v1.2.3