Re: [PATCH BlueZ] shell: Fix artifacts when asking for user input

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
On Thu, Nov 22, 2018 at 6:02 PM Luiz Augusto von Dentz
<luiz.dentz@xxxxxxxxx> wrote:
>
> From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>
>
> 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(-)
>
> diff --git a/src/shared/shell.c b/src/shared/shell.c
> index 89a2e82bc..aabbc5d0e 100644
> --- a/src/shared/shell.c
> +++ b/src/shared/shell.c
> @@ -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)
> --
> 2.17.2

Applied.

-- 
Luiz Augusto von Dentz



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux