zsh-workers
 help / color / mirror / code / Atom feed
From: Frank Terbeck <ft@bewatermyfriend.org>
To: Mica Chimera <micachimera@gmail.com>
Cc: zsh-workers@zsh.org
Subject: Re: bug report
Date: Wed, 17 Sep 2014 03:08:27 +0200	[thread overview]
Message-ID: <874mw72gvo.fsf@ft.bewatermyfriend.org> (raw)
In-Reply-To: <CABMqv67mNGb3wek4QBO8vqU4R=JUp9LE65VHePCgLV4DE_xJGQ@mail.gmail.com> (Mica Chimera's message of "Tue, 16 Sep 2014 19:26:01 -0500")

Hello Mica,

Mica Chimera wrote:
> Strange behavior when using vi editor mode.
> It goes something like this, with "|" being cursor:
>
> %: bindkey -v
> %: mv /some/file /some/other/file
> commands: <ESC>Bi
> %: mv /some/file |/some/other/file
>
> At this point I can type in new stuff just fine, and <BS> up to the point
> where I reentered insert mode, but anything earlier than that beeps and
> doesn't delete.

This is the behaviour of the original vi, which vi-mode is loosely based
on. You can always rebind to ‘backward-delete-char’ if you prefer.

> Stranger still is when I <DEL>
>
> %: mv /some/file /SOME/OTH|er/file
>
> Changes it to caps.

This on the other hand is just a lack of understanding of how terminals
work. I'll try to give a brief explanation of what's going on: Special
keys, like DELETE or INSERT or the PageUp key, are encoded by terminals
as so called escape sequences. (All of this stems from the fact that
"terminals" are actually programs that emulate ancient hardware that
exchanged characters with a host via serial links. Colours, for example,
are encoded by escape sequences as well.) In my terminal, pressing the
DELETE key sends four bytes, namely:

  ESC [ 3 ~

If that sequence is not bound to a widget (which it is not by default),
ZLE (zsh's line editor) executes the actions associated with the
individual characters. ESC would change back to normal mode; [ would do
nothing by default; and "3 ~" would toggle the capitalisation of the
next three characters.

That would be the case with you, as well. Only that there appears to be
a larger integer in front of the tilde.

Like I said "If that sequence is not bound to a widget". You can bind it
to a widget, like this:

  bindkey '^[[3~' delete-char

But the problem with that is, that different terminals use different
sequences for this kind of stuff.


Debian's new zsh packages include a few lines of configuration code that
bind a few common special keys to widgets automatically by looking at
the terminal's terminfo database entry¹. If you're interested, the code
resides in:

  http://anonscm.debian.org/cgit/collab-maint/zsh.git/tree/debian/zshrc

And the lines you would be looking for are the ones from line 18 up to
and including line 91.

You could fix your issue with the BackSpace key in one go by changing
line 54 of that file from

  bind2maps       viins       -- BackSpace   vi-backward-delete-char

to:

  bind2maps       viins       -- BackSpace   backward-delete-char

(‘bind2maps’ is a simple function defined in that file, that wraps
around ‘bindkey’.)

> I'm using version 5.0.6 and have reproduced the error on multiple x86_64
> machines with default configuration.
>
> Since no one else seems to be reporting this bug and it's so severe I
> figure it's likely there's something I just don't get. If that's the case
> I'm sorry for all the trouble, but can you let me know what's happening?

No worries. This is quite the common source of confusion.


Regards, Frank

¹ There are other attempts of handling special keys, like zkbd, but I'm
  pretty convinced, that the approach used in that setup is quite robust
  for most terminals and the most common of keys. Anything beyond is
  usually very much more terminal-specific.

-- 
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
                                                  -- RFC 1925


  reply	other threads:[~2014-09-17  1:14 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-17  0:26 Mica Chimera
2014-09-17  1:08 ` Frank Terbeck [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-03-01  9:43 BUG REPORT ZheNing Hu
2021-03-01 15:27 ` Daniel Shahaf
2021-03-01 17:32 ` Bart Schaefer
2021-03-05  7:51   ` ZheNing Hu
2019-09-19 11:16 Bug report Vladimir Deyter
2019-09-19 14:53 ` Mikael Magnusson
2019-09-19 15:57   ` Daniel Shahaf
2014-12-26 16:53 mvxxc
2014-12-27  2:35 ` Bart Schaefer
2014-06-05 17:05 bug report robin terrep-drangiug
2014-06-05 20:48 ` Bart Schaefer
2013-12-17 10:59 Bug report Patrick Oscity
2013-12-17 11:27 ` Peter Stephenson
2013-12-17 17:11 ` Bart Schaefer
2013-12-17 17:56   ` Bart Schaefer
2013-12-14 18:44 Patrick Oscity
2013-12-14 19:08 ` Bart Schaefer
2013-12-14 20:43   ` Peter Stephenson
2013-12-15  1:15     ` Bart Schaefer
2013-12-15 13:30       ` Peter Stephenson
2013-12-15 17:10         ` Bart Schaefer
2013-12-15  1:08   ` Patrick Oscity
2013-12-15 11:01   ` Patrick Oscity
2013-08-04 12:16 Bug Report Yuusuke Yoshimoto
2013-08-04 17:58 ` Peter Stephenson
1996-05-22  0:07 Bug report Felix von Leitner
1996-05-15  7:48 Martin Birgmeier
1996-05-10  8:30 Martin Birgmeier
1995-08-24 11:23 Bug Report Carsten Friedrich

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=874mw72gvo.fsf@ft.bewatermyfriend.org \
    --to=ft@bewatermyfriend.org \
    --cc=micachimera@gmail.com \
    --cc=zsh-workers@zsh.org \
    /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).