diff options
-rw-r--r-- | Userland/Libraries/LibGUI/EditingEngine.cpp | 72 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/TextEditor.cpp | 12 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/TextEditor.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/VimEditingEngine.cpp | 6 |
4 files changed, 46 insertions, 46 deletions
diff --git a/Userland/Libraries/LibGUI/EditingEngine.cpp b/Userland/Libraries/LibGUI/EditingEngine.cpp index c503514fa0..051d6e5b6c 100644 --- a/Userland/Libraries/LibGUI/EditingEngine.cpp +++ b/Userland/Libraries/LibGUI/EditingEngine.cpp @@ -40,9 +40,9 @@ void EditingEngine::detach() bool EditingEngine::on_key(const KeyEvent& event) { if (event.key() == KeyCode::Key_Left) { - if (!event.shift() && m_editor->selection()->is_valid()) { - m_editor->set_cursor(m_editor->selection()->normalized().start()); - m_editor->selection()->clear(); + if (!event.shift() && m_editor->selection().is_valid()) { + m_editor->set_cursor(m_editor->selection().normalized().start()); + m_editor->selection().clear(); m_editor->did_update_selection(); if (!event.ctrl()) { m_editor->update(); @@ -52,25 +52,25 @@ bool EditingEngine::on_key(const KeyEvent& event) if (event.ctrl()) { m_editor->update_selection(event.shift()); move_to_previous_span(); - if (event.shift() && m_editor->selection()->start().is_valid()) { - m_editor->selection()->set_end(m_editor->cursor()); + if (event.shift() && m_editor->selection().start().is_valid()) { + m_editor->selection().set_end(m_editor->cursor()); m_editor->did_update_selection(); } return true; } m_editor->update_selection(event.shift()); move_one_left(); - if (event.shift() && m_editor->selection()->start().is_valid()) { - m_editor->selection()->set_end(m_editor->cursor()); + if (event.shift() && m_editor->selection().start().is_valid()) { + m_editor->selection().set_end(m_editor->cursor()); m_editor->did_update_selection(); } return true; } if (event.key() == KeyCode::Key_Right) { - if (!event.shift() && m_editor->selection()->is_valid()) { - m_editor->set_cursor(m_editor->selection()->normalized().end()); - m_editor->selection()->clear(); + if (!event.shift() && m_editor->selection().is_valid()) { + m_editor->set_cursor(m_editor->selection().normalized().end()); + m_editor->selection().clear(); m_editor->did_update_selection(); if (!event.ctrl()) { m_editor->update(); @@ -80,16 +80,16 @@ bool EditingEngine::on_key(const KeyEvent& event) if (event.ctrl()) { m_editor->update_selection(event.shift()); move_to_next_span(event); - if (event.shift() && m_editor->selection()->start().is_valid()) { - m_editor->selection()->set_end(m_editor->cursor()); + if (event.shift() && m_editor->selection().start().is_valid()) { + m_editor->selection().set_end(m_editor->cursor()); m_editor->did_update_selection(); } return true; } m_editor->update_selection(event.shift()); move_one_right(); - if (event.shift() && m_editor->selection()->start().is_valid()) { - m_editor->selection()->set_end(m_editor->cursor()); + if (event.shift() && m_editor->selection().start().is_valid()) { + m_editor->selection().set_end(m_editor->cursor()); m_editor->did_update_selection(); } return true; @@ -100,8 +100,8 @@ bool EditingEngine::on_key(const KeyEvent& event) m_editor->update_selection(event.shift()); } move_one_up(event); - if (event.shift() && m_editor->selection()->start().is_valid()) { - m_editor->selection()->set_end(m_editor->cursor()); + if (event.shift() && m_editor->selection().start().is_valid()) { + m_editor->selection().set_end(m_editor->cursor()); m_editor->did_update_selection(); } return true; @@ -112,8 +112,8 @@ bool EditingEngine::on_key(const KeyEvent& event) m_editor->update_selection(event.shift()); } move_one_down(event); - if (event.shift() && m_editor->selection()->start().is_valid()) { - m_editor->selection()->set_end(m_editor->cursor()); + if (event.shift() && m_editor->selection().start().is_valid()) { + m_editor->selection().set_end(m_editor->cursor()); m_editor->did_update_selection(); } return true; @@ -122,15 +122,15 @@ bool EditingEngine::on_key(const KeyEvent& event) if (event.key() == KeyCode::Key_Home) { if (event.ctrl()) { move_to_first_line(); - if (event.shift() && m_editor->selection()->start().is_valid()) { - m_editor->selection()->set_end(m_editor->cursor()); + if (event.shift() && m_editor->selection().start().is_valid()) { + m_editor->selection().set_end(m_editor->cursor()); m_editor->did_update_selection(); } } else { m_editor->update_selection(event.shift()); move_to_line_beginning(); - if (event.shift() && m_editor->selection()->start().is_valid()) { - m_editor->selection()->set_end(m_editor->cursor()); + if (event.shift() && m_editor->selection().start().is_valid()) { + m_editor->selection().set_end(m_editor->cursor()); m_editor->did_update_selection(); } } @@ -140,15 +140,15 @@ bool EditingEngine::on_key(const KeyEvent& event) if (event.key() == KeyCode::Key_End) { if (event.ctrl()) { move_to_last_line(); - if (event.shift() && m_editor->selection()->start().is_valid()) { - m_editor->selection()->set_end(m_editor->cursor()); + if (event.shift() && m_editor->selection().start().is_valid()) { + m_editor->selection().set_end(m_editor->cursor()); m_editor->did_update_selection(); } } else { m_editor->update_selection(event.shift()); move_to_line_end(); - if (event.shift() && m_editor->selection()->start().is_valid()) { - m_editor->selection()->set_end(m_editor->cursor()); + if (event.shift() && m_editor->selection().start().is_valid()) { + m_editor->selection().set_end(m_editor->cursor()); m_editor->did_update_selection(); } } @@ -160,8 +160,8 @@ bool EditingEngine::on_key(const KeyEvent& event) m_editor->update_selection(event.shift()); } move_page_up(); - if (event.shift() && m_editor->selection()->start().is_valid()) { - m_editor->selection()->set_end(m_editor->cursor()); + if (event.shift() && m_editor->selection().start().is_valid()) { + m_editor->selection().set_end(m_editor->cursor()); m_editor->did_update_selection(); } return true; @@ -172,8 +172,8 @@ bool EditingEngine::on_key(const KeyEvent& event) m_editor->update_selection(event.shift()); } move_page_down(); - if (event.shift() && m_editor->selection()->start().is_valid()) { - m_editor->selection()->set_end(m_editor->cursor()); + if (event.shift() && m_editor->selection().start().is_valid()) { + m_editor->selection().set_end(m_editor->cursor()); m_editor->did_update_selection(); } return true; @@ -240,8 +240,8 @@ void EditingEngine::move_to_next_span(const KeyEvent& event) new_cursor = m_editor->document().first_word_break_after(m_editor->cursor()); } m_editor->set_cursor(new_cursor); - if (event.shift() && m_editor->selection()->start().is_valid()) { - m_editor->selection()->set_end(m_editor->cursor()); + if (event.shift() && m_editor->selection().start().is_valid()) { + m_editor->selection().set_end(m_editor->cursor()); m_editor->did_update_selection(); } } @@ -654,8 +654,8 @@ void EditingEngine::move_selected_lines_up() m_editor->set_cursor({ first_line - 1, 0 }); if (m_editor->has_selection()) { - m_editor->selection()->set_start({ first_line - 1, 0 }); - m_editor->selection()->set_end({ last_line - 1, m_editor->line(last_line - 1).length() }); + m_editor->selection().set_start({ first_line - 1, 0 }); + m_editor->selection().set_end({ last_line - 1, m_editor->line(last_line - 1).length() }); } m_editor->did_change(); @@ -679,8 +679,8 @@ void EditingEngine::move_selected_lines_down() m_editor->set_cursor({ first_line + 1, 0 }); if (m_editor->has_selection()) { - m_editor->selection()->set_start({ first_line + 1, 0 }); - m_editor->selection()->set_end({ last_line + 1, m_editor->line(last_line + 1).length() }); + m_editor->selection().set_start({ first_line + 1, 0 }); + m_editor->selection().set_end({ last_line + 1, m_editor->line(last_line + 1).length() }); } m_editor->did_change(); diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp index 425da4e01b..be59ba00eb 100644 --- a/Userland/Libraries/LibGUI/TextEditor.cpp +++ b/Userland/Libraries/LibGUI/TextEditor.cpp @@ -990,20 +990,20 @@ void TextEditor::reset_cursor_blink() void TextEditor::update_selection(bool is_selecting) { - if (is_selecting && !selection()->is_valid()) { - selection()->set(cursor(), {}); + if (is_selecting && !selection().is_valid()) { + selection().set(cursor(), {}); did_update_selection(); update(); return; } - if (!is_selecting && selection()->is_valid()) { - selection()->clear(); + if (!is_selecting && selection().is_valid()) { + selection().clear(); did_update_selection(); update(); return; } - if (is_selecting && selection()->start().is_valid()) { - selection()->set_end(cursor()); + if (is_selecting && selection().start().is_valid()) { + selection().set_end(cursor()); did_update_selection(); update(); return; diff --git a/Userland/Libraries/LibGUI/TextEditor.h b/Userland/Libraries/LibGUI/TextEditor.h index c291e38c49..f783d29b51 100644 --- a/Userland/Libraries/LibGUI/TextEditor.h +++ b/Userland/Libraries/LibGUI/TextEditor.h @@ -193,7 +193,7 @@ public: bool is_in_drag_select() const { return m_in_drag_select; } - TextRange* selection() { return &m_selection; }; + TextRange& selection() { return m_selection; }; void did_update_selection(); void did_change(AllowCallback = AllowCallback::Yes); void update_cursor(); diff --git a/Userland/Libraries/LibGUI/VimEditingEngine.cpp b/Userland/Libraries/LibGUI/VimEditingEngine.cpp index 5082a4eb22..2b991c47ae 100644 --- a/Userland/Libraries/LibGUI/VimEditingEngine.cpp +++ b/Userland/Libraries/LibGUI/VimEditingEngine.cpp @@ -1242,7 +1242,7 @@ void VimEditingEngine::switch_to_visual_mode() m_editor->reset_cursor_blink(); m_previous_key = {}; m_selection_start_position = m_editor->cursor(); - m_editor->selection()->set(m_editor->cursor(), { m_editor->cursor().line(), m_editor->cursor().column() + 1 }); + m_editor->selection().set(m_editor->cursor(), { m_editor->cursor().line(), m_editor->cursor().column() + 1 }); m_editor->did_update_selection(); m_motion.reset(); } @@ -1260,7 +1260,7 @@ void VimEditingEngine::update_selection_on_cursor_move() end.set_column(end.column() + 1); } - m_editor->selection()->set(start, end); + m_editor->selection().set(start, end); m_editor->did_update_selection(); } @@ -1276,7 +1276,7 @@ void VimEditingEngine::clamp_cursor_position() void VimEditingEngine::clear_visual_mode_data() { if (m_editor->has_selection()) { - m_editor->selection()->clear(); + m_editor->selection().clear(); m_editor->did_update_selection(); clamp_cursor_position(); } |