feat(input): bind ctrl-w to delete previous word (#150)

Fixes #135
This commit is contained in:
Alex Pasmantier 2024-12-28 16:25:19 +01:00 committed by GitHub
parent 557686e197
commit 12fdf94e5d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 6 additions and 0 deletions

View File

@ -10,6 +10,9 @@ pub enum Action {
/// Delete the character before the cursor from the input buffer.
#[serde(skip)]
DeletePrevChar,
/// Delete the previous word from the input buffer.
#[serde(skip)]
DeletePrevWord,
/// Delete the character after the cursor from the input buffer.
#[serde(skip)]
DeleteNextChar,

View File

@ -195,6 +195,7 @@ impl App {
// text input events
match keycode {
Key::Backspace => return Action::DeletePrevChar,
Key::Ctrl('w') => return Action::DeletePrevWord,
Key::Delete => return Action::DeleteNextChar,
Key::Left => return Action::GoToPrevChar,
Key::Right => return Action::GoToNextChar,

View File

@ -7,6 +7,7 @@ pub fn convert_action_to_input_request(
match action {
Action::AddInputChar(c) => Some(InputRequest::InsertChar(*c)),
Action::DeletePrevChar => Some(InputRequest::DeletePrevChar),
Action::DeletePrevWord => Some(InputRequest::DeletePrevWord),
Action::DeleteNextChar => Some(InputRequest::DeleteNextChar),
Action::GoToPrevChar => Some(InputRequest::GoToPrevChar),
Action::GoToNextChar => Some(InputRequest::GoToNextChar),

View File

@ -264,6 +264,7 @@ impl Television {
// handle input actions
Action::AddInputChar(_)
| Action::DeletePrevChar
| Action::DeletePrevWord
| Action::DeleteNextChar
| Action::GoToInputEnd
| Action::GoToInputStart