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/KeyValue.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'srcs/juloo.keyboard2/KeyValue.java') diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java index 413520d..ecfdd94 100644 --- a/srcs/juloo.keyboard2/KeyValue.java +++ b/srcs/juloo.keyboard2/KeyValue.java @@ -59,6 +59,7 @@ public final class KeyValue implements Comparable BREVE, BAR, FN, + SELECTION_MODE, } // Last is be applied first public static enum Editing @@ -77,6 +78,7 @@ public final class KeyValue implements Comparable AUTOFILL, DELETE_WORD, FORWARD_DELETE_WORD, + SELECTION_CANCEL, } public static enum Placeholder @@ -715,6 +717,9 @@ public final class KeyValue implements Comparable case "cursor_right": return sliderKey(Slider.Cursor_right, 1); case "cursor_up": return sliderKey(Slider.Cursor_up, 1); case "cursor_down": return sliderKey(Slider.Cursor_down, 1); + case "selection_cancel": return editingKey("Esc", Editing.SELECTION_CANCEL, FLAG_SMALLER_FONT); + case "selection_cursor_left": return sliderKey(Slider.Selection_cursor_left, -1); // Move the left side of the selection + case "selection_cursor_right": return sliderKey(Slider.Selection_cursor_right, 1); // These keys are not used case "replaceText": return editingKey("repl", Editing.REPLACE); case "textAssist": return editingKey(0xE038, Editing.ASSIST); @@ -764,6 +769,9 @@ public final class KeyValue implements Comparable case "௲": case "௳": return makeStringKey(name, FLAG_SMALLER_FONT); + /* Internal keys */ + case "selection_mode": return makeInternalModifier(Modifier.SELECTION_MODE); + default: return null; } } @@ -780,7 +788,9 @@ public final class KeyValue implements Comparable Cursor_left(0xE008), Cursor_right(0xE006), Cursor_up(0xE005), - Cursor_down(0xE007); + Cursor_down(0xE007), + Selection_cursor_left(0xE008), + Selection_cursor_right(0xE006); final String symbol; -- cgit v1.2.3