[comp.unix.ultrix] vt240 & termcaps / escape key problems

braun@dri.com (Kral) (06/25/91)

Here's a problem I used to know the answer to, but have forgotten.

We have both VMS and Unix (Ultrix) systems here.  One of my people has a vt240
and connects to either system, either through a data switch, or through set
host from vms.

The problem is, the escape key on the vt240 sends a "<esc>]23~", which editors
like vi interpret as a combination of garbage and "change case" commands; the
usual affect is to change the case of the character under the cursor and move
the cursor forward one character.

Her TERM env variable is set to vt200.  What are we doing wrong?


-- 
kral * 408/647-6112 *               ...!uunet!drivax!braun * braun@dri.com
"Talking trash, touching on truth"	-- Micheal Hedges "1-900-I-LUV-YOU"

j1h9453@eagle.tamu.edu (Joel Andrew Huddleston) (06/25/91)

In article <V7S4BNZ@dri.com>, braun@dri.com (Kral) writes:
|> 
|> The problem is, the escape key on the vt240 sends a "<esc>]23~", which editors
|> like vi interpret as a combination of garbage and "change case" commands; the
|> usual affect is to change the case of the character under the cursor and move
|> the cursor forward one character.
|> 
|> Her TERM env variable is set to vt200.  What are we doing wrong?

The problem is that the key labeled (ECS) on the vt240 keyboard is only
an escape key if you are in vt100 mode.  In the GENERAL setup on the terminal,
set the first real select box to "vt100 mode" and the (ESC) key will work
like an escape alone.  Or, press ctrl-[ to send an escape.  It is generally
just as easy to find as the F11 key anyway.

If neither of these is acceptable, you could add a commmand to her .exrc file
which maps ^[[23~ to just ^[.  It would look something like this:
:map! ^[[23~ ^[
To enter the two escape characters, you will have to type ^V first.

I hope one of these ideas helps.

-- 
Joel Huddleston  eka j1h9453@zeus.tamu.edu
     Peace: Not just the absence of war but the absence of fear.
       War: Not just the absence of peace but the absence of cowardice.
Disclaimer: Not just the absence of blame but the absence of repsponsiblilty.

cook@news.colorado.edu (Richard L. Cook) (06/28/91)

braun@dri.com (Kral) writes:

>We have both VMS and Unix (Ultrix) systems here.  One of my people has a vt240
[...]
>The problem is, the escape key on the vt240 sends a "<esc>]23~", which editors
>like vi interpret as a combination of garbage and "change case" commands; the

The question of how to get around this has been answered (use Setup to
switch the terminal to VT100 mode or just use ^[ for escape -- the
latter is what I usually suggest that people do), but I thought a bit
more detail and an alternative solution might be of interest.

The combination of `^[' (ie, the escape key) and `[' (left bracket, not
right) on newer DEC terminals (since the VT200 series and the LK201
keyboard) signals the initiation of a Command Sequence and depending on
what comes next you can do many strange and wondrous things to your
terminal if sent in that direction or signal the use of a special key if
sent in the other direction.  In the latter case, UNIXen don't know
about the special status of F11 (presumably this will change when we get
DEC's TPU/EVE for ULTRIX) so F11 gets interpreted as (a) a real escape,
(b) a mistake (`[[' goes to the beginning of a section, but `[2' justs
gets you beeped), (c) a diversion (the MKS vi on my PC clone would
interpret it as a repetition count, but on any UNIX-based vi's I've been
able to try this on it gets ignored), and (d) a change case command.

So an alternative solution is that if the last character you've typed is
alpha just make sure it's the wrong case and go ahead and use F11!  Now
the purist won't think this is a very elegant solution (and won't like
the extraneous beep, either) so another alternative is to make good use
of command sequences and to send one to the terminal to tell it to turn
itself from gold into lead (don't get me wrong -- I liked my VT100) as
in:

    print -n "[61\"p"

I stuck this in a file named VT100 (the `print -n' is from the
KornShell, `echo' should work in others), made it executable with `chmod
+x vt100', and presto -- I've got a gender-changer, so to speak.  (Note
that in vi you need to do a ^V to insert the special escape character.)
This could go in .profile (the mileage of other shells may vary).

To change back I have a file named vt300 which contains:

    print -n "[63;1\"p"

where the 3 would be changed to a 2 for VT200 series terminals and the
1 would be changed to a 0 for 8-bit controls.  (In both of these the
inner `"' is quoted with `\'.)  As it happens, a VT[23]00 terminal
retains an appropriate terminal ID so that a SET TERM/INQUIRE on the
VMS machine will make the switch automagically.

On a PC I have Kermit set up the function keys so that F1 thru F10 map
to the VT's F11 thru F20 so that the real escape is right next to the
F11 function key.  In some ways it's better than being on a Real DEC
terminal (I use both as well as both VMS and ULTRIX -- and others).  And
on the PC I use the MKS toolkit and Digital Research DOS -- which is
almost like being on a Real Computer!

  Richard
--
Richard cook@spot.Colorado.EDU | cook@Colorado.BITNET | +1.303.492.2148
Social Science Data Analysis Center, University of Colorado  80309-0486