From: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, Wenchao Xia <xiawenc@linux.vnet.ibm.com>,
armbru@redhat.com, lcapitulino@redhat.com
Subject: [Qemu-devel] [PATCH 2/2] monitor: support sub commands in auto completion
Date: Fri, 21 Jun 2013 14:37:38 +0800 [thread overview]
Message-ID: <1371796658-15632-3-git-send-email-xiawenc@linux.vnet.ibm.com> (raw)
In-Reply-To: <1371796658-15632-1-git-send-email-xiawenc@linux.vnet.ibm.com>
This patch allow auot completion work normal in sub command case,
"info block [DEVICE]" can auto complete now, by re-enter the completion
function. Also, original "info" is treated as a special case, now it is
treated as a sub command group, global variable info_cmds is not used
any more.
Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
monitor.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/monitor.c b/monitor.c
index bc60171..c706644 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4180,6 +4180,11 @@ static void monitor_find_completion(Monitor *mon,
goto cleanup;
}
+ if (cmd->sub_table) {
+ return monitor_find_completion(mon, cmd->sub_table,
+ cmdline + strlen(cmd->name));
+ }
+
ptype = next_arg_type(cmd->args_type);
for(i = 0; i < nb_args - 2; i++) {
if (*ptype != '\0') {
@@ -4207,12 +4212,7 @@ static void monitor_find_completion(Monitor *mon,
break;
case 's':
/* XXX: more generic ? */
- if (!strcmp(cmd->name, "info")) {
- readline_set_completion_index(mon->rs, strlen(str));
- for(cmd = info_cmds; cmd->name != NULL; cmd++) {
- cmd_completion(mon, str, cmd->name);
- }
- } else if (!strcmp(cmd->name, "sendkey")) {
+ if (!strcmp(cmd->name, "sendkey")) {
char *sep = strrchr(str, '-');
if (sep)
str = sep + 1;
--
1.7.1
next prev parent reply other threads:[~2013-06-21 6:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-21 6:37 [Qemu-devel] [PATCH 0/2] support sub command group for auto completion in monitor Wenchao Xia
2013-06-21 6:37 ` [Qemu-devel] [PATCH 1/2] monitor: discard global variable in auto completion functions Wenchao Xia
2013-06-21 15:24 ` Luiz Capitulino
2013-06-24 5:36 ` Wenchao Xia
2013-06-21 6:37 ` Wenchao Xia [this message]
2013-06-21 15:24 ` [Qemu-devel] [PATCH 2/2] monitor: support sub commands in auto completion Luiz Capitulino
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1371796658-15632-3-git-send-email-xiawenc@linux.vnet.ibm.com \
--to=xiawenc@linux.vnet.ibm.com \
--cc=armbru@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).