Slight monitor enhancements
PATCH 1/1 Slight monitor enhancements
Hello,
I'm attaching two patches:
One is for the monitor's "sendkey" command. It adds:
- a very basic <tab>-completion for the arguments of sendkey,
- the "plus" and "minus" keys so you can use ctrl-alt-plus and ctrl-alt-minus while in X,
- posibility of giving keys as their scancode numbers, e.g. instead of "sendkey a" you can issue "sendkey #30" or "sendkey #0x1e" or "sendkey #036"
The second patch makes the readline save commands history to a file on exit ("~/.qemu_history" by default) and load it from that file on init (if the file exists).
I think the first patch is a useful and safe addition. Regards,
Andrew
--
balrog 2oo5
Dear Outlook users: Please remove me from your address books
http://www.newsforge.com/article.pl?sid=03/08/21/143258
monitor.c +20 -0
@@ -695,6 +695,8 @@ { 0x31, "n" }, { 0x32, "m" }, + { 0x37, "asterisk" }, + { 0x39, "spc" }, { 0x3a, "caps_lock" }, { 0x3b, "f1" },
@@ -710,6 +712,9 @@ { 0x45, "num_lock" }, { 0x46, "scroll_lock" }, + { 0x4a, "minus" }, + { 0x4e, "plus" }, + { 0x56, "<" }, { 0x57, "f11" },
@@ -735,11 +740,20 @@static int get_keycode (const char *key) {const KeyDef *p; +int ret; +char *endp;for (p = key_defs; p->name !=NULL ; p++) {if (!strcmp (key, p->name))return p->keycode; } + +if (*key =='#' ) { + ret =strtoul (key +1 , &endp,0 ); +if (ret >0 && ret <0x100 && *endp ==0 ) +return ret; + } +return -1 ; }
@@ -2087,6 +2101,7 @@int nb_args, i, len;const char *ptype, *str;term_cmd_t *cmd; +const KeyDef *key;parse_cmdline (cmdline, &nb_args, args);#ifdef DEBUG_COMPLETION
@@ -2148,6 +2163,11 @@for (cmd = info_cmds; cmd->name !=NULL ; cmd++) {cmd_completion (str, cmd->name); } + }else if (!strcmp (cmd->name,"sendkey" )) { + completion_index =strlen (str); +for (key = key_defs; key->name !=NULL ; key++) { +cmd_completion (str, key->name); + } }break ;default :
monitor.c +9 -1
@@ -2203,6 +2203,14 @@readline_start ("(qemu) " ,0 , monitor_handle_command1,NULL ); } +static void monitor_init_input (void ) +{ +readline_history_restore (); +atexit (readline_history_save); + +monitor_start_input (); +} +void monitor_init (CharDriverState *hd,int show_banner) { monitor_hd = hd;
@@ -2211,7 +2219,7 @@ QEMU_VERSION); }qemu_chr_add_read_handler (hd, term_can_read, term_read,NULL ); -monitor_start_input (); +monitor_init_input (); }/* XXX: use threads ? */
readline.c +62 -0
72 lines not on this page · raw message
vl.h +2 -0
@@ -967,6 +967,8 @@const char *readline_get_history (unsigned int index);void readline_start (const char *prompt,int is_password,ReadLineFunc *readline_func,void *opaque); +void readline_history_save (void ); +void readline_history_restore (void );void kqemu_record_dump (void );