[David Bremner] Re: [PATCH] cli/new: Avoid printing "\033[K" to non-terminal output

classic Classic list List threaded Threaded
2 messages Options
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

[David Bremner] Re: [PATCH] cli/new: Avoid printing "\033[K" to non-terminal output

Łukasz Stelmach <[hidden email]> writes:

> ---
>  notmuch-new.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/notmuch-new.c b/notmuch-new.c
> index 1321263..44174ad 100644
> --- a/notmuch-new.c
> +++ b/notmuch-new.c
> @@ -905,10 +905,9 @@ print_results (const add_files_state_t *state)
>   state->processed_files == 1 ? "file" : "total files");
>   notmuch_time_print_formatted_seconds (elapsed);
>   if (elapsed > 1)
> -    printf (" (%d files/sec.).\033[K\n",
> +    printf (" (%d files/sec.)",
>      (int) (state->processed_files / elapsed));
> - else
> -    printf (".\033[K\n");
> + printf(".%s\n", (state->output_is_a_tty) ? "\033[K" : "");
>      }
Other than missing a space after printf (which I can hopefully remember
to add when I commit it, this looks fine).

d

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Tomi Ollila-2 Tomi Ollila-2
Reply | Threaded
Open this post in threaded view
|

Re: [David Bremner] Re: [PATCH] cli/new: Avoid printing "\033[K" to non-terminal output

On Thu, Mar 09 2017, David Bremner <[hidden email]> wrote:

> From: David Bremner <[hidden email]>
> Subject: Re: [PATCH] cli/new: Avoid printing "\033[K" to non-terminal output
> To: Łukasz Stelmach <[hidden email]>
> Date: Thu, 09 Mar 2017 08:35:11 -0400
>
> Łukasz Stelmach <[hidden email]> writes:
>
>> ---
>>  notmuch-new.c | 5 ++---
>>  1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/notmuch-new.c b/notmuch-new.c
>> index 1321263..44174ad 100644
>> --- a/notmuch-new.c
>> +++ b/notmuch-new.c
>> @@ -905,10 +905,9 @@ print_results (const add_files_state_t *state)
>>   state->processed_files == 1 ? "file" : "total files");
>>   notmuch_time_print_formatted_seconds (elapsed);
>>   if (elapsed > 1)
>> -    printf (" (%d files/sec.).\033[K\n",
>> +    printf (" (%d files/sec.)",
>>      (int) (state->processed_files / elapsed));
>> - else
>> -    printf (".\033[K\n");
>> + printf(".%s\n", (state->output_is_a_tty) ? "\033[K" : "");
>>      }
>
> Other than missing a space after printf (which I can hopefully remember
> to add when I commit it, this looks fine).

I looked this briefly a while ago -- there were quite a few \033[K:s
that were not taken care of... would those have needed to be...

For those who don't know, CSI K clears up to the end of line.

>
> d

Tomi
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch