[comp.unix.aix] DELETE/BACKSPACE key paradox on RS/6000

jxt@cpdws1.ctd.ornl.gov (Tolliver J S) (03/05/91)

Hi!
I have an RS/6000. Sometimes I log in at the console, where the key marked
Backspace works as intended--it rubs out the previous character. Sometimes,
though, I log in from a VT100 terminal emulator, where the "delete" key
sends an ASCII 177 to the RS/6000, which echoes as ^?. Then one must press
control-H once to rubout the ^? and once more to rubout the original
character one wanted to "delete". This behavior can be fixed with the
stty erase command, but that's a pain. I could put stty erase in my .profile
along with enough smarts to know whether it's on the console or a dumb
terminal, but that seems rather inelegant.

My TERM variable is correctly set to be "vt100". Also, note that this same
behavior results when one telnets to the RS/6000 with a REAL VT100 via some
other host.

I claim, but am willing to be convinced otherwise, that the terminfo entry for
a vt100 is wrong. That it should deal with the ASCII 177 sent by the delete
key on a VT100 (or an emulator) "correctly" and make it behave as the "erase"
character without messing with stty erase in .profile or .login. Is this
reasoning incorrect? Why or why not? If correct, how do I hack the terminfo
entry? I've tried hacking around a bit, but terminfo is hieroglyphics to me.
I found cub1=^H and kbs=^H in the vt100 stanza in the dec.ti terminfo source
code stanza. Interestingly, they were each TWO characters (i.e., a carat (^)
and in H), not real control-H characters. I replaced them with ^?'s, applied
tic, logged out and back in. No luck. Also tried replacing them with actual
ASCII 177 codes entered with the ^V quote mechanism in vi (which echoed as
^?). Still no luck.

Is there a way to do this? How? Is it a good idea? Why or why not?

Many thanks,
Johnny Tolliver
Oak Ridge National Laboratory
jxt@ornl.gov

richter@immd4.informatik.uni-erlangen.de (Joachim Richter) (03/06/91)

In article <1991Mar5.154645.10479@cs.utk.edu> jxt@cpdws1.ctd.ornl.gov (Tolliver J S) writes:
>Hi!
>I have an RS/6000. Sometimes I log in at the console, where the key marked
>Backspace works as intended--it rubs out the previous character. Sometimes,
>though, I log in from a VT100 terminal emulator, where the "delete" key
>sends an ASCII 177 to the RS/6000, which echoes as ^?. Then one must press
>control-H once to rubout the ^? and once more to rubout the original
>character one wanted to "delete". This behavior can be fixed with the
>stty erase command, but that's a pain. I could put stty erase in my .profile
>along with enough smarts to know whether it's on the console or a dumb
>terminal, but that seems rather inelegant.
>
>My TERM variable is correctly set to be "vt100". Also, note that this same
>behavior results when one telnets to the RS/6000 with a REAL VT100 via some
>other host.
>
>I claim, but am willing to be convinced otherwise, that the terminfo entry for
>a vt100 is wrong. That it should deal with the ASCII 177 sent by the delete
>key on a VT100 (or an emulator) "correctly" and make it behave as the "erase"
>character without messing with stty erase in .profile or .login. Is this
>reasoning incorrect? Why or why not? If correct, how do I hack the terminfo
>entry? I've tried hacking around a bit, but terminfo is hieroglyphics to me.
>I found cub1=^H and kbs=^H in the vt100 stanza in the dec.ti terminfo source
>code stanza. Interestingly, they were each TWO characters (i.e., a carat (^)
>and in H), not real control-H characters. I replaced them with ^?'s, applied
>tic, logged out and back in. No luck. Also tried replacing them with actual
>ASCII 177 codes entered with the ^V quote mechanism in vi (which echoed as
>^?). Still no luck.
>
>Is there a way to do this? How? Is it a good idea? Why or why not?
>
>Many thanks,
>Johnny Tolliver
>Oak Ridge National Laboratory
>jxt@ornl.gov

bengsig@dk.oracle.com (Bjorn Engsig) (03/06/91)

Article <1991Mar5.154645.10479@cs.utk.edu> by jxt@cpdws1.ctd.ornl.gov (Tolliver J S) says:
| [description of how to chose backspace or delete as erase char deleted (!) ]
|Is there a way to do this? How? Is it a good idea? Why or why not?
Some might tell you there is.  I personally gave up on this years ago and I
am now having a set of small scripts that I can read with the shell (using .
in Bourne or Korn, source in C shell).  Each script sets TERM and a few stty
setting, so I simply log in and do (from ksh):

$ . vt100
$ . hft
$ . ibm3151
$ . vt100-w

