]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
Add ctrl-u and ctrl-w to erase password line
authorRay Strode <rstrode@redhat.com>
Wed, 28 May 2008 21:16:57 +0000 (17:16 -0400)
committerRay Strode <rstrode@redhat.com>
Wed, 28 May 2008 21:16:57 +0000 (17:16 -0400)
Right now we do it in the cheesiest way possible, by
calling the backspace function over and over again on
behalf of the user.  It might make more sense to export
another window callback specifically for erase line. It
probably doesn't make sense to do that until we fix the
TODO item:

- have plugins hook into line editing through window
  directly, instead of via vtable functions

though.

src/ply-window.c

index 747fa3ee9e99734bba544f2b81544bc7603c9de0..a3dc8891d883114a6662ca316d0b48559be507df 100644 (file)
@@ -44,6 +44,8 @@
 #include "ply-utils.h"
 
 #define KEY_CTRL_T ('\100' ^'T')
+#define KEY_CTRL_U ('\100' ^'U')
+#define KEY_CTRL_W ('\100' ^'W')
 #define KEY_CTRL_V ('\100' ^'V')
 #define KEY_ESCAPE ('\100' ^'[')
 #define KEY_RETURN '\r'
@@ -118,6 +120,15 @@ process_backspace (ply_window_t *window)
     }
 }
 
+static void
+process_line_erase (ply_window_t *window)
+{
+  size_t size;
+
+  while ((size = ply_buffer_get_size (window->line_buffer)) > 0)
+    process_backspace (window);
+}
+
 static void
 process_keyboard_input (ply_window_t *window,
                         const char   *keyboard_input,
@@ -136,6 +147,12 @@ process_keyboard_input (ply_window_t *window,
             ply_trace ("text mode toggled!");
           return;
 
+          case KEY_CTRL_U:
+          case KEY_CTRL_W:
+            ply_trace ("erase line!");
+            process_line_erase (window);
+          return;
+
           case KEY_CTRL_V:
             ply_trace ("toggle verbose mode!");
             ply_toggle_tracing ();