summary refs log tree commit diff stats
path: root/util/readline.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2014-06-11 21:34:08 +0100
committerPeter Maydell <peter.maydell@linaro.org>2014-06-11 21:34:08 +0100
commit05fedeef835c3c889e5d2e44f8abb11dcfcadefc (patch)
tree8dbcf074dec8246cb542e68f6b84c7abf5176e50 /util/readline.c
parent706808585a49bfd266e00b1c7723b6e1b0f4ff35 (diff)
parenta491af471bf8f1188b2665f54d109065d4591e45 (diff)
downloadfocaccia-qemu-05fedeef835c3c889e5d2e44f8abb11dcfcadefc.tar.gz
focaccia-qemu-05fedeef835c3c889e5d2e44f8abb11dcfcadefc.zip
Merge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into staging
* remotes/qmp-unstable/queue/qmp:
  json-parser: drop superfluous assignment for token variable
  readline: Clear screen on form feed.
  monitor: Add delvm and loadvm argument completion
  monitor: Add host_net_remove arguments completion
  readline: Make completion strings always unique
  monitor: Add host_net_add device argument completion
  net: Export valid host network devices list
  monitor: Add migrate_set_capability completion
  monitor: Add watchdog_action argument completion
  monitor: Add ringbuf_write and ringbuf_read argument completion
  dump: simplify get_len_buf_out()
  dump: hoist lzo_init() from get_len_buf_out() to dump_init()
  dump: select header bitness based on ELF class, not ELF architecture
  dump: eliminate DumpState.page_size ("guest's page size")
  dump: eliminate DumpState.page_shift ("guest's page shift")
  dump: simplify write_start_flat_header()
  dump: fill in the flat header signature more pleasingly to the eye

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'util/readline.c')
-rw-r--r--util/readline.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/util/readline.c b/util/readline.c
index 8baec55509..cc1302ac0a 100644
--- a/util/readline.c
+++ b/util/readline.c
@@ -263,6 +263,12 @@ static void readline_hist_add(ReadLineState *rs, const char *cmdline)
 void readline_add_completion(ReadLineState *rs, const char *str)
 {
     if (rs->nb_completions < READLINE_MAX_COMPLETIONS) {
+        int i;
+        for (i = 0; i < rs->nb_completions; i++) {
+            if (!strcmp(rs->completions[i], str)) {
+                return;
+            }
+        }
         rs->completions[rs->nb_completions++] = g_strdup(str);
     }
 }
@@ -345,6 +351,12 @@ static void readline_completion(ReadLineState *rs)
     }
 }
 
+static void readline_clear_screen(ReadLineState *rs)
+{
+    rs->printf_func(rs->opaque, "\033[2J\033[1;1H");
+    readline_show_prompt(rs);
+}
+
 /* return true if command handled */
 void readline_handle_byte(ReadLineState *rs, int ch)
 {
@@ -363,6 +375,9 @@ void readline_handle_byte(ReadLineState *rs, int ch)
         case 9:
             readline_completion(rs);
             break;
+        case 12:
+            readline_clear_screen(rs);
+            break;
         case 10:
         case 13:
             rs->cmd_buf[rs->cmd_buf_size] = '\0';