This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: The humble <DEL> and other editing keys


Key sequence generation is not a shell issue, it's defined by the terminal emulator which gets key-codes from the OS and generates sequences of bytes to send through a pseudo-tty to whatever application (shell or otherwise) that's reading. Likewise, it interprets things like cursor-addressing or color-changing sequences written by user-level (controlling side of the pseudo-tty) and then issues appropriate system or library calls to produce the requested display effects.

Generally, terminal emulators pick a commercial terminal product (if such things still exist) or simply use the ANSI terminal control standard and implement the sequences defined by that product or standard.

I usually use "od -c" to discover what a key is sending under a particular terminal emulator.

My "~/.inputrc" file shows where the Cygwin console and Cygwin RXVT differ for the Fn keys and the six keys in the Insert-PageDown cluster above the arrow keys. Fortunately, there's no conflict between the two:

# Console:
# F1 - F5
"\M-[[A" "fg %1\C-M"
"\M-[[B" "fg %2\C-M"
"\M-[[C" "fg %3\C-M"
"\M-[[D" "fg %4\C-M"
"\M-[[E" "fg %5\C-M"

# F1 - F5
"\M-[11~" "fg %1\C-M"
"\M-[12~" "fg %2\C-M"
"\M-[13~" "fg %3\C-M"
"\M-[14~" "fg %4\C-M"
"\M-[15~" "fg %5\C-M"

# Both Console and RXVT:
# F6 - F12
"\M-[17~" "fg %6\C-M"
"\M-[18~" "fg %7\C-M"
"\M-[19~" "fg %8\C-M"
"\M-[20~" "fg %9\C-M"
"\M-[21~" "fg %10\C-M"
"\M-[23~" "fg %11\C-M"
"\M-[24~" "fg %-\C-M"

# Console:
"\M-[1~": beginning-of-line # Home
"\M-[4~": end-of-line # End

"\M-[7~": beginning-of-line # Home
"\M-[8~": end-of-line # End

# Both Console and RXVT:
"\M-[2~": paste-from-clipboard # Insert
# "\M-[5~" # Page-Up
"\M-[3~": delete-char # Delete
# "\M-[6~" # Page-Down

Randall Schulz

At 23:31 2003-02-14, David Christensen wrote:
Elfyn McBratney wrote on 14 Feb 2003 18:18:47 -0000
> In bash you can add the following
> # DEL key in bash
> "\e[3~": delete-char
> to your ~/.inputrc or your /etc/inputrc file to get a functioning DEL
> ke.

Thanks!  I've been wondering about that for far too long.  :-)

BTW  I read the readline portion of "man bash" and was able to figure
out the "~/.inputrc", "\e", ":", "delete-char" parts, but how did you
figure out that the <Del> key maps to "[3~"?  Searching "man bash" and
"man readline" for "[3~" and subsets didn't seem to do the trick, nor
did "apropos escape" or Google "[3~"...



Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]