Commit 9dd442b1234a27375c956e650e49a32c61ff6167
1 parent
f220174d
monitor: Break out readline_show_prompt (Jan Kiszka)
Break readline_show_prompt out of readline_start so that (re-)printing the prompt can be controlled in a more fine-grained way. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6709 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
3 changed files
with
7 additions
and
10 deletions
console.h
@@ -316,5 +316,6 @@ void readline_find_completion(const char *cmdline); | @@ -316,5 +316,6 @@ void readline_find_completion(const char *cmdline); | ||
316 | const char *readline_get_history(unsigned int index); | 316 | const char *readline_get_history(unsigned int index); |
317 | void readline_start(const char *prompt, int is_password, | 317 | void readline_start(const char *prompt, int is_password, |
318 | ReadLineFunc *readline_func, void *opaque); | 318 | ReadLineFunc *readline_func, void *opaque); |
319 | +void readline_show_prompt(void); | ||
319 | 320 | ||
320 | #endif | 321 | #endif |
monitor.c
@@ -2855,6 +2855,7 @@ void monitor_resume(void) | @@ -2855,6 +2855,7 @@ void monitor_resume(void) | ||
2855 | static void monitor_start_input(void) | 2855 | static void monitor_start_input(void) |
2856 | { | 2856 | { |
2857 | readline_start("(qemu) ", 0, monitor_handle_command1, NULL); | 2857 | readline_start("(qemu) ", 0, monitor_handle_command1, NULL); |
2858 | + readline_show_prompt(); | ||
2858 | } | 2859 | } |
2859 | 2860 | ||
2860 | static void term_event(void *opaque, int event) | 2861 | static void term_event(void *opaque, int event) |
@@ -2913,6 +2914,7 @@ static void monitor_readline(const char *prompt, int is_password, | @@ -2913,6 +2914,7 @@ static void monitor_readline(const char *prompt, int is_password, | ||
2913 | char *buf, int buf_size) | 2914 | char *buf, int buf_size) |
2914 | { | 2915 | { |
2915 | readline_start(prompt, is_password, monitor_readline_cb, NULL); | 2916 | readline_start(prompt, is_password, monitor_readline_cb, NULL); |
2917 | + readline_show_prompt(); | ||
2916 | monitor_readline_buf = buf; | 2918 | monitor_readline_buf = buf; |
2917 | monitor_readline_buf_size = buf_size; | 2919 | monitor_readline_buf_size = buf_size; |
2918 | monitor_readline_started = 1; | 2920 | monitor_readline_started = 1; |
readline.c
@@ -57,7 +57,7 @@ static int term_is_password; | @@ -57,7 +57,7 @@ static int term_is_password; | ||
57 | static char term_prompt[256]; | 57 | static char term_prompt[256]; |
58 | static void *term_readline_opaque; | 58 | static void *term_readline_opaque; |
59 | 59 | ||
60 | -static void term_show_prompt2(void) | 60 | +void readline_show_prompt(void) |
61 | { | 61 | { |
62 | term_printf("%s", term_prompt); | 62 | term_printf("%s", term_prompt); |
63 | term_flush(); | 63 | term_flush(); |
@@ -66,13 +66,6 @@ static void term_show_prompt2(void) | @@ -66,13 +66,6 @@ static void term_show_prompt2(void) | ||
66 | term_esc_state = IS_NORM; | 66 | term_esc_state = IS_NORM; |
67 | } | 67 | } |
68 | 68 | ||
69 | -static void term_show_prompt(void) | ||
70 | -{ | ||
71 | - term_show_prompt2(); | ||
72 | - term_cmd_buf_index = 0; | ||
73 | - term_cmd_buf_size = 0; | ||
74 | -} | ||
75 | - | ||
76 | /* update the displayed command line */ | 69 | /* update the displayed command line */ |
77 | static void term_update(void) | 70 | static void term_update(void) |
78 | { | 71 | { |
@@ -360,7 +353,7 @@ static void term_completion(void) | @@ -360,7 +353,7 @@ static void term_completion(void) | ||
360 | j = 0; | 353 | j = 0; |
361 | } | 354 | } |
362 | } | 355 | } |
363 | - term_show_prompt2(); | 356 | + readline_show_prompt(); |
364 | } | 357 | } |
365 | } | 358 | } |
366 | 359 | ||
@@ -473,7 +466,8 @@ void readline_start(const char *prompt, int is_password, | @@ -473,7 +466,8 @@ void readline_start(const char *prompt, int is_password, | ||
473 | term_readline_func = readline_func; | 466 | term_readline_func = readline_func; |
474 | term_readline_opaque = opaque; | 467 | term_readline_opaque = opaque; |
475 | term_is_password = is_password; | 468 | term_is_password = is_password; |
476 | - term_show_prompt(); | 469 | + term_cmd_buf_index = 0; |
470 | + term_cmd_buf_size = 0; | ||
477 | } | 471 | } |
478 | 472 | ||
479 | const char *readline_get_history(unsigned int index) | 473 | const char *readline_get_history(unsigned int index) |