From 7d15ecc3affdee1ad89ef1a2eeaca6b894ae6548 Mon Sep 17 00:00:00 2001 From: Alfred Reinold Baudisch Date: Wed, 19 Oct 2022 19:35:14 +0200 Subject: Add Selection and Caret for Next Occurrence of Selection Adds the bind `add_selection_for_next_occurrence` to TextEdit, with CTRL+D as the default shortcut. When the bind is performed, ff a selection is currently active with the last caret in text fields, searches for the next occurrence of the selection, adds a caret and selects the next occurrence. If no selection is currently active with the last caret in text fields, selects the word currently under the caret. The action can be performed sequentially for all occurrences of the selection of the last caret and for all existing carets. The viewport is adjusted to the latest newly added caret. The bind and the behaviour is similar to VS Code's "Add Selection to Next Find Match" and JetBrains' "Add Selection for Next Occurrence". It takes advantage of the multi-caret API. The default shortcut for `select_word_under_caret` has been changed to ALT+G, in order to give priority to CTRL+D for `add_selection_for_next_occurrence` to better align with popular IDEs and editors. --- core/input/input_map.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'core/input') diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp index ce76d11b6e..0c765fe23c 100644 --- a/core/input/input_map.cpp +++ b/core/input/input_map.cpp @@ -337,6 +337,7 @@ static const _BuiltinActionDisplayName _builtin_action_display_names[] = { { "ui_text_scroll_down.macos", TTRC("Scroll Down") }, { "ui_text_select_all", TTRC("Select All") }, { "ui_text_select_word_under_caret", TTRC("Select Word Under Caret") }, + { "ui_text_add_selection_for_next_occurrence", TTRC("Add Selection for Next Occurrence") }, { "ui_text_toggle_insert_mode", TTRC("Toggle Insert Mode") }, { "ui_text_submit", TTRC("Text Submitted") }, { "ui_graph_duplicate", TTRC("Duplicate Nodes") }, @@ -641,9 +642,13 @@ const HashMap>> &InputMap::get_builtins() { default_builtin_cache.insert("ui_text_select_all", inputs); inputs = List>(); - inputs.push_back(InputEventKey::create_reference(Key::D | KeyModifierMask::CMD_OR_CTRL)); + inputs.push_back(InputEventKey::create_reference(Key::G | KeyModifierMask::ALT)); default_builtin_cache.insert("ui_text_select_word_under_caret", inputs); + inputs = List>(); + inputs.push_back(InputEventKey::create_reference(Key::D | KeyModifierMask::CMD_OR_CTRL)); + default_builtin_cache.insert("ui_text_add_selection_for_next_occurrence", inputs); + inputs = List>(); inputs.push_back(InputEventKey::create_reference(Key::INSERT)); default_builtin_cache.insert("ui_text_toggle_insert_mode", inputs); -- cgit v1.2.3