shared/shell: Fix artifacts related to prompt
Luiz Augusto von Dentz
maintainerPATCH 1/1 shared/shell: Fix artifacts related to prompt
From: Luiz Augusto von Dentz <[email protected]>
Both bt_shell_prompt_input and bt_shell_input could cause the prompt to be printed incorrectly, so they now rely on bt_shell_printf which properly check if input and prompt shall be saved/restored.
--- src/shared/shell.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
src/shared/shell.c +8 -8
@@ -475,7 +475,8 @@ void bt_shell_printf(const char *fmt, ...)if (save_input) { saved_point = rl_point; saved_line =rl_copy_text (0 , rl_end); -rl_save_prompt (); +if (!data.saved_prompt) +rl_save_prompt ();rl_replace_line ("" ,0 );rl_redisplay (); }
@@ -485,7 +486,8 @@ void bt_shell_printf(const char *fmt, ...)va_end (args);if (save_input) { -rl_restore_prompt (); +if (!data.saved_prompt) +rl_restore_prompt ();rl_replace_line (saved_line,0 ); rl_point = saved_point;rl_forced_update_display ();
@@ -523,12 +525,12 @@ void bt_shell_prompt_input(const char *label, const char *msg,if (data.saved_prompt)return ; -rl_save_prompt (); -rl_message (COLOR_RED "[%s]" COLOR_OFF " %s " , label, msg); - data.saved_prompt = true; data.saved_func = func; data.saved_user_data = user_data; + +rl_save_prompt (); +bt_shell_printf (COLOR_RED "[%s]" COLOR_OFF " %s " , label, msg); }int bt_shell_release_prompt (const char *input)
@@ -1085,9 +1087,7 @@ void bt_shell_set_prompt(const char *string)return ;rl_set_prompt (string); -printf ("\r" ); -rl_on_new_line (); -rl_redisplay (); +bt_shell_printf ("\r" ); }static bool input_read (struct io *io,void *user_data)
Signature · 1 line
2.14.3
Hi,
Quoted 61 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
Both
bt_shell_prompt_inputandbt_shell_inputcould cause the prompt to be printed incorrectly, so they now rely onbt_shell_printfwhich properly check if input and prompt shall be saved/restored.--- src/shared/shell.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)src/shared/shell.c +8
-9@@ -475,7 +475,8 @@ void bt_shell_printf(const char *fmt, ...)if (save_input) { saved_point = rl_point; saved_line =rl_copy_text (0 , rl_end); -rl_save_prompt (); +if (!data.saved_prompt) +rl_save_prompt ();rl_replace_line ("" ,0 );rl_redisplay (); }@@ -485,7 +486,8 @@ void bt_shell_printf(const char *fmt, ...)va_end (args);if (save_input) { -rl_restore_prompt (); +if (!data.saved_prompt) +rl_restore_prompt ();rl_replace_line (saved_line,0 ); rl_point = saved_point;rl_forced_update_display ();@@ -523,12 +525,12 @@ void bt_shell_prompt_input(const char *label, const char *msg,if (data.saved_prompt)return ; -rl_save_prompt (); -rl_message (COLOR_RED "[%s]" COLOR_OFF " %s " , label, msg); - data.saved_prompt = true; data.saved_func = func; data.saved_user_data = user_data; + +rl_save_prompt (); +bt_shell_printf (COLOR_RED "[%s]" COLOR_OFF " %s " , label, msg); }int bt_shell_release_prompt (const char *input)@@ -1085,9 +1087,7 @@ void bt_shell_set_prompt(const char *string)return ;rl_set_prompt (string); -printf ("\r" ); -rl_on_new_line (); -rl_redisplay (); +bt_shell_printf ("\r" ); }static bool input_read (struct io *io,void *user_data) --
Quoted 1 line
2.14.3
Applied.
Signature · 1 line
Luiz Augusto von Dentz