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 16:11:13 +0200 [thread overview]
Message-ID: <553.1207231873@dcle12> (raw)
In-Reply-To: <20080403123301.43f1f1f9@news01>
Peter wrote:
> 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
Thanks. Sorry, I see now that that is documented.
> > 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've updated from cvs, rebuilt with debug enabled, removed the
spurious "/" and tried again. This time it works. Thanks.
By the way, the documented feature that accepting a line does not save
region_highlight doesn't appear to work. For me, the variable and the
highlights are persisting.
> 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.
I had to add a call to "zle -R" so that it doesn't wait till the end of
the widget to display the highlight but otherwise, that seems to work.
An additional key typed in less than a second will remove the
highlighting but that's actually fine. I've included the full function
below in case anyone else wants to play with it: handle quoting or
forward searching perhaps.
> > 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.
Yes, that would be another solution.
Oliver
local i nested=1
typeset -A match
match=(
\) \(
\" \"
\' \'
\] \[
\} \{
)
zle self-insert
for ((i=$(( $CURSOR - 1));i;i--)) {
[[ $BUFFER[$i] = $match[$KEYS] ]] && (( ! --nested )) && break
[[ $BUFFER[$i] == $KEYS ]] && (( nested++ ))
}
region_highlight=("$((i-1)) $i standout")
zle -R
read -kt 1 && zle -U "$REPLY"
region_highlight=()
next prev parent reply other threads:[~2008-04-03 14:11 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
2008-04-03 14:11 ` Oliver Kiddle [this message]
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=553.1207231873@dcle12 \
--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).