Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: zsh/complist colours improperly handle multibyte characters
On Thu, 20 Oct 2016 21:07:35 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> The problem with the (#b) example is not that the pattern has matched
> improperly, but that #ifdef MULTIBYTE_SUPPORT has never been worked
> into complist.c:clprintfmt(). So it is counting the bytes rather than
> the display width when deciding where to start/stop coloring.
So something like this might be better?
This is counting characters properly, but not taking into account the
width of the character may be greater than 1. As the outer loop is
assuming one position per character I don't know how to fix that
properly. Probably incrementing cc by the width and doing something
clever with the "beg =" is a further imporvement, but I have no idea
what to about i.
pws
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 8aeb6c3..39ac782 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -662,7 +662,9 @@ clprintfmt(char *p, int ml)
initiscol();
- for (; *p; p++) {
+ while (*p) {
+ convchar_t chr;
+ int chrlen = MB_METACHARLENCONV(p, &chr);
doiscol(i++);
cc++;
if (*p == '\n') {
@@ -673,11 +675,16 @@ clprintfmt(char *p, int ml)
if (ml == mlend - 1 && (cc % zterm_columns) == zterm_columns - 1)
return 0;
- if (*p == Meta) {
+ while (chrlen) {
+ if (*p == Meta) {
+ p++;
+ chrlen--;
+ putc(*p ^ 32, shout);
+ } else
+ putc(*p, shout);
+ chrlen--;
p++;
- putc(*p ^ 32, shout);
- } else
- putc(*p, shout);
+ }
if ((beg = !(cc % zterm_columns)))
ml++;
if (mscroll && !(cc % zterm_columns) &&
Messages sorted by:
Reverse Date,
Date,
Thread,
Author