Subject: Re: Using the delete key to "right-delete" chars
To: None <netbsd-help@NetBSD.org>
From: James K. Lowden <jklowden@schemamania.org>
List: netbsd-help
Date: 10/02/2003 02:04:29
On Wed, 1 Oct 2003, Geoff Wing <mason@primenet.com.au> wrote:
> Julien Gabel <jpeg@thilelli.net> typed:
>
> : I just noted that the corresponding control sequence is even different
> : under the same shell, but if you use the "vi" or "emacs" edition
> command: line mode.
> 
> The control sequence is created by the terminal program and terminal
> programs don't usually care what foreground task is running.  

Geoff, 

Let me see if you've improved my understanding.  

1.  /netbsd reads the raw scancode from the keyboard with wskbd(4).
2.  X multiplexes wsdbd?  
3.  xterm reads wsdbd and converts the value to a key sequence.  Which key
sequence depends on what terminal it's emulating.  
4.  An application, frequently the shell, reads the key sequence from the
tty interface, usually in raw mode.  

How the application deals with the "delete" key depends on how it's
configured to respond to the key sequence.  Some applications, notably vi,
rely on a further level of abstraction, the curses library and its
/etc/termcap.  bash, however, doesn't, so it has to be configured per
*terminal* and per user [1].  :-(  (When I said I could get bash to tell
me the name of the key, it's because I didn't expect to have to hard-code
the key sequence.  I thought something like "bind DEL: delete-char" would
do the trick.)  

Following your suggestion and interpreting some of what I found in
http://www.ibb.net/~anne/keyboard/keyboardprev.html, I got my delete key
to do something useful in bash, where I need it most.  Mine now looks like
this:

"\e[3~": delete-char		# [delete]
"\e[H": beginning-of-line	# [home]
"\e[F": end-of-line		# [end]

"\e[5D": backward-word		# ctrl+[left arrow]
"\e[5C": forward-word		# ctrl+[right arrow]

IMHO, these bindings and their equivalents for editline and vi should be
standard issue in NetBSD.  As things stand, these keys (which have been on
VT-100 keyboards for what, half a century?) do nothing.  This makes them
similar to what (I'd say) most people expect.  It's not just gnomers who
think [home] goes to start of line.  The folks at nedit do, too, and
they're hardly will o' the wisp over there.  

Hmph.  Two nights reading about terminal emulation.  I guess I'll be
strapping my modem next.  Where the heck is that breakout box?  

Regards, 

--jkl

[1] Curiously, it seems readline (which bash uses, as you know) has no
systemwide configuration file.  It's ~/.inputrc or nothing (well, or
read.c).  Many web pages refer to /etc/inputrc, but it's definitely not in
bash 2.05.  I guess the theory is that it's enough to export INPUTRC in
/etc/profile.