From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23004 invoked from network); 21 Apr 2008 17:57:18 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.4 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 21 Apr 2008 17:57:18 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 75096 invoked from network); 21 Apr 2008 17:57:12 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 21 Apr 2008 17:57:12 -0000 Received: (qmail 20255 invoked by alias); 21 Apr 2008 17:57:09 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24860 Received: (qmail 20235 invoked from network); 21 Apr 2008 17:57:07 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 21 Apr 2008 17:57:07 -0000 Received: from cluster-d.mailcontrol.com (cluster-d.mailcontrol.com [217.69.20.190]) by bifrost.dotsrc.org (Postfix) with ESMTP id A492B808A37A for ; Mon, 21 Apr 2008 19:57:04 +0200 (CEST) Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly46d.srv.mailcontrol.com (MailControl) with ESMTP id m3LHv3UI002373 for ; Mon, 21 Apr 2008 18:57:03 +0100 Received: from news01 ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Mon, 21 Apr 2008 18:57:02 +0100 Date: Mon, 21 Apr 2008 18:57:02 +0100 From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: vi-backward-kill-word Message-ID: <20080421185702.19659d5a@news01> In-Reply-To: <20080421182728.3450104d@news01> References: <20080421182728.3450104d@news01> Organization: CSR X-Mailer: Claws Mail 3.3.1 (GTK+ 2.12.5; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 21 Apr 2008 17:57:02.0219 (UTC) FILETIME=[1A2915B0:01C8A3D9] X-Scanned-By: MailControl A-08-00-04 (www.mailcontrol.com) on 10.68.0.156 X-Virus-Scanned: ClamAV 0.91.2/6865/Mon Apr 21 17:43:29 2008 on bifrost X-Virus-Status: Clean On Mon, 21 Apr 2008 18:27:28 +0100 Peter Stephenson wrote: > I think there's still a problem > in overstrike mode when you enter a combining character; it'll advance too > far right. I'll look at that separately. I think this deals with it. I saw some oddities with undo, but that may simply be because in a version I hadn't quite got right the cursor position was screwy. I didn't see them with the final version. Index: Src/Zle/zle_misc.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_misc.c,v retrieving revision 1.50 diff -u -r1.50 zle_misc.c --- Src/Zle/zle_misc.c 21 Apr 2008 17:30:35 -0000 1.50 +++ Src/Zle/zle_misc.c 21 Apr 2008 17:53:42 -0000 @@ -50,19 +50,43 @@ if (insmode) spaceinline(m * len); else { - int pos = zlecs, count = m * len, i = count, diff; + int pos = zlecs, diff, i; + + /* + * Calculate the number of character positions we are + * going to be using. The algorithm is that + * anything that shows up as a logical single character + * (i.e. even if control, or double width, or with combining + * characters) is treated as 1 for the purpose of replacing + * what's there already. + */ + for (i = 0, count = 0; i < len; i++) { + int width = wcwidth(zstr[i]); + count += (width != 0) ? 1 : 0; + } /* * Ensure we replace a complete combining character * for each character we overwrite. */ - while (pos < zlell && i--) { + for (i = count; pos < zlell && i--; ) { INCPOS(pos); } - diff = pos - zlecs - count; + /* + * Calculate how many raw line places we need. + * pos - zlecs is the raw line distance we're replacing, + * m * len the number we're inserting. + */ + diff = pos - zlecs - m * len; if (diff < 0) { spaceinline(-diff); - } else if (diff > 0) - foredel(diff, CUT_RAW); + } else if (diff > 0) { + /* + * We use shiftchars() here because we don't + * want combining char alignment fixed up: we + * are going to write over any that remain. + */ + shiftchars(zlecs, diff); + } } while (m--) for (s = zstr, count = len; count; s++, count--) Index: Src/Zle/zle_utils.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_utils.c,v retrieving revision 1.51 diff -u -r1.51 zle_utils.c --- Src/Zle/zle_utils.c 21 Apr 2008 10:13:31 -0000 1.51 +++ Src/Zle/zle_utils.c 21 Apr 2008 17:53:42 -0000 @@ -450,7 +450,7 @@ } /**/ -static void +void shiftchars(int to, int cnt) { if (mark >= to + cnt) -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070