Subject: Re: Creeping PCism...
To: Frederick Bruckman <fredb@immanent.net>
From: Greg Troxel <gdt@ir.bbn.com>
List: netbsd-users
Date: 02/10/2004 13:29:49
  You could broach the subject on tech-x11. I can say, from
  reviewing the CVS history, it's been the way it is for a very long
  time, accusations of "recent changes" notwithstanding.

You are quite right; the commit that introduced this was apparently
the import of XF86 3.3.4 (from xsrc/xc/programs/xterm/main.:

  revision 1.1.1.9
  date: 1999/07/20 17:50:56;  author: veego;  state: Exp;  lines: +97 -1
  XFree86 3.3.4 sources)

I'm not sure why, but I have a distinct memory of starting to be
bothered by this when I made the XF86 3.3 -> 4 jump.

  I also seem to recall that xterm doesn't emulate a VT100 in any
  sense, that it emulates something known as an "ANSI" terminal. No
  doubt you might find out more, and more accurate, details with a web
  search engine.

From 'man xterm':

       The  xterm program is a terminal emulator for the X Window
       System.  It provides DEC VT102/VT220 (VTxxx) and Tektronix
       4014  compatible terminals for programs that can't use the
       window system directly.

I recall that the ANSI spec was a generalization of the VT100 (and
came after it).  The common terminals around MIT in 1985 or so (when I
think xterm was first written under X10) were VT100s.  I think that
the VS100 (bitmapped display and keyboard for a VAX, perhaps the
earliest thing that ran X) had a delete key above return, as did the
LK201 keyboard used on the QVSS and QDSS displays on microvaxen (which
were the next-generation 'normal X displays', IIRC).

(from termcap sources, a bit later date is shown:
# X10/6.6	11/7/86, minus alternate screen, plus (csr))


  You've got to balance that against the many years of (recent?)
  tradition, and the fact that all programs and platforms that do the
  right thing with a terminal type of "xterm" would suddenly break. At
  least NetBSD systems can be configured to work properly from an xterm
  "terminal". [Maybe we need an "xterm" type in "/etc/gettytab"?]

I assume that you are referring to programs that run under an xterm in
raw mode and interpret BS as a 'delete backwards' command from the
user.  Do you mean that these programs would break because the
backspace key sends delete?  The xterm man page says that it sets the
'kb' capability accordingly and exports TERMCAP:

       ptyInitialErase (class PtyInitialErase)
               If  ``true'', xterm will use the pseudo-terminal's
               sense of the  stty  erase  value.   If  ``false'',
               xterm  will  set the stty erase value to match its
               own configuration, using the kb  string  from  the
               termcap  entry  as  a reference, if available.  In
               either case, the result is applied to the  TERMCAP
               variable   which   xterm  sets.   The  default  is
               ``false''.

xterm indeed seems to do so on my 1.6.2ish system with ptyInitialErase
set (sorry for the long line, but that's the way it is):

> env|egrep TERMCAP
TERMCAP=xterm|vs100|xterm terminal emulator (X Window System):am:bs:km:mi:ms:ut:xn:co#80:it#8:li#24:Co#8:pa#64:AB=\E[4%dm:AF=\E[3%dm:op=\E[m:@1=\EOE:@7=\EOF:@8=\EOM:k;=\E[21~:ac=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:IC=\E[%d@:K1=\EOw:K2=\EOy:K3=\EOu:K4=\EOq:K5=\EOs:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:ae=^O:al=\E[L:as=^N:bl=^G:bt=\E[Z:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:cm=\E[%i%d;%dH:cr=^M:cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:do=^J:ec=\E[%dX:ei=\E[4l:ho=\E[H:im=\E[4h:is=\E7\E[r\E[m\E[?7h\E[?1;3;4;6l\E[4l\E8\E>:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:k5=\E[15~:k6=\E[17~:k7=\E[18~:k8=\E[19~:k9=\E[20~:kD=\E[3~:kI=\E[2~:kN=\E[6~:kP=\E[5~:kd=\EOB:ke=\E[?1l\E>:kh=\EOH:kl=\EOD:kr=\EOC:ks=\E[?1h\E=:ku=\EOA:le=^H:md=\E[1m:me=\E[m:mr=\E[7m:nd=\E[C:rc=\E8:sc=\E7:se=\E[m:sf=^J:so=\E[7m:sr=\EM:st=\EH:ta=^I:te=\E[2J\E[?47l\E8:ti=\E7\E[?47h:ue=\E[m:up=\E[A:us=\E[4m:ve=\E[?25h:vi=\E[?25l:vs=\E[?25h::ZZ=0x820e000:kb=\177:

Here, kb is \177.  So I don't see the problem in this case; a correct
program has to cope with a user on a terminal with a real delete key
as well as a BackSpace key, and use the kb resource.

Of course, there's still an issue because the program is very likely
trying to behave in a way that the user expects when the user presses
the 'logical delete' key, which is either labeled BackSpace or "DEL",
depending on the terminal.  So arguably a program which is trying to
get this behavior should read the 'stty erase' setting and use that
character, whatever it may be.  I'm not going to suggest modifying
termcap(5) to have 'logical delete' concept, since I know that's way
too disruptive.

Thank you very much for the elucidation of how things work - I'm much
happier now that I understand how to make xterm do what I want.  I'm
not going to push on changing the defaults, since I realize others
have differing opinions and this is really a question of which
tradition one values more, and that's an intractable question.