From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12828 invoked by alias); 28 Oct 2015 15:46:24 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 37003 Received: (qmail 5420 invoked from network); 28 Oct 2015 15:46:23 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=ZR2E/8qSBEzzlprxMjbM698lk2oGkjOgCM9AGGP8bVk=; b=ftpp79/XolqgfQRamSfov5mGjFOL4u37J3bv6gl+Ne2AVEm9ZkEPHKwGVQzUT00H8r mJnZqo1ZH0KEmd1Bl8PDgMmTQTSnAAHZKcpy+gMiVgEs4tpe5bna215bIi8VTmFBWCV3 b5V/lnTPc/G981i4N09GDzYjS7R9YrEq2CEldx3L6cKpAWroHUrNbA64f8FtdBKa1qDO XupBxTMuiaxRrqM++hl2voW762SXjxXtNjdERQgg4dd4ODJd+HkKDiYo1h9DyTzw/BLG S9viLZ7agegWIaEiIb7qhK6Kui4Q6wTXxOU001v1Zjm2pbco0tyZKwKl8ksY2Ut3cGcL ljyQ== X-Received: by 10.25.28.131 with SMTP id c125mr12488156lfc.99.1446047180016; Wed, 28 Oct 2015 08:46:20 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Sebastian Gniazdowski Date: Wed, 28 Oct 2015 16:46:00 +0100 Message-ID: Subject: Re: [PATCH] Index of element after width of characters To: Zsh hackers list Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I can resign from the "," and stay with "<" and ">" if Bart agrees. The comma would be more complicated than the rest, having 3 possible values: index, -1, empty string. Having only "<" and ">" it's easy to detect that the limit doesn't divide any char in half: a=3D"=E6=B8=AC=E5=8F=A5a" idx1=3D${(<:2:)a} idx1=3D1 # =E6=B8=AC idx2=3D${(>:2:)a} idx2=3D2 # =E5=8F=A5 idx3=3D${(,:2:)a} idx3=3D a=3D"=E6=B8=AC=E5=8F=A5a" idx1=3D${(<:3:)a} idx1=3D1 # =E6=B8=AC idx2=3D${(>:3:)a} idx2=3D3 # a idx3=3D${(,:3:)a} idx3=3D2 # =E5=8F=A5 As it can be seen ;) when a character is divided in half by the width limit then indexes returned by < and > differ by 2. So a simple test allows to detect this and compute the period's index: idx1+1. Your syntax is very complicated, we should go for < and > as this is important functionality that allows to use $COLUMNS, construct prompts, format text. Characters < and > are related, it's good that they will be allocated for the same feature. Best regards, Sebastian Gniazdowski On 28 October 2015 at 14:31, Mikael Magnusson wrote: > On Wed, Oct 28, 2015 at 12:38 PM, Sebastian Gniazdowski > wrote: >> After thinking this through I would want to use "<", ",", ">". Could I >> allocate those symbols? Very mnemonic and nice, the use would be >> ${(<:10:)a}, ${(,:10:)a}, ${(>:10:)a} for index before width, index at >> width, index after width. I checked that they work with parser. >> >> PS. The code works in D07multibyte.ztst, so the tests issue is solved. > > Wouldn't it make more sense to use syntax like $a[(y)10,-1] and > $a[1,(y)10] ? That's also less likely to trouble Bart since we only > have about 9 flags in that namespace. For example the (w) flag works > this way, making the number refer to words rather than characters in > the string. > > -- > Mikael Magnusson