From 8f79086021c15fdec555d41ee1283506d74beccc Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Wed, 28 May 2008 17:16:57 -0400 Subject: [PATCH] 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. --- src/ply-window.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 ();