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.
This commit is contained in:
Ray Strode 2008-05-28 17:16:57 -04:00
parent 93ff1b7882
commit 8f79086021

View 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 ();