[RFC 2/3] readline: add ctrl-w handling (cut-the-last-word)
Antony Pavlov
antonynpavlov at gmail.com
Fri Oct 26 01:58:54 EDT 2012
Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
---
lib/readline.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/lib/readline.c b/lib/readline.c
index 086b7f1..37566c3 100644
--- a/lib/readline.c
+++ b/lib/readline.c
@@ -328,6 +328,16 @@ int readline(const char *prompt, char *buf, int len)
REFRESH_TO_EOL();
continue;
}
+ case CTL_CH('w'):
+ while ((num >= 1) && (buf[num - 1] == ' ')) {
+ DO_BACKSPACE();
+ }
+
+ while ((num >= 1) && (buf[num - 1] != ' ')) {
+ DO_BACKSPACE();
+ }
+
+ break;
default:
if (isascii(ichar) && isprint(ichar))
cread_add_char(ichar, insert, &num, &eol_num, buf, len);
--
1.7.10.4
More information about the barebox
mailing list