From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16114 invoked from network); 3 Apr 2008 11:34:19 -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.3 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; 3 Apr 2008 11:34:19 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 95186 invoked from network); 3 Apr 2008 11:34:13 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 3 Apr 2008 11:34:13 -0000 Received: (qmail 15654 invoked by alias); 3 Apr 2008 11:34:09 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24784 Received: (qmail 15641 invoked from network); 3 Apr 2008 11:34:09 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 3 Apr 2008 11:34:09 -0000 Received: from cluster-g.mailcontrol.com (cluster-g.mailcontrol.com [85.115.41.190]) by bifrost.dotsrc.org (Postfix) with ESMTP id 7599782DC37A for ; Thu, 3 Apr 2008 13:34:02 +0200 (CEST) Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly11g.srv.mailcontrol.com (MailControl) with ESMTP id m33BXYKx019046 for ; Thu, 3 Apr 2008 12:33:48 +0100 Received: from news01 ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Thu, 3 Apr 2008 12:33:01 +0100 Date: Thu, 3 Apr 2008 12:33:01 +0100 From: Peter Stephenson To: zsh-workers@sunsite.dk (Zsh hackers list) Subject: Re: PATCH: command line highlighting Message-ID: <20080403123301.43f1f1f9@news01> In-Reply-To: <10127.1207218614@thecus> References: <8360.1207165155@pws-pc> <10127.1207218614@thecus> 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: 03 Apr 2008 11:33:01.0826 (UTC) FILETIME=[79949E20:01C8957E] X-Scanned-By: MailControl A-08-00-04 (www.mailcontrol.com) on 10.71.0.121 X-Virus-Scanned: ClamAV 0.91.2/6565/Thu Apr 3 12:29:29 2008 on bifrost X-Virus-Status: Clean On Thu, 03 Apr 2008 12:30:14 +0200 Oliver Kiddle wrote: > > +special array parameter tt(region_highglight); see > > There's a typo there. I'll fix that when I commit. > Can the region and unprintable characters have a different highlight > style? zle_highlight is an array, right? Or is that for start/end escape > sequences. zle_highlight is a global setting which can go in your .zshrc, so you can set zle_highlight=(region:underline special:bold), or whatever. That's why it begins with zle_: the local special parameters in widgets are only special there so don't have it. > > - arbitrary chunks of the line: controlled by the (zle special) array > > region_highlight. This is limited to static uses at the moment; > > highlighting doesn't track movement. > > This is probably the part that will be expanded on if things like syntax > highlighting will be done in shell code (completion system like). Yes, one day it should be possible to expand this to track changes, but I think there are areas of the code that aren't very consistent at the moment, such as undo. Also, I'm not sure how consistent the completion code is in calling the right code to change the command line: mostly I think it's OK, but there's so much of it it's hard to be sure. So for now it's purely static. > As a test, I wrote a very rudimentary bracket matching widget: > local i > zle self-insert > for ((i=$CURSOR;i;i--)) { > [[ $BUFFER[$i] = '(' ]] && break > } > region_highlight=("$((i-1)) $i/ bold") > With a zle -M command at the end of this, zsh coredumps. Let me know if > you can't reproduce it. I observed it on Solaris 10. I couldn't easily get this to happen (that "/" probably isn't supposed to be there). However, I have seen at least one crash involving widgets and region_highlight here which comes from get_region_highlight() being broken. I think I'll commit what I have: it is to be assumed that the interface will continue to change. > I'm not sure where and how to implement the unhighlight. Ideally, I > would like to have the matching paren highlighted for 1 second which > is what nedit does. We need to be able to see if a key is read within the time and if it is unget it and return (like sit-for in Emacs). Something like read -kt 1 && zle -U $REPLY should work, but I haven't played around with it yet. > And how can it be sure to remove its highlight > and not a region from some other widget. region_highlight could be an associative array, I suppose. -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070