mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:17:35 +00:00
LibGUI: Add Ctrl-U to insert mode
While under insert mode, Ctrl-U deletes all characters between the first non-blank character of the line and the cursor. Implement delete_from_line_start_to_cursor() in TextEditor. Then, call the method in VimEditingEngine via its pointer to an instance of TextEditor.
This commit is contained in:
parent
8230bf8944
commit
54bf6a7884
3 changed files with 11 additions and 0 deletions
|
@ -928,6 +928,13 @@ void TextEditor::delete_previous_char()
|
||||||
execute<RemoveTextCommand>(document().text_in_range(to_erase), to_erase);
|
execute<RemoveTextCommand>(document().text_in_range(to_erase), to_erase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextEditor::delete_from_line_start_to_cursor()
|
||||||
|
{
|
||||||
|
TextPosition start(m_cursor.line(), current_line().first_non_whitespace_column());
|
||||||
|
TextRange to_erase(start, m_cursor);
|
||||||
|
execute<RemoveTextCommand>(document().text_in_range(to_erase), to_erase);
|
||||||
|
}
|
||||||
|
|
||||||
void TextEditor::do_delete()
|
void TextEditor::do_delete()
|
||||||
{
|
{
|
||||||
if (!is_editable())
|
if (!is_editable())
|
||||||
|
|
|
@ -137,6 +137,7 @@ public:
|
||||||
void delete_current_line();
|
void delete_current_line();
|
||||||
void delete_previous_word();
|
void delete_previous_word();
|
||||||
void delete_previous_char();
|
void delete_previous_char();
|
||||||
|
void delete_from_line_start_to_cursor();
|
||||||
void select_all();
|
void select_all();
|
||||||
virtual void undo();
|
virtual void undo();
|
||||||
virtual void redo();
|
virtual void redo();
|
||||||
|
|
|
@ -802,6 +802,9 @@ bool VimEditingEngine::on_key_in_insert_mode(const KeyEvent& event)
|
||||||
case KeyCode::Key_H:
|
case KeyCode::Key_H:
|
||||||
m_editor->delete_previous_char();
|
m_editor->delete_previous_char();
|
||||||
return true;
|
return true;
|
||||||
|
case KeyCode::Key_U:
|
||||||
|
m_editor->delete_from_line_start_to_cursor();
|
||||||
|
return true;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue