diff options
Diffstat (limited to 'srcs/juloo.keyboard2/KeyEventHandler.java')
| -rw-r--r-- | srcs/juloo.keyboard2/KeyEventHandler.java | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/srcs/juloo.keyboard2/KeyEventHandler.java b/srcs/juloo.keyboard2/KeyEventHandler.java index 145acbe..336398c 100644 --- a/srcs/juloo.keyboard2/KeyEventHandler.java +++ b/srcs/juloo.keyboard2/KeyEventHandler.java @@ -12,10 +12,13 @@ import java.util.Iterator; public final class KeyEventHandler implements Config.IKeyEventHandler, - ClipboardHistoryService.ClipboardPasteCallback + ClipboardHistoryService.ClipboardPasteCallback, + CurrentlyTypedWord.Callback { IReceiver _recv; Autocapitalisation _autocap; + Suggestions _suggestions; + CurrentlyTypedWord _typedword; /** State of the system modifiers. It is updated whether a modifier is down or up and a corresponding key event is sent. */ Pointers.Modifiers _mods; @@ -33,20 +36,25 @@ public final class KeyEventHandler _autocap = new Autocapitalisation(recv.getHandler(), this.new Autocapitalisation_callback()); _mods = Pointers.Modifiers.EMPTY; + _suggestions = new Suggestions(recv); + _typedword = new CurrentlyTypedWord(this); } /** Editing just started. */ public void started(Config conf) { - _autocap.started(conf, _recv.getCurrentInputConnection()); + InputConnection ic = _recv.getCurrentInputConnection(); + _autocap.started(conf, ic); + _typedword.started(conf, ic); _move_cursor_force_fallback = conf.editor_config.should_move_cursor_force_fallback; } /** Selection has been updated. */ - public void selection_updated(int oldSelStart, int newSelStart) + public void selection_updated(int oldSelStart, int newSelStart, int newSelEnd) { _autocap.selection_updated(oldSelStart, newSelStart); + _typedword.selection_updated(oldSelStart, newSelStart, newSelEnd); } /** A key is being pressed. There will not necessarily be a corresponding @@ -122,6 +130,12 @@ public final class KeyEventHandler send_text(content); } + @Override + public void currently_typed_word(String word) + { + _suggestions.currently_typed_word(word); + } + /** Update [_mods] to be consistent with the [mods], sending key events if needed. */ void update_meta_state(Pointers.Modifiers mods) @@ -211,13 +225,14 @@ public final class KeyEventHandler _autocap.event_sent(eventCode, metaState); } - void send_text(CharSequence text) + void send_text(String text) { InputConnection conn = _recv.getCurrentInputConnection(); if (conn == null) return; conn.commitText(text, 1); _autocap.typed(text); + _typedword.typed(text); } /** See {!InputConnection.performContextMenuAction}. */ @@ -473,7 +488,7 @@ public final class KeyEventHandler return (conn.getSelectedText(0) != null); } - public static interface IReceiver + public static interface IReceiver extends Suggestions.Callback { public void handle_event_key(KeyValue.Event ev); public void set_shift_state(boolean state, boolean lock); |
