qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2 16/17] monitor: Add mouse_set index argument comp


From: Hani Benhabiles
Subject: [Qemu-devel] [PATCH v2 16/17] monitor: Add mouse_set index argument completion.
Date: Sun, 30 Mar 2014 11:58:38 +0100

Signed-off-by: Hani Benhabiles <address@hidden>
---
 hmp-commands.hx |  1 +
 hmp.h           |  1 +
 monitor.c       | 22 ++++++++++++++++++++++
 3 files changed, 24 insertions(+)

diff --git a/hmp-commands.hx b/hmp-commands.hx
index b41a6d6..04aa059 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -734,6 +734,7 @@ ETEXI
         .params     = "index",
         .help       = "set which mouse device receives events",
         .mhandler.cmd = do_mouse_set,
+        .command_completion = mouse_set_completion,
     },
 
 STEXI
diff --git a/hmp.h b/hmp.h
index 12f0364..6e76473 100644
--- a/hmp.h
+++ b/hmp.h
@@ -112,5 +112,6 @@ void migrate_set_capability_completion(ReadLineState *rs, 
int nb_args,
 void host_net_add_completion(ReadLineState *rs, int nb_args, const char *str);
 void host_net_remove_completion(ReadLineState *rs, int nb_args,
                                 const char *str);
+void mouse_set_completion(ReadLineState *rs, int nb_args, const char *str);
 
 #endif
diff --git a/monitor.c b/monitor.c
index 9781ee2..385fb70 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4657,6 +4657,28 @@ void host_net_remove_completion(ReadLineState *rs, int 
nb_args, const char *str)
     }
 }
 
+void mouse_set_completion(ReadLineState *rs, int nb_args, const char *str)
+{
+    size_t len;
+    MouseInfoList *mice_list, *mouse;
+    if (nb_args != 2) {
+        return;
+    }
+    len = strlen(str);
+    readline_set_completion_index(rs, len);
+    mice_list = mouse = qmp_query_mice(NULL);
+    while (mouse) {
+        char name[16];
+        snprintf(name, sizeof(name), "%" PRId64, mouse->value->index);
+
+        if (!strncmp(str, name, len)) {
+            readline_add_completion(rs, name);
+        }
+        mouse = mouse->next;
+    }
+    qapi_free_MouseInfoList(mice_list);
+}
+
 static void monitor_find_completion_by_table(Monitor *mon,
                                              const mon_cmd_t *cmd_table,
                                              char **args,
-- 
1.8.3.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]