feat(text_box): add CTRL+<backspace> and CTRL+<delete> keybinds (delete left/right word) (#353)
This commit is contained in:
parent
32cab6eef6
commit
40a54654dc
1 changed files with 15 additions and 0 deletions
|
|
@ -935,6 +935,19 @@ where
|
||||||
editor.action(Action::Motion(motion));
|
editor.action(Action::Motion(motion));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pre-select word for CTRL+<backspace> and CTRL+<delete>
|
||||||
|
fn delete_modifiers(
|
||||||
|
editor: &mut BorrowedWithFontSystem<'_, ViEditor<'static, 'static>>,
|
||||||
|
motion_to_apply: Motion,
|
||||||
|
modifiers: Modifiers,
|
||||||
|
) {
|
||||||
|
if modifiers.control() && editor.selection() == Selection::None {
|
||||||
|
let cursor = editor.cursor();
|
||||||
|
editor.set_selection(Selection::Normal(cursor));
|
||||||
|
editor.action(Action::Motion(motion_to_apply));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mut status = Status::Ignored;
|
let mut status = Status::Ignored;
|
||||||
match event {
|
match event {
|
||||||
Event::Keyboard(KeyEvent::KeyPressed {
|
Event::Keyboard(KeyEvent::KeyPressed {
|
||||||
|
|
@ -983,10 +996,12 @@ where
|
||||||
status = Status::Captured;
|
status = Status::Captured;
|
||||||
}
|
}
|
||||||
Named::Backspace => {
|
Named::Backspace => {
|
||||||
|
delete_modifiers(&mut editor, Motion::LeftWord, modifiers);
|
||||||
editor.action(Action::Backspace);
|
editor.action(Action::Backspace);
|
||||||
status = Status::Captured;
|
status = Status::Captured;
|
||||||
}
|
}
|
||||||
Named::Delete => {
|
Named::Delete => {
|
||||||
|
delete_modifiers(&mut editor, Motion::RightWord, modifiers);
|
||||||
editor.action(Action::Delete);
|
editor.action(Action::Delete);
|
||||||
status = Status::Captured;
|
status = Status::Captured;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue