From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22722 invoked from network); 4 May 2008 18:27:02 -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.6 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; 4 May 2008 18:27:02 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 25750 invoked from network); 4 May 2008 18:26:58 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 4 May 2008 18:26:58 -0000 Received: (qmail 22143 invoked by alias); 4 May 2008 18:26:56 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24915 Received: (qmail 22127 invoked from network); 4 May 2008 18:26:55 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 4 May 2008 18:26:55 -0000 Received: from mtaout01-winn.ispmail.ntl.com (mtaout01-winn.ispmail.ntl.com [81.103.221.47]) by bifrost.dotsrc.org (Postfix) with ESMTP id 42BA580ED172 for ; Sun, 4 May 2008 20:26:47 +0200 (CEST) Received: from aamtaout04-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout01-winn.ispmail.ntl.com with ESMTP id <20080504183011.KYUA27050.mtaout01-winn.ispmail.ntl.com@aamtaout04-winn.ispmail.ntl.com> for ; Sun, 4 May 2008 19:30:11 +0100 Received: from pws-pc.ntlworld.com ([81.107.40.67]) by aamtaout04-winn.ispmail.ntl.com with ESMTP id <20080504182652.WTOI29112.aamtaout04-winn.ispmail.ntl.com@pws-pc.ntlworld.com> for ; Sun, 4 May 2008 19:26:52 +0100 Received: from pws-pc (pws-pc [127.0.0.1]) by pws-pc.ntlworld.com (8.14.2/8.14.2) with ESMTP id m44IPtWL003628 for ; Sun, 4 May 2008 19:25:55 +0100 From: Peter Stephenson To: zsh-workers@sunsite.dk (Zsh hackers list) Subject: PATCH: more combining character stuff X-Mailer: MH-E 8.0.3; nmh 1.2-20070115cvs; GNU Emacs 22.1.1 Date: Sun, 04 May 2008 19:25:55 +0100 Message-ID: <3627.1209925555@pws-pc> X-Virus-Scanned: ClamAV 0.91.2/7023/Sun May 4 19:35:05 2008 on bifrost X-Virus-Status: Clean More stuff to fix up combining characters, found just by looking through the code. I think the remaining job is to think about the function widget interface. I'll look at Functions/Zle at some point to see what might need doing there. Index: Src/Zle/zle_hist.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_hist.c,v retrieving revision 1.54 diff -u -r1.54 zle_hist.c --- Src/Zle/zle_hist.c 1 May 2008 11:33:06 -0000 1.54 +++ Src/Zle/zle_hist.c 4 May 2008 18:16:45 -0000 @@ -247,6 +247,11 @@ if (zlecs > findbol() && invicmdmode()) DECCS(); } +#ifdef MULTIBYTE_SUPPORT + else + CCRIGHT(); +#endif + } return n; } @@ -331,6 +336,10 @@ if (zlecs > findbol() && invicmdmode()) DECCS(); } +#ifdef MULTIBYTE_SUPPORT + else + CCRIGHT(); +#endif } return n; } Index: Src/Zle/zle_misc.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_misc.c,v retrieving revision 1.53 diff -u -r1.53 zle_misc.c --- Src/Zle/zle_misc.c 23 Apr 2008 21:08:34 -0000 1.53 +++ Src/Zle/zle_misc.c 4 May 2008 18:16:47 -0000 @@ -801,10 +801,20 @@ for (;;) { t1 = t0; - while (t0 && !ZC_iword(zleline[t0-1])) - t0--; - while (t0 && ZC_iword(zleline[t0-1])) - t0--; + while (t0) { + int prev = t0; + DECPOS(prev); + if (ZC_iword(zleline[prev])) + break; + t0 = prev; + } + while (t0) { + int prev = t0; + DECPOS(prev); + if (!ZC_iword(zleline[prev])) + break; + t0 = prev; + } if (!--count) break; Index: Src/Zle/zle_move.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_move.c,v retrieving revision 1.16 diff -u -r1.16 zle_move.c --- Src/Zle/zle_move.c 21 Apr 2008 11:49:58 -0000 1.16 +++ Src/Zle/zle_move.c 4 May 2008 18:16:47 -0000 @@ -307,11 +307,19 @@ return ret; } while (n--) { + int pos; + if (zlecs == 0) return 0; - if (zleline[zlecs - 1] == '\n') - if (!--zlecs) + pos = zlecs; + DECPOS(pos); + if (zleline[pos] == '\n') { + zlecs = pos; + if (!zlecs) return 0; + } + + /* works OK with combining chars since '\n' must be on its own */ while (zlecs && zleline[zlecs - 1] != '\n') zlecs--; } @@ -359,11 +367,19 @@ return ret; } while (n) { + int pos; + if (zlecs == 0) break; - if (zleline[zlecs - 1] == '\n') - if (!--zlecs) + pos = zlecs; + DECPOS(pos); + if (zleline[pos] == '\n') { + zlecs = pos; + if (!pos) break; + } + + /* works OK with combining chars since '\n' must be on its own */ while (zlecs && zleline[zlecs - 1] != '\n') zlecs--; n--; @@ -554,12 +570,15 @@ oth = '['; break; default: - zlecs++; + INCCS(); goto otog; } ct = 1; while (zlecs >= 0 && zlecs < zlell && ct) { - zlecs += dir; + if (dir < 0) + DECCS(); + else + INCCS(); if (zleline[zlecs] == oth) ct--; else if (zleline[zlecs] == me) @@ -634,7 +653,7 @@ } zlecs = findeol() + 1; } - zlecs--; + DECCS(); lastcol = 1<<30; return 0; } Index: Src/Zle/zle_vi.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_vi.c,v retrieving revision 1.21 diff -u -r1.21 zle_vi.c --- Src/Zle/zle_vi.c 23 Apr 2008 08:43:38 -0000 1.21 +++ Src/Zle/zle_vi.c 4 May 2008 18:16:47 -0000 @@ -262,7 +262,7 @@ zlecs = pos; return 1; } - zlecs--; + DECCS(); } else { while(n++ && zlecs >= 0) zlecs = findbol() - 1; @@ -270,7 +270,7 @@ zlecs = pos; return 1; } - zlecs++; + INCCS(); } virangeflag = 2; return 0; @@ -281,7 +281,7 @@ viaddnext(UNUSED(char **args)) { if (zlecs != findeol()) - zlecs++; + INCCS(); startvitext(1); return 0; } @@ -776,7 +776,7 @@ zlecs += buf->len; } if (zlecs) - zlecs--; + DECCS(); } return 0; } @@ -819,20 +819,27 @@ int vijoin(UNUSED(char **args)) { - int x; + int x, pos; startvichange(-1); if ((x = findeol()) == zlell) return 1; zlecs = x + 1; - for (x = 1; zlecs != zlell && ZC_iblank(zleline[zlecs]); zlecs++, x++); + pos = zlecs; + for (; zlecs != zlell && ZC_iblank(zleline[zlecs]); INCPOS(zlecs)) + ; + x = 1 + (zlecs - pos); backdel(x, CUT_RAW); - if (zlecs && ZC_iblank(zleline[zlecs-1])) - zlecs--; - else { - spaceinline(1); - zleline[zlecs] = ZWC(' '); + if (zlecs) { + int pos = zlecs; + DECPOS(pos); + if (ZC_iblank(zleline[pos])) { + zlecs = pos; + return 0; + } } + spaceinline(1); + zleline[zlecs] = ZWC(' '); return 0; } @@ -851,10 +858,10 @@ zleline[zlecs] = ZC_toupper(zleline[zlecs]); else if (ZC_iupper(zleline[zlecs])) zleline[zlecs] = ZC_tolower(zleline[zlecs]); - zlecs++; + INCCS(); } if (zlecs && zlecs == eol) - zlecs--; + DECCS(); return 0; } @@ -909,7 +916,7 @@ return 1; } /* delete to end of line */ - forekill(findeol() - zlecs, 0); + forekill(findeol() - zlecs, CUT_RAW); return 0; } @@ -925,13 +932,17 @@ spaceinline(1); zleline[zlecs] = '#'; if(zlecs <= viinsbegin) - viinsbegin++; - zlecs = oldcs + (zlecs <= oldcs); + INCPOS(viinsbegin); + if (zlecs <= oldcs) + INCPOS(oldcs); + zlecs = oldcs; } else { foredel(1, 0); if (zlecs < viinsbegin) - viinsbegin--; - zlecs = oldcs - (zlecs < oldcs); + DECPOS(viinsbegin); + if (zlecs < oldcs) + DECPOS(oldcs); + zlecs = oldcs; } return 0; } -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/