Note that the vt100 and vt100-w furthermore will echo the sequence to make
a vt100 display 80 or 132 characters.
-- 
Bjorn Engsig, ORACLE Corporation, E-mail: bengsig@oracle.com, bengsig@oracle.nl

ijlustig@phoenix.Princeton.EDU (Irvin Lustig) (03/07/91)

In article <1991Mar5.154645.10479@cs.utk.edu>, jxt@cpdws1.ctd.ornl.gov (Tolliver J S) writes:
|> Hi!
|> I have an RS/6000. 
|> 
|> I claim, but am willing to be convinced otherwise, that the terminfo entry for
|> a vt100 is wrong. That it should deal with the ASCII 177 sent by the delete
|> key on a VT100 (or an emulator) "correctly" and make it behave as the "erase"
|> character without messing with stty erase in .profile or .login.
|> 
|> Is there a way to do this? How? Is it a good idea? Why or why not?
|> 
|> Many thanks,
|> Johnny Tolliver
|> Oak Ridge National Laboratory
|> jxt@ornl.gov

We had the same problem here at Princeton.  The problem is that the vt100
entry in terminfo (see /usr/lib/terminfo/dec.ti) sets the key 
kdch1=\177, which means that your delete key is interpreted as *delete*,
which is fine and dandy, except that all DEC LK201 keyboards don't have
a convenient backspace key, and the delete key on those keyboards *is* the
backspace key.  Our solution for our machine at Princeton was to create
a new terminal type vt100-p, which had everything the vt100 had, except
left out the kdch1 definition.  Then everything worked fine, but I still
have to put stty erase DEL in my .login to get things to work right.  
(Here DEL is the delete character inputted into vi.)  I now supply
all of our users with a .login that tests where they're coming from
and sets the terminal type appropriately.

Note that the presence of kdch1 causes vi to map delete to the x command.
You can verify this by typing :map in vi.

	-Irv Lustig
	Assistant Professor
	Dept. of Civil Engineering and Operations Research
	Princeton University
	irv%basie@princeton.edu

craig@bacchus.esa.oz.au (Craig Macbride) (03/08/91)

The real problem is that your vt100 has a "delete" key which sends "del", and
no proper "backspace" key to send "bs". Most vt100 emulators will allow you
to change this behaviour so that they send "bs" when you hit "delete". I've
never seen a real vt100, but all the clones I've seen will also allow it to
be configured. Change the vt100 to act like a normal terminal (having a
convenient backspace!) is the easiest solution.

 _--_|\		Craig Macbride <craig@bacchus.esa.oz.au>
/      \
\_.--.*/	Expert Solutions Australia
      v
-- 
 _____________________________________________________________________________
| Craig Macbride, craig@bacchus.esa.oz.au      | Hardware:                    |
|                                              |      The parts of a computer |
|   Expert Solutions Australia                 |        which you can kick!   | 

rcd@ico.isc.com (Dick Dunn) (03/09/91)

craig@bacchus.esa.oz.au (Craig Macbride) writes:
> The real problem is that your vt100 has a "delete" key which sends "del", and
> no proper "backspace" key to send "bs"...

This is not in the least true, probably explained by the later statement:
>...I've
> never seen a real vt100,...

...which makes me wonder why you posted.

The VT100 has both backspace and delete; it's just that the delete is at
the end of a row while the backspace has the break key to its right.  Thus
delete is slightly more convenient.  This is also true of relatively faith-
ful VT100 clones.

> ...Change the vt100 to act like a normal terminal (having a
> convenient backspace!) is the easiest solution.

Well, the VT100 is not programmable to alter the codes generated by the
keys, so that's not an answer.  But really, is the software problem of
setting the erase character so difficult that "change the hardware" is
an easier answer?!?  I hope not!
-- 
Dick Dunn     rcd@ico.isc.com -or- ico!rcd       Boulder, CO   (303)449-2870
   ...But is it art?

s900387@minyos.xx.rmit.oz.au (Craig Macbride) (03/11/91)

rcd@ico.isc.com (Dick Dunn) writes:

>> The real problem is that your vt100 has a "delete" key which sends "del", and
>> no proper "backspace" key to send "bs"...

>This is not in the least true, probably explained by the later statement: [...]
>The VT100 has both backspace and delete; it's just that the delete is at
>the end of a row while the backspace has the break key to its right.  Thus
>delete is slightly more convenient.

Sorry I wasn't more precise. By a "proper" backspace key, I meant to imply one
that is in the usual position and is thus relatively useable. For someone who
uses a variety of keyboards and backspaces often, the standard vt100 bs key is
not practical. The delete is not "slightly" more practical ... it is where a
backspace usually is, and as such is _the_ key people will naturally press to
backspace.

