From 60b01927abed9479bed5fdbb268f049cfe609aea Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sat, 15 Mar 2025 16:13:16 +0100 Subject: Selection mode (#913) * Selection mode: Space to cancel the selection This adds the "selection mode", which is activated when text is selected in the text box. The selection mode is exited when the selection is cleared. While the selection mode is activated, the Space and Esc keys are modified into the "selection cancel" key, which remove the selection without changing the text. The space bar is otherwise easy to type by accident during a selection and causes the selected text to be deleted. * Selection mode: Move each ends of selection separately with slider When the selection mode is activated, the space bar sliders change how they affect the selection: - The left side of the slider moves the left position of the selection. To shrink the selection from the left side, the slider must be activated by sliding to the left, extending the selection temporarilly, then by sliding to the right. - The right side of the slider affects the right position if the selection.--- srcs/juloo.keyboard2/KeyModifier.java | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'srcs/juloo.keyboard2/KeyModifier.java') diff --git a/srcs/juloo.keyboard2/KeyModifier.java b/srcs/juloo.keyboard2/KeyModifier.java index bb33cca..e512521 100644 --- a/srcs/juloo.keyboard2/KeyModifier.java +++ b/srcs/juloo.keyboard2/KeyModifier.java @@ -82,6 +82,7 @@ public final class KeyModifier case HOOK_ABOVE: return apply_compose(k, ComposeKeyData.accent_hook_above); case DOUBLE_GRAVE: return apply_compose(k, ComposeKeyData.accent_double_grave); case ARROW_RIGHT: return apply_combining_char(k, "\u20D7"); + case SELECTION_MODE: return apply_selection_mode(k); default: return k; } } @@ -392,6 +393,34 @@ public final class KeyModifier return (name == null) ? k : KeyValue.getKeyByName(name); } + private static KeyValue apply_selection_mode(KeyValue k) + { + String name = null; + switch (k.getKind()) + { + case Char: + switch (k.getChar()) + { + case ' ': name = "selection_cancel"; break; + } + break; + case Slider: + switch (k.getSlider()) + { + case Cursor_left: name = "selection_cursor_left"; break; + case Cursor_right: name = "selection_cursor_right"; break; + } + break; + case Keyevent: + switch (k.getKeyevent()) + { + case KeyEvent.KEYCODE_ESCAPE: name = "selection_cancel"; break; + } + break; + } + return (name == null) ? k : KeyValue.getKeyByName(name); + } + /** Compose the precomposed initial with the medial [kv]. */ private static KeyValue combine_hangul_initial(KeyValue kv, int precomposed) { -- cgit v1.2.3