diff --git a/LibGUI/GTextEditor.cpp b/LibGUI/GTextEditor.cpp index f3d877eb261..0d33b408bd2 100644 --- a/LibGUI/GTextEditor.cpp +++ b/LibGUI/GTextEditor.cpp @@ -379,6 +379,11 @@ void GTextEditor::keydown_event(GKeyEvent& event) return; } + if (event.modifiers() == Mod_Shift && event.key() == KeyCode::Key_Delete) { + delete_current_line(); + return; + } + if (event.key() == KeyCode::Key_Delete) { do_delete(); return; @@ -390,12 +395,24 @@ void GTextEditor::keydown_event(GKeyEvent& event) return GWidget::keydown_event(event); } +void GTextEditor::delete_current_line() +{ + if (has_selection()) + return delete_selection(); + + m_lines.remove(m_cursor.line()); + if (m_lines.is_empty()) + m_lines.append(make()); + + update_content_size(); + update(); +} + void GTextEditor::do_delete() { - if (has_selection()) { - delete_selection(); - return; - } + if (has_selection()) + return delete_selection(); + if (m_cursor.column() < current_line().length()) { // Delete within line current_line().remove(m_cursor.column()); diff --git a/LibGUI/GTextEditor.h b/LibGUI/GTextEditor.h index 9e5b88cf74e..abc529b76f4 100644 --- a/LibGUI/GTextEditor.h +++ b/LibGUI/GTextEditor.h @@ -94,6 +94,7 @@ public: void copy(); void paste(); void do_delete(); + void delete_current_line(); Function on_return_pressed; Function on_escape_pressed;