>This is also true of relatively faithful VT100 clones.

Maybe we just get different hardware over here, but I've never met a vt100
clone which could not be configured to send bs when you press the delete key.

>> ...Change the vt100 to act like a normal terminal (having a
>> convenient backspace!) is the easiest solution.

>Well, the VT100 is not programmable to alter the codes generated by the
>keys, so that's not an answer.  But really, is the software problem of
>setting the erase character so difficult that "change the hardware" is
>an easier answer?!?  I hope not!

The easiest answer is to have clones which allow for the standard sending of
bs by the key in the backspace position. This is what the majority of people
here seem to do. When you have one type of terminal which acts differently to
all others, all you end up doing is confusing the less Unix-aware users and
irritating the rest. Also, I've come across various programs which are stupid
enough to want to read backspaces no matter what the erase char is set to by
stty.

I'm not saying that choosing sensible hardware which follows the same standards
as everyone else is necessarily the only approach, but the alternative is messy.
It is not "difficult" to set the erase character, so long as you're someone who
knows enough about Unix to do that, but you've still got to remember to do it.
More importantly, there are people out there who use Unix boxes purely as
computers to run packages on. These packages have no way of knowing that a
vt100 has the delete key where the backspace key should be, and so you have
users who know nothing about stty and who suddenly use a vt100 and have no
idea why things go bananas when they try to backspace things. If their system's
default for intr is delete, then they _really_ get confused. Hooray for user-
unfriendly hardware!

 _--_|\		Craig Macbride	<uni: s900387@minyos.xx.rmit.oz.au>
/      \			<work: craig@bacchus.esa.oz.au>
\_.--.*/	VUT (RMIT) is responsible for the equipment, not the opinions!
      v
-- 
 _____________________________________________________________________________
| Craig Macbride, s900387@minyos.xx.rmit.oz.au |  Reality is for people who   |
| Only the equipment belongs to Victoria Uni.  | can't handle science fiction.|
| of Technology (RMIT); The opinions are mine. |______________________________|

jxt@cpdws1.ctd.ornl.gov (Tolliver J S) (03/15/91)

Hi!
This is being cross-posted to comp.unix.questions. First a small introduction.

A few weeks ago, I started a flurry of comments about the
delete/backspace keys and
an RS/6000. The problem was that I claimed that the delete key on my
VT100
teminal emulator wasn't being interpreted "correctly" by AIX and I
wanted to
change it, preferably with the vt100 terminfo entry instead of stty.

It seems that the concensus opinion is that AIX is right and I am
wrong, that real VT100's have both backspace and delete keys, that I should
be using the correct key for the purpose intended, and that my terminal
emulator should either include both keys or allow the delete key to be
remapped to a backspace. Furthermore, if my terminal emulator does not have
both keys and/or allow remapping, then it is brain-dead. And perhaps I, too,
am brain-dead for using such a terminal emulator.

Now for some explanations. It is true that VT100's have both keys. My terminal
emulator also supports both. It also supports remapping of the delete key to
be DELETE or BACKSPACE or anything else I want it to be. So maybe it's only
me that is brain-dead :-)

The problem is that the key marked delete on my keyboard is in the convenient
location for (all-to-frequent) use and that getting to the backspace key is
cumbersome. So why not just remap the delete key to send BACKSPACE? Well, I
use the same keyboard and terminal emulator to connect to a variety of
machines, most of which use DELETE for the erase function. Here's a list:

erase is DELETE		erase is BACKSPACE
---------------		------------------
Dec Ultrix		IBM AIX 3.1
SUN			Silicon Graphics IRIS
Intel Hypercube
Apple AU/X
NeXT
Cray UNICOS
Cray CTSS
VAX/VMS
DEC TOPS-10

I don't claim that this list is exhaustive, just the systems I regularly use
and/or have access to and have tried. I'm sure many of the readers of this
newsgroup could add to either list.

In any case, I don't want to remap my delete key between each rlogin, etc. So
I want to leave the delete key as DELETE and tell AIX to use DELETE as erase.
And that is easy to do with stty in my .profile, along with appropriate logic
to decide if I am at the console or at a remote VT100 or emulator.

However, as a fledgling system administrator, I receive all the complaints from
neophyte unix users who can't understand why delete doesn't delete. You see,
almost every other system in use at this site uses delete to delete (er,
excuse me, erase) and that is what people expect. To solve this dilema, I COULD
tell everyone to put something like [ $TERM = vt100 ] && stty erase ^? in their
.profile or .login file, but I would prefer a system-wide way of handling it
instead of each user doing it on an individual basis. Of course, at the console
keyboard, I need erase to be BACKSPACE so I can't really do it system-wide
(even if that would be possible). That is why I hit upon the apparently
bad idea of mucking with the vt100 terminfo database to change the behavior
of the delete key.

