Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Binding Home and End
- X-seq: zsh-users 14763
- From: "Benjamin R. Haskell" <zsh@xxxxxxxxxx>
- To: Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx>
- Subject: Re: Binding Home and End
- Date: Sun, 31 Jan 2010 18:19:13 -0500 (EST)
- Cc: zsh-users@xxxxxxx
- In-reply-to: <87iqaikkfv.fsf@xxxxxxxxxxxxxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20100127165843.GA4832@xxxxxxxxxxxxxxxxxxxxxxxxxx> <20100128213354.0dd08dd2@pws-pc> <87mxzwsi54.fsf@xxxxxxxxxxxxxxxxxxxxxx> <237967ef1001291351h6ce2d3b4o8204833df57e2ccb@xxxxxxxxxxxxxx> <87iqajsulg.fsf@xxxxxxxxxxxxxxxxxxxxxx> <20100131201022.3a71d672@pws-pc> <87iqaikkfv.fsf@xxxxxxxxxxxxxxxxxxxxxx>
On Sun, 31 Jan 2010, Frank Terbeck wrote:
> Peter Stephenson wrote:
> > On Sat, 30 Jan 2010 12:25:15 +0100
> > Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx> wrote:
> >> Mikael Magnusson wrote:
> [...]
>
> > (Although it's certainly arguable, it's not completely clear that a
> > shell's line editor is an "application" in the strict sense, the
> > whole distinction being a not very happy historical accident in the
> > first place. The way shells evolved means that to begin with they
> > were just using raw input; at some point they crossed the boundary
> > to become something more sophisticated. The simple application /
> > raw distinction doesn't really fit.)
>
> Does somebody on the list actually know why such a distinction was
> made at all? And why it would make sense to have a key like `HOME'
> send different bytes depending on which mode is active?
(This problem came up on the Vim list, too in the past couple days).
The XTerm FAQ has a short (possible) answer[1]. And I liked this ending
to an email on an Apple mailing list[2]:
"""
Confused yet? Read the relevant man pages terminfo, infocmp, tput.
If still not sufficiently confused, read
http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
and weep.
- Harald
"""
As with most things terminal(-emulator)-related, it seems to mostly come
down to hysterical raisins, but the purpose of the two modes seems
similar to what the NumLock key tends to do nowadays. (That is: lets
you switch between two useful sets of keybindings for the same
~18-key numerical keypad.) AFAICT, the VT-100 didn't have a NumLock key[3].
And, from terminfo, it seems clear that that was the intent (to separate
two different modes for the keypad itself, not to create a semantic
distinction between 'application' and 'normal' modes)[4].
[1] http://invisible-island.net/xterm/xterm.faq.html#xterm_arrows
[2] http://lists.apple.com/archives/x11-users/2008/Apr/msg00253.html
[3] http://www.columbiauniversity.org/kermit/vt100-keyboard.jpg
[4] http://linux.die.net/man/5/terminfo (Â Keypad and Function Keys)
> > If you're not relying on the particular O / [ key sequence you're
> > getting at the moment, however, as far as I know the shell code I
> > gave should work fine for you (obviously, do let us know if you find
> > a problem).
>
> Sending smkx when zle starts should make the values from $terminfo
> valid within the line editor. So no rewriting O to [ should be
> necessary.
>
> I've tested this with a number of terminals, with and without terminal
> multiplexers (screen and tmux), and so far I have not seen any
> breakages. (So far, only tried Linux, though.)
Just as more data: I can also confirm that on my system, the 'terminfo'
values for 'Home' and 'End' match the 'application' mode values for:
(u)rxvt, mlterm, and (u)xterm (=konsole, gnome-terminal, xfce's
Terminal, and terminator). Same is true under 'screen' and 'tmux'.
Of all those I just listed, only the ones that "faithfully" emulate
XTerm ((u)xterm, konsole, gnome-terminal) actually emit a different code
for Home/End under the different modes. All the others match terminfo
in both modes (as far as Home/End go).
--
Best,
Ben
Messages sorted by:
Reverse Date,
Date,
Thread,
Author