zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: zsh-workers@sunsite.dk (Zsh hackers list)
Subject: Re: PATCH: command line highlighting
Date: Thu, 03 Apr 2008 12:30:14 +0200	[thread overview]
Message-ID: <10127.1207218614@thecus> (raw)
In-Reply-To: <8360.1207165155@pws-pc>

Peter Stephenson wrote:
> Now 4.3.6 is out of the way, here's something I've been working on.  It
> highlights the normal command line (not a completion list) in three

Very cool. This is fantastic. The fish shell will be going belly up once
this evolves a bit.

> +special array parameter tt(region_highglight); see

There's a typo there.

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.

> - 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).

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'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. And how can it be sure to remove its highlight
and not a region from some other widget. In the same way as compadd
adds completion matches instead of us having a $comp_matches, maybe a
builtin would be easier. It might allow more flexibility: timeout options,
group/tag identifiers, etc.

I'm not too familiar with the way syntax highlighting is typically done
in text editors. Maybe command-lines are small enough that reparsing
the whole line each time makes sense but that might imply full redraws
which could be bad over slow ssh connections. If the parsing is only
done partially as changes are made, then we'll need a good few hooks and
a way to make highlights sticky: the same word in the buffer is
highlighted even as text is inserted before it.

This is going to make the whole concept of PS2 prompts instead of proper
multiline editing seem even more out of place.

Oliver


  reply	other threads:[~2008-04-03 10:30 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 [this message]
2008-04-03 11:33   ` Peter Stephenson
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=10127.1207218614@thecus \
    --to=okiddle@yahoo.co.uk \
    --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).