[comp.windows.x] Xterm translations in vi/nn

garyb@abekrd.UUCP (Gary Bartlett) (12/20/90)

My normal windows are xterms. I have a numeric keypad which normally produces
the correct characters - for instance pressing 'KP_0' generates a '0'. But
when I start up vi (and nn) in this xterm window, the KP_0 generates the
corresponding vt100 escape code (I think) (eg - KP_0 -> ^[Op).
Can someone explain this please.  Does xterm map the key differently for raw
mode operation?

How can I get KP_0 to generate a 0 in vi (other than with a map! in my .exrc).
-- 
---------------------------------------------------------------------------
Gary C. Bartlett               NET: garyb@abekrd.co.uk
Abekas Video Systems Ltd.     UUCP: ...!uunet!mcsun!ukc!pyrltd!abekrd!garyb
12 Portman Rd,   Reading,    PHONE: +44 734 585421
Berkshire.       RG3 1EA.      FAX: +44 734 567904
United Kingdom.              TELEX: 847579

gildea@EXPO.LCS.MIT.EDU (Stephen Gildea) (12/21/90)

    Date: 20 Dec 90 12:42:12 GMT
    From: garyb@abekrd.co.uk (Gary Bartlett)
    
    My normal windows are xterms. I have a numeric keypad which
    normally produces the correct characters - for instance pressing
    'KP_0' generates a '0'. But when I start up vi (and nn) in this
    xterm window, the KP_0 generates the corresponding vt100 escape
    code (I think) (eg - KP_0 -> ^[Op).  Can someone explain this
    please.  Does xterm map the key differently for raw mode
    operation?

The explanation is that xterm is correctly emulating a VT100.  The
VT100 keypad has several modes, which are controlled by ESC sequences.
When vi (or any curses-based application) starts up, it reads the
termcap/terminfo for the terminal and sends sequences defined there
for "begin keypad application."  This typically shifts the terminal
into a mode where the keypad keys generate escape sequences.  This
behavior is desirable because complex screen-based programs may want
to be able to distinguish between the main keyboard '0' key and the
keypad '0'.  EDT comes to mind here.  I've made use of this feature in
Emacs, too.
    
    How can I get KP_0 to generate a 0 in vi (other than with a map!
    in my .exrc).

Actually, a map command is not such a bad idea.  Your other options
are to create and/or install a termcap or terminfo entry more to your
liking, or define XTerm*VT100 translations for the keypad keys.

 < Stephen
   gildea@expo.lcs.mit.edu

garyb@abekrd.UUCP (Gary Bartlett) (12/21/90)

In <9012202306.AA16572@excalibur.lcs.mit.edu> gildea@EXPO.LCS.MIT.EDU (Stephen Gildea) writes:
>The explanation is that xterm is correctly emulating a VT100.  The
>VT100 keypad has several modes, which are controlled by ESC sequences.
>    
>    How can I get KP_0 to generate a 0 in vi (other than with a map!
>    in my .exrc).

>Actually, a map command is not such a bad idea.  Your other options
>are to create and/or install a termcap or terminfo entry more to your
>liking, or define XTerm*VT100 translations for the keypad keys.

I tried XTerm*VT100 translations but these were ignored in `keypad-mode'
although they worked fine in normal mode.  Is there perhaps another resource
option for translations in this mode?

What do you do with applications that switch to keypad-mode and don't
provide ways to remap keys?

Does anyone have a full list of VT100 control codes?

Thanks again.
Gary
-- 
---------------------------------------------------------------------------
Gary C. Bartlett               NET: garyb@abekrd.co.uk
Abekas Video Systems Ltd.     UUCP: ...!uunet!mcsun!ukc!pyrltd!abekrd!garyb
12 Portman Rd,   Reading,    PHONE: +44 734 585421
Berkshire.       RG3 1EA.      FAX: +44 734 567904
United Kingdom.              TELEX: 847579

mouse@LARRY.MCRCIM.MCGILL.EDU (12/22/90)

>> My normal windows are xterms. I have a numeric keypad which normally
>> produces the correct characters - for instance pressing 'KP_0'
>> generates a '0'. But when I start up vi (and nn) in this xterm
>> window, the KP_0 generates the corresponding vt100 escape code (I
>> think) (eg - KP_0 -> ^[Op).

> The explanation is that xterm is correctly emulating a VT100.  The
> VT100 keypad has several modes, which are controlled by ESC
> sequences.  When vi (or any curses-based application) starts up, it
> reads the termcap/terminfo for the terminal and sends sequences
> defined there for "begin keypad application."

Well, "begin full-screen application".  You could delete the
"application keypad mode" sequence from the :ti: capability.

>> How can I get KP_0 to generate a 0 in vi (other than with a map! in
>> my .exrc).

You might simply

xmodmap - << EOF
keysym KP_0 = 0
keysym KP_1 = 1
keysym KP_2 = 2
keysym KP_3 = 3
keysym KP_4 = 4
keysym KP_5 = 5
keysym KP_6 = 6
keysym KP_7 = 7
keysym KP_8 = 8
keysym KP_9 = 9
EOF

Then they should be indistinguishable from the main digit keys.  If you
want to get really fancy, you could set the shifted keys as well; if
your shifted digits match mine, this would then give

xmodmap - << EOF
ksysym KP_0 = 0 parenright
ksysym KP_1 = 1 exclam
ksysym KP_2 = 2 at
ksysym KP_3 = 3 numbersign
ksysym KP_4 = 4 dollar
ksysym KP_5 = 5 percent
ksysym KP_6 = 6 asciicircum
ksysym KP_7 = 7 ampersand
ksysym KP_8 = 8 asterisk
ksysym KP_9 = 9 parenleft
EOF

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu