mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:08:12 +00:00
GTextEditor: Shift+Delete should delete the current line.
This commit is contained in:
parent
fceeb9b695
commit
838a06096a
2 changed files with 22 additions and 4 deletions
|
@ -379,6 +379,11 @@ void GTextEditor::keydown_event(GKeyEvent& event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.modifiers() == Mod_Shift && event.key() == KeyCode::Key_Delete) {
|
||||||
|
delete_current_line();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (event.key() == KeyCode::Key_Delete) {
|
if (event.key() == KeyCode::Key_Delete) {
|
||||||
do_delete();
|
do_delete();
|
||||||
return;
|
return;
|
||||||
|
@ -390,12 +395,24 @@ void GTextEditor::keydown_event(GKeyEvent& event)
|
||||||
return GWidget::keydown_event(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<Line>());
|
||||||
|
|
||||||
|
update_content_size();
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
void GTextEditor::do_delete()
|
void GTextEditor::do_delete()
|
||||||
{
|
{
|
||||||
if (has_selection()) {
|
if (has_selection())
|
||||||
delete_selection();
|
return delete_selection();
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (m_cursor.column() < current_line().length()) {
|
if (m_cursor.column() < current_line().length()) {
|
||||||
// Delete within line
|
// Delete within line
|
||||||
current_line().remove(m_cursor.column());
|
current_line().remove(m_cursor.column());
|
||||||
|
|
|
@ -94,6 +94,7 @@ public:
|
||||||
void copy();
|
void copy();
|
||||||
void paste();
|
void paste();
|
||||||
void do_delete();
|
void do_delete();
|
||||||
|
void delete_current_line();
|
||||||
|
|
||||||
Function<void(GTextEditor&)> on_return_pressed;
|
Function<void(GTextEditor&)> on_return_pressed;
|
||||||
Function<void(GTextEditor&)> on_escape_pressed;
|
Function<void(GTextEditor&)> on_escape_pressed;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue