From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2836 invoked from network); 17 Sep 2006 19:16:31 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.5 (2006-08-29) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 17 Sep 2006 19:16:31 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 26782 invoked from network); 17 Sep 2006 19:16:25 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 17 Sep 2006 19:16:25 -0000 Received: (qmail 15842 invoked by alias); 17 Sep 2006 19:16:22 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22729 Received: (qmail 15831 invoked from network); 17 Sep 2006 19:16:22 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 17 Sep 2006 19:16:22 -0000 Received: (qmail 26419 invoked from network); 17 Sep 2006 19:16:22 -0000 Received: from mtaout01-winn.ispmail.ntl.com (81.103.221.47) by a.mx.sunsite.dk with SMTP; 17 Sep 2006 19:16:20 -0000 Received: from aamtaout02-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout01-winn.ispmail.ntl.com with ESMTP id <20060917191615.PHNH15018.mtaout01-winn.ispmail.ntl.com@aamtaout02-winn.ispmail.ntl.com>; Sun, 17 Sep 2006 20:16:15 +0100 Received: from pwslaptop.csr.com ([81.107.41.155]) by aamtaout02-winn.ispmail.ntl.com with SMTP id <20060917191615.OXZW23938.aamtaout02-winn.ispmail.ntl.com@pwslaptop.csr.com>; Sun, 17 Sep 2006 20:16:15 +0100 Date: Sun, 17 Sep 2006 20:16:12 +0100 From: Peter Stephenson To: Andrey Borzenkov Cc: zsh-workers@sunsite.dk Subject: Re: Broken completion with UTF-8 description Message-Id: <20060917201612.fe9933d5.p.w.stephenson@ntlworld.com> In-Reply-To: <200609171853.57050.arvidjaar@newmail.ru> References: <200609171853.57050.arvidjaar@newmail.ru> X-Mailer: Sylpheed version 2.2.7 (GTK+ 2.8.20; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Sun, 17 Sep 2006 18:53:50 +0400 Andrey Borzenkov wrote: > Writing completion for kcmshell (attached); it outputs list of KDE > configuration modules together with descriptions and I have not found > any way (confirmed by KDE developers) to force descriptions in > English. So far I get the following: > > ... > printers -- Настройки системы печа�[0m > privacy -- Модуль kcontrol, очищающ�[0m > profilechooser -- Mandriva KDE profilechooser > proxy -- Настройка серверов прок�[0m > ... That's another evening of my life gone. Something in computil was using strlen() to decide whether to truncate at the end of the screen line. Apparently descriptions never wrap. There are lots of other strlen()s in computil, but they don't seem to be used for anything like this. Index: Src/Zle/computil.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v retrieving revision 1.94 diff -u -r1.94 computil.c --- Src/Zle/computil.c 30 May 2006 22:35:04 -0000 1.94 +++ Src/Zle/computil.c 17 Sep 2006 19:11:04 -0000 @@ -616,8 +616,22 @@ memset(buf, ' ', cd_state.pre); memcpy(buf, str->str, str->len); strcpy(sufp, str->desc); - if (strlen(buf) >= columns - 1) - buf[columns - 1] = '\0'; + if (MB_METASTRWIDTH(buf) >= columns - 1) { + char *termptr = buf; + int w; + MB_METACHARINIT(); + for (w = columns - 1; *termptr && w > 0; ) { + convchar_t cchar; + int cw; + termptr += MB_METACHARLENCONV(termptr, &cchar); + cw = WCWIDTH(cchar); + if (cw >= 0) + w -= cw; + else + w--; + } + *termptr = '\0'; + } *dp++ = ztrdup(buf); } *mp = *dp = NULL; -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/