aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>2007-06-25 11:36:50 +0000
committerths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>2007-06-25 11:36:50 +0000
commit33fa11d4b53dcda0f71929a60d60e51ad46e926d (patch)
treed29f9d9e6f5bbd7c5402a2790fb78e21441211a1
parent31211df14dd887cd9976722dd527a4b592dd5a07 (diff)
Implement ^W in readline.c, by Michal Hanselmann.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3016 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r--readline.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/readline.c b/readline.c
index cbe33dbdd8..25572dd02d 100644
--- a/readline.c
+++ b/readline.c
@@ -156,6 +156,45 @@ static void term_backspace(void)
}
}
+static void term_backword(void)
+{
+ int start;
+
+ if (term_cmd_buf_index == 0 || term_cmd_buf_index > term_cmd_buf_size) {
+ return;
+ }
+
+ start = term_cmd_buf_index - 1;
+
+ /* find first word (backwards) */
+ while (start > 0) {
+ if (!isspace(term_cmd_buf[start])) {
+ break;
+ }
+
+ --start;
+ }
+
+ /* find first space (backwards) */
+ while (start > 0) {
+ if (isspace(term_cmd_buf[start])) {
+ ++start;
+ break;
+ }
+
+ --start;
+ }
+
+ /* remove word */
+ if (start < term_cmd_buf_index) {
+ memmove(term_cmd_buf + start,
+ term_cmd_buf + term_cmd_buf_index,
+ term_cmd_buf_size - term_cmd_buf_index);
+ term_cmd_buf_size -= term_cmd_buf_index - start;
+ term_cmd_buf_index = start;
+ }
+}
+
static void term_bol(void)
{
term_cmd_buf_index = 0;
@@ -338,6 +377,10 @@ void readline_handle_byte(int ch)
/* NOTE: readline_start can be called here */
term_readline_func(term_readline_opaque, term_cmd_buf);
break;
+ case 23:
+ /* ^W */
+ term_backword();
+ break;
case 27:
term_esc_state = IS_ESC;
break;