[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 14/20] monitor: Convert sendkey to use command_comple
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PULL 14/20] monitor: Convert sendkey to use command_completion. |
Date: |
Fri, 16 May 2014 11:30:29 -0400 |
From: Hani Benhabiles <address@hidden>
Signed-off-by: Hani Benhabiles <address@hidden>
Signed-off-by: Luiz Capitulino <address@hidden>
---
hmp-commands.hx | 1 +
hmp.h | 1 +
monitor.c | 32 +++++++++++++++++++++++---------
3 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 8971f1b..b4b23c8 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -556,6 +556,7 @@ ETEXI
.params = "keys [hold_ms]",
.help = "send keys to the VM (e.g. 'sendkey ctrl-alt-f1',
default hold time=100 ms)",
.mhandler.cmd = hmp_send_key,
+ .command_completion = sendkey_completion,
},
STEXI
diff --git a/hmp.h b/hmp.h
index 20ef454..12e21e7 100644
--- a/hmp.h
+++ b/hmp.h
@@ -97,5 +97,6 @@ void object_add_completion(ReadLineState *rs, int nb_args,
const char *str);
void object_del_completion(ReadLineState *rs, int nb_args, const char *str);
void device_add_completion(ReadLineState *rs, int nb_args, const char *str);
void device_del_completion(ReadLineState *rs, int nb_args, const char *str);
+void sendkey_completion(ReadLineState *rs, int nb_args, const char *str);
#endif
diff --git a/monitor.c b/monitor.c
index 9af6b0a..cb9b2c2 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4376,6 +4376,28 @@ void object_del_completion(ReadLineState *rs, int
nb_args, const char *str)
qapi_free_ObjectPropertyInfoList(start);
}
+void sendkey_completion(ReadLineState *rs, int nb_args, const char *str)
+{
+ int i;
+ char *sep;
+ size_t len;
+
+ if (nb_args != 2) {
+ return;
+ }
+ sep = strrchr(str, '-');
+ if (sep) {
+ str = sep + 1;
+ }
+ len = strlen(str);
+ readline_set_completion_index(rs, len);
+ for (i = 0; i < Q_KEY_CODE_MAX; i++) {
+ if (!strncmp(str, QKeyCode_lookup[i], len)) {
+ readline_add_completion(rs, QKeyCode_lookup[i]);
+ }
+ }
+}
+
static void monitor_find_completion_by_table(Monitor *mon,
const mon_cmd_t *cmd_table,
char **args,
@@ -4444,15 +4466,7 @@ static void monitor_find_completion_by_table(Monitor
*mon,
break;
case 's':
case 'S':
- if (!strcmp(cmd->name, "sendkey")) {
- char *sep = strrchr(str, '-');
- if (sep)
- str = sep + 1;
- readline_set_completion_index(mon->rs, strlen(str));
- for (i = 0; i < Q_KEY_CODE_MAX; i++) {
- cmd_completion(mon, str, QKeyCode_lookup[i]);
- }
- } else if (!strcmp(cmd->name, "help|?")) {
+ if (!strcmp(cmd->name, "help|?")) {
monitor_find_completion_by_table(mon, cmd_table,
&args[1], nb_args - 1);
}
--
1.9.0
- [Qemu-devel] [PULL 00/20] QMP queue, Luiz Capitulino, 2014/05/16
- [Qemu-devel] [PULL 01/20] qapi: Update qapi-code-gen.txt example to match current code, Luiz Capitulino, 2014/05/16
- [Qemu-devel] [PULL 14/20] monitor: Convert sendkey to use command_completion.,
Luiz Capitulino <=
- [Qemu-devel] [PULL 13/20] qapi: Show qapi-commands.py invocation in qapi-code-gen.txt, Luiz Capitulino, 2014/05/16
- [Qemu-devel] [PULL 20/20] qapi: skip redundant includes, Luiz Capitulino, 2014/05/16
- [Qemu-devel] [PULL 11/20] tests: Don't call visit_end_struct() after visit_start_struct() fails, Luiz Capitulino, 2014/05/16
- [Qemu-devel] [PULL 08/20] qapi: Un-inline visit of implicit struct, Luiz Capitulino, 2014/05/16
- [Qemu-devel] [PULL 09/20] hmp: Call visit_end_struct() after visit_start_struct() succeeds, Luiz Capitulino, 2014/05/16
- [Qemu-devel] [PULL 17/20] monitor: Add set_link arguments completion., Luiz Capitulino, 2014/05/16
- [Qemu-devel] [PULL 16/20] monitor: Add chardev-add backend argument completion., Luiz Capitulino, 2014/05/16
- [Qemu-devel] [PULL 15/20] monitor: Add chardev-remove command completion., Luiz Capitulino, 2014/05/16
- [Qemu-devel] [PULL 19/20] monitor: Add netdev_del id argument completion., Luiz Capitulino, 2014/05/16
- [Qemu-devel] [PULL 06/20] qapi: Clean up shadowing of parameters and locals in inner scopes, Luiz Capitulino, 2014/05/16