shell: Fix artifacts when asking for user input
Luiz Augusto von Dentz
maintainerPATCH 1/1 shell: Fix artifacts when asking for user input
From: Luiz Augusto von Dentz <[email protected]>
Instead of printing a message use set the new prompt so it is carried over when new lines are printed. Unfortunately this has some drawbacks as apparently readline is not really able to redisplay properly if the prompt contain colors.
--- src/shared/shell.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
src/shared/shell.c +6 -2
@@ -562,6 +562,8 @@ void bt_shell_usage()void bt_shell_prompt_input (const char *label,const char *msg,bt_shell_prompt_input_func func,void *user_data) { +char *str; +if (!data.init || data.mode)return ;
@@ -573,9 +575,11 @@ void bt_shell_prompt_input(const char *label, const char *msg, data.saved_prompt = true; data.saved_func = func; data.saved_user_data = user_data; +asprintf (&str,"[%s] %s " , label, msg);rl_save_prompt (); -bt_shell_printf (COLOR_RED "[%s]" COLOR_OFF " %s " , label, msg); +bt_shell_set_prompt (str); +free (str); }int bt_shell_release_prompt (const char *input)
@@ -1209,7 +1213,7 @@ void bt_shell_set_prompt(const char *string)return ;rl_set_prompt (string); -bt_shell_printf ("\r" ); +rl_redisplay (); }static bool input_read (struct io *io,void *user_data)
Signature · 1 line
2.17.2
Hi,
Quoted 47 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
Instead of printing a message use set the new prompt so it is carried over when new lines are printed. Unfortunately this has some drawbacks as apparently readline is not really able to redisplay properly if the prompt contain colors.
--- src/shared/shell.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)src/shared/shell.c +6
-3@@ -562,6 +562,8 @@ void bt_shell_usage()void bt_shell_prompt_input (const char *label,const char *msg,bt_shell_prompt_input_func func,void *user_data) { +char *str; +if (!data.init || data.mode)return ;@@ -573,9 +575,11 @@ void bt_shell_prompt_input(const char *label, const char *msg, data.saved_prompt = true; data.saved_func = func; data.saved_user_data = user_data; +asprintf (&str,"[%s] %s " , label, msg);rl_save_prompt (); -bt_shell_printf (COLOR_RED "[%s]" COLOR_OFF " %s " , label, msg); +bt_shell_set_prompt (str); +free (str); }int bt_shell_release_prompt (const char *input)@@ -1209,7 +1213,7 @@ void bt_shell_set_prompt(const char *string)return ;rl_set_prompt (string); -bt_shell_printf ("\r" ); +rl_redisplay (); }static bool input_read (struct io *io,void *user_data) --
Quoted 1 line
2.17.2
Applied.
Signature · 1 line
Luiz Augusto von Dentz