mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:07:35 +00:00
LibGUI: Add Ctrl-W to insert mode
In Vim's insert mode, Ctrl-W deletes the word before the cursor, like Ctrl-Backspace. Unlike Ctrl-Backspace, if only whitespace exists between the end of the word and the cursor, the word will be deleted with the whitespace. To do so, this commit introduces two methods: delete_previous_word() for TextEditor and first_word_before() for TextDocument, where the former depends on the latter. delete_previous_word() is then called in VimEditingEngine.
This commit is contained in:
parent
8f01a8b741
commit
808e5e813f
5 changed files with 52 additions and 0 deletions
|
@ -883,6 +883,12 @@ void TextEditor::keydown_event(KeyEvent& event)
|
|||
event.ignore();
|
||||
}
|
||||
|
||||
void TextEditor::delete_previous_word()
|
||||
{
|
||||
TextRange to_erase(document().first_word_before(m_cursor, true), m_cursor);
|
||||
execute<RemoveTextCommand>(document().text_in_range(to_erase), to_erase);
|
||||
}
|
||||
|
||||
void TextEditor::delete_current_line()
|
||||
{
|
||||
if (has_selection())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue