From 5dda234aa2265f46f5b6e8d0d375de168e2e8342 Mon Sep 17 00:00:00 2001 From: Alex Pasmantier Date: Sat, 12 Apr 2025 23:05:03 +0200 Subject: [PATCH] feat(input): add action to delete input line --- television/action.rs | 3 +++ television/app.rs | 1 + television/input.rs | 1 + television/television.rs | 2 ++ 4 files changed, 7 insertions(+) diff --git a/television/action.rs b/television/action.rs index 4b16afb..1356971 100644 --- a/television/action.rs +++ b/television/action.rs @@ -18,6 +18,9 @@ pub enum Action { /// Delete the character after the cursor from the input buffer. #[serde(skip)] DeleteNextChar, + /// Delete the current line from the input buffer. + #[serde(skip)] + DeleteLine, /// Move the cursor to the character before the current cursor position. #[serde(skip)] GoToPrevChar, diff --git a/television/app.rs b/television/app.rs index 524bbb1..81fea6d 100644 --- a/television/app.rs +++ b/television/app.rs @@ -297,6 +297,7 @@ impl App { match keycode { Key::Backspace => Action::DeletePrevChar, Key::Ctrl('w') => Action::DeletePrevWord, + Key::Ctrl('u') => Action::DeleteLine, Key::Delete => Action::DeleteNextChar, Key::Left => Action::GoToPrevChar, Key::Right => Action::GoToNextChar, diff --git a/television/input.rs b/television/input.rs index 65b81ad..765bb7f 100644 --- a/television/input.rs +++ b/television/input.rs @@ -9,6 +9,7 @@ pub fn convert_action_to_input_request( Action::DeletePrevChar => Some(InputRequest::DeletePrevChar), Action::DeletePrevWord => Some(InputRequest::DeletePrevWord), Action::DeleteNextChar => Some(InputRequest::DeleteNextChar), + Action::DeleteLine => Some(InputRequest::DeleteLine), Action::GoToPrevChar => Some(InputRequest::GoToPrevChar), Action::GoToNextChar => Some(InputRequest::GoToNextChar), Action::GoToInputStart => Some(InputRequest::GoToStart), diff --git a/television/television.rs b/television/television.rs index d0f90a0..d140ca8 100644 --- a/television/television.rs +++ b/television/television.rs @@ -428,6 +428,7 @@ impl Television { Action::AddInputChar(_) | Action::DeletePrevChar | Action::DeletePrevWord + | Action::DeleteLine | Action::DeleteNextChar => { let new_pattern = input.value().to_string(); if new_pattern != self.current_pattern { @@ -552,6 +553,7 @@ impl Television { | Action::DeletePrevChar | Action::DeletePrevWord | Action::DeleteNextChar + | Action::DeleteLine | Action::GoToInputEnd | Action::GoToInputStart | Action::GoToNextChar