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/Keyboard2View.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'srcs/juloo.keyboard2/Keyboard2View.java') 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); -- cgit v1.2.3