zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk (Zsh hackers list)
Subject: Re: PATCH: command line highlighting
Date: Thu, 3 Apr 2008 12:33:01 +0100	[thread overview]
Message-ID: <20080403123301.43f1f1f9@news01> (raw)
In-Reply-To: <10127.1207218614@thecus>

On Thu, 03 Apr 2008 12:30:14 +0200
Oliver Kiddle <okiddle@yahoo.co.uk> 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 <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


  reply	other threads:[~2008-04-03 11:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-02 19:39 Peter Stephenson
2008-04-03 10:30 ` Oliver Kiddle
2008-04-03 11:33   ` Peter Stephenson [this message]
2008-04-03 14:11     ` Oliver Kiddle
2008-04-03 15:29       ` Peter Stephenson
2008-04-03 15:13     ` Peter Stephenson
2008-04-04  9:13 ` Mikael Magnusson
2008-04-04 16:28   ` Peter Stephenson
2008-04-06 20:31 ` Bart Schaefer
2008-04-07  9:36   ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080403123301.43f1f1f9@news01 \
    --to=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).