Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: (large) initial support for combining characters in ZLE.



On Mon, 14 Apr 2008 15:34:19 +0200
"Mikael Magnusson" <mikachu@xxxxxxxxx> wrote:
> Hi, I'm not sure if you want bug reports at this point, but one thing
> I noticed and can reproduce in zsh -f is that the cursor sometimes
> gets misplaced in the terminal with combiningchars on.
> % zsh -f
> % setopt combiningchars
> % print -z $'\u0342'
> the buffer should now contain an inverted <0342>, press left or ctrl-a
> or whatever to go to the start of the line and press 'a'. Here, in
> both urxvt and xterm (though in xterm no ~ appears over the a) the
> cursor goes to sit on the start of the previous line in the terminal.
> Funnily when you backspace it goes back to the proper place in the
> current buffer again.

Here are a few trivial fixes for some simple problems like that---it's
simply a case of moving right until we get off the combining characters.

I should find a general fix for the jumping cursor problem, but for now
it's quite convenient (for me, anyway) to see the problems so clearly.

Index: Src/Zle/zle_hist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_hist.c,v
retrieving revision 1.39
diff -u -r1.39 zle_hist.c
--- Src/Zle/zle_hist.c	13 Apr 2008 16:58:42 -0000	1.39
+++ Src/Zle/zle_hist.c	14 Apr 2008 13:52:18 -0000
@@ -756,10 +756,12 @@
 	ZS_memcpy(zleline, he->zle_text, zlell);
 
 	if ((zlecs = zlell) && invicmdmode())
-	    zlecs--;
+	    DECCS();
     } else {
 	setline(he->node.nam, ZSL_COPY|ZSL_TOEND);
     }
+    /* Move right if we're on a zero-width combining character */
+    CCRIGHT();
     setlastline();
     clearlist = 1;
 }
@@ -1548,6 +1550,7 @@
 		zletextfree(&zt);
 		zle_setline(he);
 		zlecs = cpos;
+		CCRIGHT();
 		return 0;
 	    }
 	}
@@ -1588,6 +1591,7 @@
 		zletextfree(&zt);
 		zle_setline(he);
 		zlecs = cpos;
+		CCRIGHT();
 		return 0;
 	    }
 	}
Index: Src/Zle/zle_misc.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_misc.c,v
retrieving revision 1.45
diff -u -r1.45 zle_misc.c
--- Src/Zle/zle_misc.c	13 Apr 2008 16:58:42 -0000	1.45
+++ Src/Zle/zle_misc.c	14 Apr 2008 13:52:33 -0000
@@ -56,6 +56,8 @@
 	    zleline[zlecs++] = *s;
     if(neg)
 	zlecs += zmult * len;
+    /* if we ended up on a combining character, skip over it */
+    CCRIGHT();
 }
 
 /**/
Index: Src/Zle/zle_tricky.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_tricky.c,v
retrieving revision 1.92
diff -u -r1.92 zle_tricky.c
--- Src/Zle/zle_tricky.c	14 Apr 2008 09:13:18 -0000	1.92
+++ Src/Zle/zle_tricky.c	14 Apr 2008 13:52:45 -0000
@@ -980,14 +980,11 @@
 
     free(zlemetaline);
     zlemetaline = NULL;
-
-#ifdef MULTIBYTE_SUPPORT
     /*
      * If we inserted combining characters under the cursor we
      * won't have tested the effect yet.  So fix it up now.
      */
-    alignmultiwordright(1);
-#endif
+    CCRIGHT();
 }
 
 /* Free a brinfo list. */


-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070



Messages sorted by: Reverse Date, Date, Thread, Author