EditingEngine: Split selection from movement functions

This patch moves selection updates outside movement functions in
EditingEngine.  Previously, movement functions would automatically
update the selection based on whether the Shift key was pressed down
during movement.  However, not all EditingEngine subclasses want that;
VimEditingEngine being a good example (because all selection is handled
in visual mode).

Therefore, this patch moves all selection updating to
EditingEngine::on_key().  Subclasses wishing to provide custom movement
and selection semantics should override it (and VimEditingEngine already
does).
This commit is contained in:
sin-ack 2021-04-26 20:29:05 +00:00 committed by Andreas Kling
commit d6dc81874d
Notes: sideshowbarker 2024-07-18 19:02:58 +09:00
6 changed files with 72 additions and 68 deletions

View file

@ -920,7 +920,7 @@ void TextEditor::reset_cursor_blink()
start_timer(500);
}
void TextEditor::toggle_selection_if_needed_for_event(bool is_selecting)
void TextEditor::update_selection(bool is_selecting)
{
if (is_selecting && !selection()->is_valid()) {
selection()->set(cursor(), {});