abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Keyboard2View.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/Keyboard2View.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/Keyboard2View.java')
-rw-r--r--srcs/juloo.keyboard2/Keyboard2View.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java
index fed2be6..d946aa1 100644
--- a/srcs/juloo.keyboard2/Keyboard2View.java
+++ b/srcs/juloo.keyboard2/Keyboard2View.java
@@ -90,6 +90,27 @@ public class Keyboard2View extends View
invalidate();
}
+ /** Called by auto-capitalisation. */
+ public void set_shift_state(boolean state)
+ {
+ KeyValue shift = KeyValue.getKeyByName("shift");
+ KeyboardData.Key key = _keyboard.findKeyWithValue(shift);
+ if (key == null)
+ {
+ // Lookup again for the lockable shift key, which is a different value.
+ shift = shift.withFlags(shift.getFlags() | KeyValue.FLAG_LOCK);
+ key = _keyboard.findKeyWithValue(shift);
+ }
+ if (key != null)
+ {
+ if (state)
+ _pointers.add_fake_pointer(shift, key);
+ else
+ _pointers.remove_fake_pointer(shift, key);
+ invalidate();
+ }
+ }
+
public KeyValue modifyKey(KeyValue k, Pointers.Modifiers mods)
{
return KeyModifier.modify(k, mods);