* [Qemu-devel] [PATCH] monitor: Add device_add type argument completion.
@ 2014-01-24 22:27 Hani Benhabiles
2014-02-10 19:49 ` Luiz Capitulino
0 siblings, 1 reply; 4+ messages in thread
From: Hani Benhabiles @ 2014-01-24 22:27 UTC (permalink / raw)
To: qemu-devel; +Cc: lcapitulino
Signed-off-by: Hani Benhabiles <kroosec@gmail.com>
---
monitor.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/monitor.c b/monitor.c
index 845f608..cf91544 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4254,6 +4254,26 @@ static const char *next_arg_type(const char *typestr)
return (p != NULL ? ++p : typestr);
}
+static void device_add_completion(ReadLineState *rs, const char *str)
+{
+ GSList *list, *elt;
+ size_t len;
+ len = strlen(str);
+ readline_set_completion_index(rs, len);
+ list = elt = object_class_get_list(TYPE_DEVICE, false);
+ while (elt) {
+ const char *name;
+ DeviceClass *dc = OBJECT_CLASS_CHECK(DeviceClass, elt->data,
+ TYPE_DEVICE);
+ name = object_class_get_name(OBJECT_CLASS(dc));
+ if (!strncmp(name, str, len)) {
+ readline_add_completion(rs, name);
+ }
+ elt = elt->next;
+ }
+ g_slist_free(list);
+}
+
static void monitor_find_completion_by_table(Monitor *mon,
const mon_cmd_t *cmd_table,
char **args,
@@ -4317,6 +4337,11 @@ static void monitor_find_completion_by_table(Monitor *mon,
readline_set_completion_index(mon->rs, strlen(str));
bdrv_iterate(block_completion_it, &mbs);
break;
+ case 'O':
+ if (!strcmp(cmd->name, "device_add")) {
+ device_add_completion(mon->rs, str);
+ }
+ break;
case 's':
case 'S':
if (!strcmp(cmd->name, "sendkey")) {
--
1.8.3.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] monitor: Add device_add type argument completion.
2014-01-24 22:27 [Qemu-devel] [PATCH] monitor: Add device_add type argument completion Hani Benhabiles
@ 2014-02-10 19:49 ` Luiz Capitulino
2014-02-10 21:23 ` Hani Benhabiles
0 siblings, 1 reply; 4+ messages in thread
From: Luiz Capitulino @ 2014-02-10 19:49 UTC (permalink / raw)
To: Hani Benhabiles; +Cc: qemu-devel
On Fri, 24 Jan 2014 23:27:55 +0100
Hani Benhabiles <kroosec@gmail.com> wrote:
> Signed-off-by: Hani Benhabiles <kroosec@gmail.com>
> ---
> monitor.c | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> diff --git a/monitor.c b/monitor.c
> index 845f608..cf91544 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -4254,6 +4254,26 @@ static const char *next_arg_type(const char *typestr)
> return (p != NULL ? ++p : typestr);
> }
>
> +static void device_add_completion(ReadLineState *rs, const char *str)
> +{
> + GSList *list, *elt;
> + size_t len;
> + len = strlen(str);
> + readline_set_completion_index(rs, len);
> + list = elt = object_class_get_list(TYPE_DEVICE, false);
> + while (elt) {
> + const char *name;
> + DeviceClass *dc = OBJECT_CLASS_CHECK(DeviceClass, elt->data,
> + TYPE_DEVICE);
> + name = object_class_get_name(OBJECT_CLASS(dc));
> + if (!strncmp(name, str, len)) {
> + readline_add_completion(rs, name);
> + }
> + elt = elt->next;
> + }
> + g_slist_free(list);
> +}
> +
> static void monitor_find_completion_by_table(Monitor *mon,
> const mon_cmd_t *cmd_table,
> char **args,
> @@ -4317,6 +4337,11 @@ static void monitor_find_completion_by_table(Monitor *mon,
> readline_set_completion_index(mon->rs, strlen(str));
> bdrv_iterate(block_completion_it, &mbs);
> break;
> + case 'O':
> + if (!strcmp(cmd->name, "device_add")) {
> + device_add_completion(mon->rs, str);
This is nice, but it keeps printing auto-completion options even after
it has auto-completed. For example:
(qemu) device_add pcnet <TAB>
Will show all device names once again.
> + }
> + break;
> case 's':
> case 'S':
> if (!strcmp(cmd->name, "sendkey")) {
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] monitor: Add device_add type argument completion.
2014-02-10 19:49 ` Luiz Capitulino
@ 2014-02-10 21:23 ` Hani Benhabiles
2014-02-10 21:26 ` Luiz Capitulino
0 siblings, 1 reply; 4+ messages in thread
From: Hani Benhabiles @ 2014-02-10 21:23 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: qemu-devel
Hi Luiz,
Thanks for taking a look at it.
On Mon, Feb 10, 2014 at 02:49:13PM -0500, Luiz Capitulino wrote:
> On Fri, 24 Jan 2014 23:27:55 +0100
> Hani Benhabiles <kroosec@gmail.com> wrote:
>
> > Signed-off-by: Hani Benhabiles <kroosec@gmail.com>
> > ---
> > monitor.c | 25 +++++++++++++++++++++++++
> > 1 file changed, 25 insertions(+)
> >
> > diff --git a/monitor.c b/monitor.c
> > index 845f608..cf91544 100644
> > --- a/monitor.c
> > +++ b/monitor.c
> > @@ -4254,6 +4254,26 @@ static const char *next_arg_type(const char *typestr)
> > return (p != NULL ? ++p : typestr);
> > }
> >
> > +static void device_add_completion(ReadLineState *rs, const char *str)
> > +{
> > + GSList *list, *elt;
> > + size_t len;
> > + len = strlen(str);
> > + readline_set_completion_index(rs, len);
> > + list = elt = object_class_get_list(TYPE_DEVICE, false);
> > + while (elt) {
> > + const char *name;
> > + DeviceClass *dc = OBJECT_CLASS_CHECK(DeviceClass, elt->data,
> > + TYPE_DEVICE);
> > + name = object_class_get_name(OBJECT_CLASS(dc));
> > + if (!strncmp(name, str, len)) {
> > + readline_add_completion(rs, name);
> > + }
> > + elt = elt->next;
> > + }
> > + g_slist_free(list);
> > +}
> > +
> > static void monitor_find_completion_by_table(Monitor *mon,
> > const mon_cmd_t *cmd_table,
> > char **args,
> > @@ -4317,6 +4337,11 @@ static void monitor_find_completion_by_table(Monitor *mon,
> > readline_set_completion_index(mon->rs, strlen(str));
> > bdrv_iterate(block_completion_it, &mbs);
> > break;
> > + case 'O':
> > + if (!strcmp(cmd->name, "device_add")) {
> > + device_add_completion(mon->rs, str);
>
> This is nice, but it keeps printing auto-completion options even after
> it has auto-completed. For example:
>
> (qemu) device_add pcnet <TAB>
>
> Will show all device names once again.
>
> > + }
> > + break;
> > case 's':
> > case 'S':
> > if (!strcmp(cmd->name, "sendkey")) {
>
I fixed the issue in these patch series:
http://lists.gnu.org/archive/html/qemu-devel/2014-02/msg00891.html
Could you please take a look at it ?
Cheers,
Hani.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] monitor: Add device_add type argument completion.
2014-02-10 21:23 ` Hani Benhabiles
@ 2014-02-10 21:26 ` Luiz Capitulino
0 siblings, 0 replies; 4+ messages in thread
From: Luiz Capitulino @ 2014-02-10 21:26 UTC (permalink / raw)
To: Hani Benhabiles; +Cc: qemu-devel
On Mon, 10 Feb 2014 22:23:02 +0100
Hani Benhabiles <kroosec@gmail.com> wrote:
> Hi Luiz,
>
> Thanks for taking a look at it.
>
> On Mon, Feb 10, 2014 at 02:49:13PM -0500, Luiz Capitulino wrote:
> > On Fri, 24 Jan 2014 23:27:55 +0100
> > Hani Benhabiles <kroosec@gmail.com> wrote:
> >
> > > Signed-off-by: Hani Benhabiles <kroosec@gmail.com>
> > > ---
> > > monitor.c | 25 +++++++++++++++++++++++++
> > > 1 file changed, 25 insertions(+)
> > >
> > > diff --git a/monitor.c b/monitor.c
> > > index 845f608..cf91544 100644
> > > --- a/monitor.c
> > > +++ b/monitor.c
> > > @@ -4254,6 +4254,26 @@ static const char *next_arg_type(const char *typestr)
> > > return (p != NULL ? ++p : typestr);
> > > }
> > >
> > > +static void device_add_completion(ReadLineState *rs, const char *str)
> > > +{
> > > + GSList *list, *elt;
> > > + size_t len;
> > > + len = strlen(str);
> > > + readline_set_completion_index(rs, len);
> > > + list = elt = object_class_get_list(TYPE_DEVICE, false);
> > > + while (elt) {
> > > + const char *name;
> > > + DeviceClass *dc = OBJECT_CLASS_CHECK(DeviceClass, elt->data,
> > > + TYPE_DEVICE);
> > > + name = object_class_get_name(OBJECT_CLASS(dc));
> > > + if (!strncmp(name, str, len)) {
> > > + readline_add_completion(rs, name);
> > > + }
> > > + elt = elt->next;
> > > + }
> > > + g_slist_free(list);
> > > +}
> > > +
> > > static void monitor_find_completion_by_table(Monitor *mon,
> > > const mon_cmd_t *cmd_table,
> > > char **args,
> > > @@ -4317,6 +4337,11 @@ static void monitor_find_completion_by_table(Monitor *mon,
> > > readline_set_completion_index(mon->rs, strlen(str));
> > > bdrv_iterate(block_completion_it, &mbs);
> > > break;
> > > + case 'O':
> > > + if (!strcmp(cmd->name, "device_add")) {
> > > + device_add_completion(mon->rs, str);
> >
> > This is nice, but it keeps printing auto-completion options even after
> > it has auto-completed. For example:
> >
> > (qemu) device_add pcnet <TAB>
> >
> > Will show all device names once again.
> >
> > > + }
> > > + break;
> > > case 's':
> > > case 'S':
> > > if (!strcmp(cmd->name, "sendkey")) {
> >
>
> I fixed the issue in these patch series:
> http://lists.gnu.org/archive/html/qemu-devel/2014-02/msg00891.html
>
> Could you please take a look at it ?
It's in my queue, I should get to it. Eventually :)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-02-10 21:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-24 22:27 [Qemu-devel] [PATCH] monitor: Add device_add type argument completion Hani Benhabiles
2014-02-10 19:49 ` Luiz Capitulino
2014-02-10 21:23 ` Hani Benhabiles
2014-02-10 21:26 ` Luiz Capitulino
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).