Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: one time in 20 error
- X-seq: zsh-workers 51105
- From: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- To: Oliver Kiddle <opk@xxxxxxx>
- Cc: Zsh Workers <zsh-workers@xxxxxxx>
- Subject: Re: one time in 20 error
- Date: Tue, 6 Dec 2022 14:21:05 +0100
- Archived-at: <https://zsh.org/workers/51105>
- In-reply-to: <45486-1670284091.713245@QrNT.Ugrc.e_6U>
- List-id: <zsh-workers.zsh.org>
- References: <f29162cd-28d1-85ed-6a3c-9bec1fb2e13a@eastlink.ca> <CAA-Ti-hhbwZD3-aeMvy_tm5f7SKHw7XN4muJn8ymez1q7rAE_A@mail.gmail.com> <CAN=4vMpCUNgKYgSR+4rmREpA25v_sLHYcS4nfTk8EQ_0Cg5yyw@mail.gmail.com> <45486-1670284091.713245@QrNT.Ugrc.e_6U>
On Tue, Dec 6, 2022 at 12:48 AM Oliver Kiddle <opk@xxxxxxx> wrote:
>
> On 29 Nov, Roman Perepelitsa wrote:
> > I have the following in my .zshrc:
> >
> > function skip-csi-sequence() {
> > local key
> > while read -sk key && (( $((#key)) < 0x40 || $((#key)) > 0x7E )); do
> > # empty body
> > done
> > }
> >
> > zle -N skip-csi-sequence
> > bindkey '\e[' skip-csi-sequence
> >
> > With this binding a buggy script that leaks mouse events into zle
> > won't have any effect.
>
> This is a nice idea. I've occasionally had unwanted effects from
> unintentionally hitting a function key.
That's its intended purpose. I learned about readline's
skip-csi-sequence here: https://www.reddit.com/r/zsh/comments/yzhx3l.
Docs: https://www.gnu.org/software/bash/manual/html_node/Miscellaneous-Commands.html#index-skip_002dcsi_002dsequence-_0028_0029
"""
skip-csi-sequence ()
Read enough characters to consume a multi-key sequence such as those
defined for keys like Home and End. Such sequences begin with a
Control Sequence Indicator (CSI), usually ESC-[. If this sequence is
bound to "\e[", keys producing such sequences will have no effect
unless explicitly bound to a Readline command, instead of inserting
stray characters into the editing buffer. This is unbound by default,
but usually bound to ESC-[.
"""
> The patch below tries the widget approach. Rather than look for the
> termination character, I thought it better to bail out given any
> out-of-range parameter byte [...]
Good idea. This is also how readline does it.
> [...] or KEYTIMEOUT being exceeded
Probably also a good idea, although readline doesn't have a timeout.
Is there an advantage to implementing this widget in C rather than zsh?
Roman.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author