nano-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] minibar: when the next character has zero width, show its co


From: pepa65
Subject: Re: [PATCH] minibar: when the next character has zero width, show its code too
Date: Thu, 7 Jan 2021 08:34:13 +0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

Useful to me, mostly when editing Thai files. In Thai, 3 composing
characters (1 base and 2 zero-width) happen a fair amount. Of course,
with this patch, only the base and the first zero-width character is
shown. I was wondering if it would be possible to show all three.

Right now, this is an example output: "U+0E14 U+0E35" (missing: U+0E48).
If it would be displayed like: "U+0E140E350E48" the whole string would
only be 1 character longer. (If 2 more spaces can be spared, perhaps a
display like "U+0E14_0E35_0E48" would be even cleared!)

In any case, this patch is already desirable in the current form.

Cheers,
Peter


On 1/7/21 2:23 AM, Benno Schulenberg wrote:
> This allows seeing that an accented character is not a single code point
> but composed from a base character plus a combining character.
> 
> 
> [ I don't really like how this behaves, and it doesn't handle the case
>   of multiple combining characters, but I can't think of a better way.
>   But I do want to be able to see it when a character is composed. ]
> 
> ---
>  src/winio.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/src/winio.c b/src/winio.c
> index 115c34f7..d8f304b0 100644
> --- a/src/winio.c
> +++ b/src/winio.c
> @@ -2072,6 +2072,7 @@ void minibar(void)
>       char *thename = NULL, *number_of_lines = NULL, *ranking = NULL;
>       char *location = nmalloc(44);
>       char *hexadecimal = nmalloc(9);
> +     char *successor = NULL;
>       size_t namewidth, placewidth;
>       size_t tallywidth = 0;
>       size_t padding = 2;
> @@ -2150,10 +2151,19 @@ void minibar(void)
>                       sprintf(hexadecimal, "  0x%02X", (unsigned 
> char)*this_position);
>  
>               mvwaddstr(bottomwin, 0, COLS - 23, hexadecimal);
> +
> +             successor = this_position + char_length(this_position);
> +
> +             if (*this_position != '\0' && is_zerowidth(successor) &&
> +                                     mbtowc(&widecode, successor, 
> MAXCHARLEN) >= 0) {
> +                     sprintf(hexadecimal, " U+%04X", widecode);
> +                     waddstr(bottomwin, hexadecimal);
> +             } else
> +                     successor = NULL;
>       }
>  
>       /* Display the state of three flags, and the state of macro and mark. */
> -     if (namewidth + tallywidth + 14 + 2 * padding < COLS) {
> +     if (!successor && namewidth + tallywidth + 14 + 2 * padding < COLS) {
>               wmove(bottomwin, 0, COLS - 11 - padding);
>               show_states_at(bottomwin);
>       }
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]