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

Re: PATCH: displaying wide characters



Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> This didn't fix the problem for me, but it is acting differently now.
> Not sure how to describe it accurately, I'll paste a few lines where
> all I've done is press delete at the first character:

I've found a problem with deletions but for some reason it didn't show up
with the characters you were using.  Anyway, this code certainly fixes
something, so let's see if it's yours.

Much of the following may be simply paranoia; the last fix is the key one.
What happened before was we only overwrote part of the last displayed
character.

Index: Src/Zle/zle_refresh.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_refresh.c,v
retrieving revision 1.34
diff -u -r1.34 zle_refresh.c
--- Src/Zle/zle_refresh.c	25 Oct 2005 23:13:41 -0000	1.34
+++ Src/Zle/zle_refresh.c	28 Oct 2005 12:02:18 -0000
@@ -1069,9 +1069,22 @@
 /* 3: main display loop - write out the buffer using whatever tricks we can */
 
     for (;;) {
-	if (*nl && *ol && nl[1] == ol[1]) /* skip only if second chars match */
+	if (*nl && *ol && nl[1] == ol[1]) {
+	    /* skip only if second chars match */
+#ifdef ZLE_UNICODE_SUPPORT
+	    int ccs_was = ccs;
+#endif
 	/* skip past all matching characters */
 	    for (; *nl && (*nl == *ol); nl++, ol++, ccs++) ;
+#ifdef ZLE_UNICODE_SUPPORT
+	    /* Make sure ol and nl are pointing to real characters */
+	    while ((*nl == WEOF || *ol == WEOF) && ccs > ccs_was) {
+		nl--;
+		ol--;
+		ccs--;
+	    }
+#endif
+	}
 
 	if (!*nl) {
 	    if (ccs == winw && hasam && char_ins > 0 && ins_last
@@ -1125,7 +1138,8 @@
 
     /* inserting & deleting chars: we can if there's no right-prompt */
 	if ((ln || !put_rpmpt || !oput_rpmpt) 
-	    && (nl[1] && ol[1] && nl[1] != ol[1])) { 
+	    && (nl[1] && ol[1] && nl[1] != ol[1])
+	    && *ol != WEOF && *nl != WEOF) { 
 
 	/* deleting characters - see if we can find a match series that
 	   makes it cheaper to delete intermediate characters
@@ -1177,9 +1191,19 @@
 	}
     /* we can't do any fancy tricks, so just dump the single character
        and keep on trying */
-	zputc(*nl);
-	nl++, ol++;
-	ccs++, vcs++;
+#ifdef ZLE_UNICODE_SUPPORT
+	do {
+#endif
+	    zputc(*nl);
+	    nl++, ol++;
+	    ccs++, vcs++;
+#ifdef ZLE_UNICODE_SUPPORT
+	    /*
+	     * Make sure we always overwrite the complete width of
+	     * a character that was there before.
+	     */
+	} while (*ol == WEOF && *nl);
+#endif
     }
 }
 


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


This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com



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