From 41777fdda61715a59be241f0be9a8e3385222888 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Thu, 18 Dec 2025 19:15:32 +0100 Subject: Disable selection mode in text editors (#1141) * Disable selection mode in text editors Selection mode removes the space bar key (which is replaced by the Esc key) and can be annoying in Emacs for example. Text editor users probably have the `esc` key available. * Refactor: Move EditorInfo related code to EditorConfig Add the new EditorConfig class that handles configuration extracted from the EditorInfo. It is accessible from the Config class for convenience. This aims at reducing the length of already large classes and group the code that was spread over several classes.--- srcs/juloo.keyboard2/KeyEventHandler.java | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'srcs/juloo.keyboard2/KeyEventHandler.java') diff --git a/srcs/juloo.keyboard2/KeyEventHandler.java b/srcs/juloo.keyboard2/KeyEventHandler.java index 33089d9..21a60c1 100644 --- a/srcs/juloo.keyboard2/KeyEventHandler.java +++ b/srcs/juloo.keyboard2/KeyEventHandler.java @@ -3,10 +3,8 @@ package juloo.keyboard2; import android.annotation.SuppressLint; import android.os.Looper; import android.os.Handler; -import android.text.InputType; import android.view.KeyCharacterMap; import android.view.KeyEvent; -import android.view.inputmethod.EditorInfo; import android.view.inputmethod.ExtractedText; import android.view.inputmethod.ExtractedTextRequest; import android.view.inputmethod.InputConnection; @@ -38,10 +36,11 @@ public final class KeyEventHandler } /** Editing just started. */ - public void started(EditorInfo info) + public void started(Config conf) { - _autocap.started(info, _recv.getCurrentInputConnection()); - _move_cursor_force_fallback = should_move_cursor_force_fallback(info); + _autocap.started(conf, _recv.getCurrentInputConnection()); + _move_cursor_force_fallback = + conf.editor_config.should_move_cursor_force_fallback; } /** Selection has been updated. */ @@ -468,17 +467,6 @@ public final class KeyEventHandler return (conn.getSelectedText(0) != null); } - /** Workaround some apps which answers to [getExtractedText] but do not react - to [setSelection] while returning [true]. */ - boolean should_move_cursor_force_fallback(EditorInfo info) - { - // This catch Acode: which sets several variations at once. - if ((info.inputType & InputType.TYPE_MASK_VARIATION & InputType.TYPE_TEXT_VARIATION_PASSWORD) != 0) - return true; - // Godot editor: Doesn't handle setSelection() but returns true. - return info.packageName.startsWith("org.godotengine.editor"); - } - public static interface IReceiver { public void handle_event_key(KeyValue.Event ev); -- cgit v1.2.3