From: Ray Strode Date: Wed, 28 May 2008 21:16:57 +0000 (-0400) Subject: Add ctrl-u and ctrl-w to erase password line X-Git-Tag: 0.1.0~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f79086021c15fdec555d41ee1283506d74beccc;p=thirdparty%2Fplymouth.git Add ctrl-u and ctrl-w to erase password line 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. --- diff --git a/src/ply-window.c b/src/ply-window.c index 747fa3ee..a3dc8891 100644 --- a/src/ply-window.c +++ b/src/ply-window.c @@ -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 ();