zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk
Subject: Re: PATCH: displaying wide characters
Date: Fri, 28 Oct 2005 13:03:43 +0100	[thread overview]
Message-ID: <20051028130343.03e7ab97.pws@csr.com> (raw)
In-Reply-To: <237967ef0510260731rad76af2u7098358d3f0baa76@mail.gmail.com>

Mikael Magnusson <mikachu@gmail.com> 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@csr.com>                  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


  reply	other threads:[~2005-10-28 12:03 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-19 20:31 Peter Stephenson
2005-10-19 20:41 ` Peter Stephenson
2005-10-20  0:39   ` Mikael Magnusson
2005-10-20  9:39     ` Peter Stephenson
2005-10-20 15:02       ` Bart Schaefer
2005-10-21  9:03         ` Peter Stephenson
2005-10-21 14:39           ` Bart Schaefer
2005-10-21 22:29             ` Peter Stephenson
2005-10-24  8:40       ` Mikael Magnusson
2005-10-24  9:07         ` Peter Stephenson
2005-10-24 12:41           ` Mikael Magnusson
2005-10-24 12:47             ` Peter Stephenson
2005-10-24 16:53               ` Peter Stephenson
2005-10-25 23:11         ` Peter Stephenson
2005-10-26  5:19           ` Mikael Magnusson
2005-10-26  9:17             ` Peter Stephenson
2005-10-26 14:31               ` Mikael Magnusson
2005-10-28 12:03                 ` Peter Stephenson [this message]
2005-10-28 17:19                   ` Mikael Magnusson
2005-10-19 22:47 ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051028130343.03e7ab97.pws@csr.com \
    --to=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).