From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34742) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUDSV-0000E6-FB for qemu-devel@nongnu.org; Sun, 30 Mar 2014 06:59:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WUDSP-0003aH-Gb for qemu-devel@nongnu.org; Sun, 30 Mar 2014 06:59:23 -0400 Received: from mail-ee0-x235.google.com ([2a00:1450:4013:c00::235]:41411) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUDSP-0003a7-9O for qemu-devel@nongnu.org; Sun, 30 Mar 2014 06:59:17 -0400 Received: by mail-ee0-f53.google.com with SMTP id b57so5585176eek.40 for ; Sun, 30 Mar 2014 03:59:16 -0700 (PDT) From: Hani Benhabiles Date: Sun, 30 Mar 2014 11:58:38 +0100 Message-Id: <1396177119-24955-17-git-send-email-kroosec@gmail.com> In-Reply-To: <1396177119-24955-1-git-send-email-kroosec@gmail.com> References: <1396177119-24955-1-git-send-email-kroosec@gmail.com> Subject: [Qemu-devel] [PATCH v2 16/17] monitor: Add mouse_set index argument completion. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, aliguori@amazon.com, lcapitulino@redhat.com, stefanha@redhat.com, imammedo@redhat.com Signed-off-by: Hani Benhabiles --- 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