Repository: osa1/tiny (language: rust)

Issue:
input_delete_to_start
As seen in https://github.com/osa1/tiny/pull/328, there is no function to emulate term ``C-u``
Maybe duplicate of https://github.com/osa1/tiny/issues/300 ?


Discussion / hints:
#382 is merged and we now have a `input_delete_to_end` action. Perhaps we can also implement this. @trevarj do you see any problems with this? It's fine if by default we don't have a binding for it.
It should be an easy addition. I will have a look later

Fix patch:
diff --git a/crates/libtiny_tui/src/input_area/mod.rs b/crates/libtiny_tui/src/input_area/mod.rs
index 8d92f4f8..a044c77f 100644
--- a/crates/libtiny_tui/src/input_area/mod.rs
+++ b/crates/libtiny_tui/src/input_area/mod.rs
@@ -260,6 +260,14 @@ impl InputArea {
                 self.move_cursor_to_end();
                 WidgetRet::KeyHandled
             }
+            KeyAction::InputDeleteToStart => {
+                if self.cursor != 0 {
+                    self.modify();
+                    self.buffer.drain(..self.cursor as usize);
+                    self.move_cursor(0);
+                }
+                WidgetRet::KeyHandled
+            }
             KeyAction::InputDeleteToEnd => {
                 if self.cursor != self.current_buffer_len() {
                     self.modify();
diff --git a/crates/libtiny_tui/src/key_map.rs b/crates/libtiny_tui/src/key_map.rs
index e4c931a4..9b571163 100644
--- a/crates/libtiny_tui/src/key_map.rs
+++ b/crates/libtiny_tui/src/key_map.rs
@@ -37,6 +37,7 @@ pub(crate) enum KeyAction {
     InputSend,
     InputDeletePrevChar,
     InputDeleteNextChar,
+    InputDeleteToStart,
     InputDeleteToEnd,
     InputDeletePrevWord,
     InputMoveCursEnd,
@@ -72,6 +73,7 @@ impl Display for KeyAction {
             KeyAction::InputSend => "input_send",
             KeyAction::InputDeletePrevChar => "input_delete_prev_char",
             KeyAction::InputDeleteNextChar => "input_delete_next_char",
+            KeyAction::InputDeleteToStart => "input_delete_to_start",
             KeyAction::InputDeleteToEnd => "input_delete_to_end",
             KeyAction::InputDeletePrevWord => "input_delete_prev_word",
             KeyAction::InputMoveCursEnd => "input_move_curs_end",


Test patch: