From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2879 invoked from network); 17 Feb 2008 16:45:03 -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.5 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; 17 Feb 2008 16:45:03 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 56406 invoked from network); 17 Feb 2008 16:44:58 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 17 Feb 2008 16:44:58 -0000 Received: (qmail 16428 invoked by alias); 17 Feb 2008 16:44:55 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24564 Received: (qmail 16411 invoked from network); 17 Feb 2008 16:44:54 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 17 Feb 2008 16:44:54 -0000 Received: from mtaout03-winn.ispmail.ntl.com (mtaout03-winn.ispmail.ntl.com [81.103.221.49]) by bifrost.dotsrc.org (Postfix) with ESMTP id 0C0278026E0E for ; Sun, 17 Feb 2008 17:44:50 +0100 (CET) Received: from aamtaout03-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout03-winn.ispmail.ntl.com with ESMTP id <20080217164714.LBJQ19530.mtaout03-winn.ispmail.ntl.com@aamtaout03-winn.ispmail.ntl.com> for ; Sun, 17 Feb 2008 16:47:14 +0000 Received: from pws-pc ([81.107.42.63]) by aamtaout03-winn.ispmail.ntl.com with ESMTP id <20080217164855.KOVL26699.aamtaout03-winn.ispmail.ntl.com@pws-pc> for ; Sun, 17 Feb 2008 16:48:55 +0000 Date: Sun, 17 Feb 2008 16:43:18 +0000 From: Peter Stephenson To: "Zsh Hackers' List" Subject: Re: Phil's prompt is not working when LANG is set to UTF-8 Message-ID: <20080217164318.29e922a3@pws-pc> In-Reply-To: <080216111335.ZM17124@torch.brasslantern.com> References: <20080215235241.2f255730@pws-pc> <080216111335.ZM17124@torch.brasslantern.com> X-Mailer: Claws Mail 3.2.0 (GTK+ 2.12.5; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Cloudmark-Analysis: v=1.0 c=1 a=Rw7lO6RaNG4A:15 a=8Gg2pG7T7twA:10 a=3FTp5y5X6ml6ZCsPBftHHg==:17 a=NLZqzBF-AAAA:8 a=8WqKA3vb_yMIaq_Me8oA:9 a=bVUb8sF01cl_sDc1DL0A:7 a=14HSqJ6mph9LabGp64U1BUdQAawA:4 a=I6wTmPyJxzYA:10 a=_dQi-Dcv4p4A:10 a=LY0hPdMaydYA:10 X-Virus-Scanned: ClamAV 0.91.2/5847/Sun Feb 17 12:26:12 2008 on bifrost X-Virus-Status: Clean On Sat, 16 Feb 2008 11:13:35 -0800 Bart Schaefer wrote: > On Feb 15, 11:52pm, Peter Stephenson wrote: > } > } - Hence it falls foul of the multibyte tests. In principle it > } might clash with a UTF-8 character anyway and have the wrong > } width, so assuming a width 1 for an unknown character is not > } necessarily better than assuming width 0. > > I agree with "not necessarily," but I suspect it'll be right more > often than wrong to assume 1. *Most* characters are not going to be > "non-printing," and if the mb library doesn't recognize them, then > they're also unlikely to be simultaneously multibyte and handled > correctly by the terminal. OK, I'll change that (though needless to say the %G method is still recommended as being less hit and miss). > I like this, but I'm wondering if it might not be better to have %{ > accept a count, e.g., instead of %{...%6G%} just write %6{...%}. That was my originally thought, but then I realisd that as far as the code is concerned they're logically independent. From the point of view of the user it's a rather different matter, however. It's trivial to support both. > Does it matter where %G appears? %{...%7G...%} ? Because they're indepdendent, it doesn't matter at all, and multiple uses acumulate. In fact, they don't actually need to appear within the %{...%}, although there's no obvious reason to put them elsewhere. > Ooh, and what about negative numbers? Can one say %-4G to mean that > the sequence actually moved the cursor to the LEFT four positions? > *That* could be really useful. Yes, but I picked the present change because it was already supported by the backend code. Additions like the above are another story. Index: Doc/Zsh/prompt.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/prompt.yo,v retrieving revision 1.10 diff -u -r1.10 prompt.yo --- Doc/Zsh/prompt.yo 15 Feb 2008 23:59:09 -0000 1.10 +++ Doc/Zsh/prompt.yo 17 Feb 2008 16:42:43 -0000 @@ -187,6 +187,9 @@ Include a string as a literal escape sequence. The string within the braces should not change the cursor position. Brace pairs can nest. + +A positive numeric argument between the tt(%) and the %%({) is treated as +described for tt(%G) below. ) item(tt(%G))( Within a tt(%{)...tt(%}) sequence, include a `glitch': that is, assume @@ -199,6 +202,9 @@ indicates a character width other than one. Hence tt(%{)var(seq)tt(%2G%}) outputs var(seq) and assumes it takes up the width of two standard characters. + +Multiple uses of tt(%G) accumulate in the obvious fashion; the position +of the tt(%G) is unimportant. Negative integers are not handled. ) enditem() Index: Src/prompt.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/prompt.c,v retrieving revision 1.45 diff -u -r1.45 prompt.c --- Src/prompt.c 15 Feb 2008 23:59:09 -0000 1.45 +++ Src/prompt.c 17 Feb 2008 16:42:43 -0000 @@ -472,7 +472,10 @@ addbufspc(1); *bp++ = Inpar; } - break; + if (arg <= 0) + break; + /* else */ + /* FALLTHROUGH */ case 'G': if (arg > 0) { addbufspc(arg); @@ -948,9 +951,11 @@ break; case MB_INVALID: memset(&mbs, 0, sizeof mbs); - /* FALL THROUGH */ + /* Invalid character: assume single width. */ + multi = 0; + w++; + break; case 0: - /* Invalid character or null: assume no output. */ multi = 0; break; default: -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/