So now my question is this:
Is the best way of handling this DELETE/BACKSPACE identity crisis with a
stty in everyone's .profile or .login?
Or is there some system-wide method, possibly using terminfo, that would work
and apply to everyone except console logins?

Please note, the problem sometimes seems to get much worse. For example,
logged into a SUN, delete works normally (i.e., it erases), then rlogin to
the RS/6000 passes through .login, which does stty erase ^?, and delete
still works "normally". But then doing an xterm or aixterm grandly messes
up the delete key. It now echoes multiple characters--escape-something-or-
other. Furthermore stty erase <del>, where <del> is the delete key doesn't
help since stty erase is looking for a single character. In fact, I think
this will set the erase character to be escape, but certainly not the delete
key. Go back to the SUN and do an rsh to the RS/6000 and start xterm or
aixterm. The rsh doesn't go through .login; delete still echoes multiple
characters and stty erase doesn't work. Or, from a Macintosh running MacX,
connect to the RS/6000 (which MacX does via rsh), and delete still echoes
multiple characters.

Second question: Is there anyway to fix THAT? Is this an aixterm problem? It
seems that the key-mapping gets done at some lower level even before .login
and grandly messes up the delete key. Note that MacX to a SUN, Ultrix, etc.
works just fine.
--
Many thanks,
Johnny Tolliver (jxt@ornl.gov)

johnbob@there.austin.ibm.com (03/16/91)

This is the best description of the problem that I have seen:

In article <1991Mar14.173058.16978@cs.utk.edu> jxt@cpdws1.ctd.ornl.gov (Tolliver J S) writes:
>Hi!
>This is being cross-posted to comp.unix.questions. First a small introduction.
>
>A few weeks ago, I started a flurry of comments about the
>delete/backspace keys and
...
>The problem is that the key marked delete on my keyboard is in the convenient
>location for (all-to-frequent) use and that getting to the backspace key is
>cumbersome. So why not just remap the delete key to send BACKSPACE? Well, I
On my keyboard it is the other way around.   The backspace key is easy to
get to and the delete key is inconvenient.

>cumbersome. So why not just remap the delete key to send BACKSPACE? Well, I
>use the same keyboard and terminal emulator to connect to a variety of
>machines, most of which use DELETE for the erase function. Here's a list:
>
>erase is DELETE		erase is BACKSPACE
>---------------		------------------
>Dec Ultrix		IBM AIX 3.1
>SUN			Silicon Graphics IRIS
>Intel Hypercube
>Apple AU/X
>NeXT
>Cray UNICOS
>Cray CTSS
>VAX/VMS
>DEC TOPS-10
>
I don't have all these other machines to look at so I'll just give a 
suggestion.  I can't test to see that it will work on all the machines
listed.

>...
>seems that the key-mapping gets done at some lower level even before .login
>...
>--
>Many thanks,
>Johnny Tolliver (jxt@ornl.gov)

In the directory "/usr/lib/nls/im/En_US" you may find a file "imkeymap.us".
(do this as root)
I looked through it and found lines that started with "0xff08" and "0xffff"
(line 266 and line 370).  I replaced the contents of line "0xffff" with the
contents of line "0xff08".  Here is what it looked like:

#0xffff "\033[P"    "\033[P"    "\033[P"	   "\033[P"    "\033[142q" U U U "\033[M"    U U U U U U U U
0xffff "\10" "\10"    "\10"    "\10" "\177"	 U U U "\033[071q" U U U U U U U U

I saved the file and ran these commands (as root):

 mv imkeymap imkeymap.orig
 keycomp < imkeymap.us > imkeymap

I started up an aixterm and both backspace and delete would delete characters.
You may also have to do the same thing for the keymap file "imkeymap.vt" in
directory "/usr/lib/nls/im/En_US.ascii".

As I said before, I have no way to test it.
Disclaimers apply.

Have a day.

-john harvey

john harvey
@cs.utexas.edu:ibmchs!there.austin.ibm.com!johnbob
uunet!cs.utexas.edu!ibmaus!auschs!there.austin.ibm.com!johnbob
I don't represent anyone.  I don't speak for anyone.  This message has not
been approved by U.S., Israeli, or Iraqi censors.
-- 
john harvey
@cs.utexas.edu:ibmchs!there.austin.ibm.com!johnbob
uunet!cs.utexas.edu!ibmaus!auschs!there.austin.ibm.com!johnbob
I don't represent anyone.  I don't speak for anyone.  This message has not