Discussion of the Numeric Keypad on DEC VT100 terminals (and other VTx00)

 //////////////////////////////////////////////////////////////////////////////

This page is part of the Video Terminal Information collection:

    http://www.cs.utk.edu/~shuford/terminal_index.html

 //////////////////////////////////////////////////////////////////////////////

Newsgroups: comp.sys.stratus
Message-ID: <199502172057.PAA24446@cetus1f.cs.utk.edu>
Date: Fri, 17 Feb 1995 15:57:31 -0500
From: Richard S. Shuford
Subject: Re: ENTER keys

In message <538902171@KSINET.COM>, John Koch said:
>
>  We're using MicroSoft's telnet software to connect to Stratus (VOS).
>  Using a VT100 emulator (yes, set on both ends - I'm not THAT novice)
>  we find that the ENTER key (the key marked "Enter" on the PC's keypad)
>  does the same thing as the RETURN key (the key marked "Enter" on the
>  main part of the PC's keyboard) when it comes to working with CRT 
>  forms.
>  ...
>  (A) why do the RETURN and ENTER keys behave the same?
>  (B) how does one submit a completed CRT form with ONE keystroke?


To which <Paul.Green*stratus.com> replied in message
   <199502171715.MAA11104@transfer.stratus.com>:
|
|  You don't say which ttp you are using on VOS, but I will assume
|  it is the vt100.ttp file.
|  
|  The "keyboard" section of the vt100.ttp file defines the names
|  and key sequences used by the VT100 keys.  In it we find:
|
|       enter-key      Enter          esc O M


I have not used the Microsoft "telnet" application, but one standard
setup option in a DEC VT100 (or VT220, VT340, VT420, VT510, etc.) is
the "keypad mode"--what the behavior of the numeric keypad should be.

The two modes are "application" and "numeric".

In numeric mode, the various keypad keys send either the ASCII code
for decimal digits, or the ASCII code for the comma, period, or
hyphen, or (in the case of the keypad "Enter" key") the ASCII carriage
return control character (or CR/LF if so configured).

The "Enter" key behavior you describe is characteristic of numeric-
keypad mode.

The application mode is used by programs that don't need decimal
digits so much but need lots of user-activated software functions.
The DEC text-editing programs (EDT, EVE, etc.) are a classic example.
In application mode, the keypad keys send special Escape sequences
that chiefly begin with the so-called SS3 (single-shift G3) prefix,
which in 7-bit ASCII representation is the "Esc O".  (In 8-bit, SS3
is the single code hexadecimal 8F.)

The following chart summarizes the possible codes (7-bit) generated by
the DEC terminals' keypad:

 Keypad Key    Numeric Mode   Application Mode
 ----------    ------------   ----------------
    0                0            Esc O p
    1                1            Esc O q
    2                2            Esc O r
    3                3            Esc O s
    4                4            Esc O t
    5                5            Esc O u
    6                6            Esc O v
    7                7            Esc O w
    8                8            Esc O x
    9                9            Esc O y
    -                -            Esc O m
    ,                ,            Esc O l
    .                .            Esc O n
    Enter      carriage return    Esc O M
    PF1           Esc O P         Esc O P
    PF2           Esc O Q         Esc O Q
    PF3           Esc O R         Esc O R
    PF4           Esc O S         Esc O S


` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `

This mode is useful in these  programs because they require lots of
special-function keys, perhaps for meanings like "check spelling" or
"wrap paragraph", etc.

If you just want to type numeric digits, you must arrange for the
"application keypad" mode to be turned off.  The controls are

ANSI X3.64 style

    ESC [ ? 6 6 h     DECNKM  enter Numeric Keypad Mode (lowercase H)
    ESC [ ? 6 6 l     DECNKM  exit  Numeric Keypad Mode (lowercase L)

or VT52 style

    Esc =             DECKPAM  set Keypad Application Mode
    Esc >             DECKPNM  set Keypad Numeric Mode

In Unix or Linux, these mode changes may be triggered by sequences
in the termcap or terminfo initialization strings.

 //////////////////////////////////////////////////////////////////////////////

A photo of a DEC LK401 keyboard (used with VT300, VT400) may be seen here:

    http://www.cs.utk.edu/~shuford/terminal/lk401_dec_kbd_1280x567.jpg

A diagram of the original VT100 terminal's keyboard is here:

    http://www.cs.utk.edu/~shuford/terminal/vt100_keyboard.gif

 //////////////////////////////////////////////////////////////////////////////

Newsgroups: comp.terminals,comp.sys.stratus
Path: transfer.stratus.com!not-for-spam
Message-ID: <19980131_212121_rshu@stratus.com>
References: <01bd2dbf$6480ad80$2662a294@uskihpc218523>
Date: 31 Jan 1998 21:21:21 EST
From: "Richard S. Shuford"
Subject: RE: emulation of vt220 to stratus

In message <01bd2dbf$6480ad80$2662a294@uskihpc218523>,
   "Scott Trosien" <strosien@..kmart.com>  wrote:
>
>Subject: emulation of vt220 to stratus
>Date: 30 Jan 1998 20:41:25 GMT   
>Organization: Kmart Corporation
>
> I am looking to use a vt220 terminal emulator to connect to a Stratus
> system.  The keypad seems to send the equivalent to the F-keys which the
> application uses.  Anyone have any idea what is different between what the
> keypad num keys send and what the num keys( above the alpha keys) send?
 
 
There are two separate issues in play here: the setup of the
DEC VT220 terminal itself and the settings that the Stratus
computer and its VOS operating system apply to the terminal
port to which the VT220 is connected.
 
The whole DEC terminal family, of which the VT220 is a member,
have two different modes in which the numeric keypad keys can
be operated:  "numeric" mode or "application" mode.

In numeric mode, the keys send digits: 0 1 2 3 4 5 6 7 8 9, etc.
 
In application mode, the keys send special control codes, called
"Escape sequences", which the host computer is expected to interpret.
In VOS, the rules for interpreting the Escape sequences are kept in a
"ttp" (terminal type) file set up by the system administrator for the
operating system.
 
It is not surprising that you are seeing the keypad keys produce
the Escape sequences (interpreted as application-program commands),
because the normal VOS "vt220.ttp" sends a initialization command  
to the terminal that forces the keypad into application mode.
 
Unfortunately, the relatively old VT220 terminal provides no way to
change the keypad setting locally (i.e., using the terminal's own  
SETUP screen).  Newer DEC terminals, such as the VT330, VT420, and
VT510, do give you a setup option for this.
 
If you really need to type lots of digits, you should discuss the
matter with the sysadmin of your Stratus system.
 
You are constrained somewhat in that you still have to be able to
somehow send whatever control codes the application software expects.

However, if you can do without whatever commands the numeric keys
are sending in application mode, one possible adjustment could be  
that your sysadmin could modify the "ttp" that controls your terminal
port--setting the init string to send the command to invoke numeric
keypad mode.
 
Or, if you need the numeric mode only part of the time, you could write
a little program that sends the appropriate command to the terminal at
the precise time when you need the numeric mode.  (You'll have to use
raw I/O for this.)

In either case, you should beware that VOS may need the "application"
mode set so that it can detect when you press the "Enter" key, as
distinguished from the "Return" key.  Thus, there may be some
side-effects in form-based data entry.  (In most configurations, if
VOS cannot detect the Enter key, you can't submit the form.)  So the
ttp key functions for forms may need adjustment, as well.

The Escape sequences that VOS uses for this are the older-style
controls invented by DEC for the VT52:
 
    ESC =           Enter numeric keypad application mode  (DECKPAM)
 
    ESC >           Enter numeric keypad numeric mode      (DECKPNM)
 
There is a newer ANSI-compliant command set which also works in the VT220:
[revised]

    ESC [ ? 6 6 h   set numeric keypad to application mode (SM DECNKM)
 
    ESC [ ? 6 6 l   reset numeric keypad to numeric mode   (RM DECNKM)
                    (that's a lowercase L at the end)

User-written ttp's are typically applied at bootload during the
"module_start_up.cm"  processing.  Other information about VOS ttp's may
be found in the documentation volume R096-01 "Defining a Terminal Type".
If the sysadmin has read this documentation and still has questions, he
or she can call the Stratus Customer Assistance Center for advice.
 
Bottom line:  you may be able to set things more to your liking,
but it will require some thought and effort.
 
 ...Richard S. Shuford

 //////////////////////////////////////////////////////////////////////////////

Newsgroups: comp.protocols.kermit.misc
Path: utk.edu!cssun.mathcs.emory.edu!hobbes.cc.uga.edu!news-feed-1.peachnet.edu
      !gatech!swrinde!cs.utexas.edu!news.cs.utah.edu!cc.usu.edu!jrd
Message-ID: <1995Apr22.122257.48276@cc.usu.edu>
References: <3n5307$jdd@kaie.va.ttu.ee>
Date: 22 Apr 1995 12:22:57 MDT
Organization: Utah State University
From: Joe Doupnik <jrd@cc.usu.edu>
Subject: Re: Defining functional keys

In article <3n5307$jdd@kaie.va.ttu.ee>,
    uuno@sofia.va.ttu.ee (Uuno Vallner) writes:
>
> We try to use KERMIT DOS as terminal. We have Novel and  Unix 
> mixed network. We try access to OSF/1 via IPX using Softnet in OSF/1.
> 
> We defined Kermit port bios3. It works perfectly. We need to use estonian 
> characters. We are resolved this problem too. But ...
> 
> We use application in OSF/1 (text retrieval system trip), which needs 
> for operating Application keypad (7,8. 9 ..1,0 ...)and some functional keys.
> But Kermit are using 7 as "home"
> 
> Kermit interpreted non correct functional keys. After pressing f1, system 
> sends only ESC , after next f1 follows code and new ESC. Same effect is with
> array keys. 
--------------

	I think there is some confusion about DEC versus IBM PC keys.
The relationship is detailed in distribution file MSVIBM.VT and also
in the user's manual book "Using MS-DOS Kermit." The IBM PC numeric
keypad keys are not necessarily related to the DEC KeyPad keys. Here
is a cutout from my copy of msvibm.vt:


1. VT320/VT102/VT52/Heath-19 EMULATOR IN MS-DOS KERMIT IBM-PC, CODE SUMMARY
 
           VT320/VT102 keypads		Heath-19 and VT52 Keypads     
              IBM keys       		    IBM Keys                   
   +------+------+------+------+  +------+------+-------+----------+
   |  PF1 |  PF2 |  PF3 |  PF4 |  | Blue |  Red |  Grey | up arrow | - Vendor
   |  F1  |  F2  |  F3  |  F4  |  |  F1  |  F2  |  F3   | up arrow | - Kermit
   +------+------+------+------+  +------+------+-------+----------+
   |  7   |  8   |  9   |  -   |  |  7   |  8   |  9    |down arrow|
   |  F5  |  F6  |  F7  |  F8  |  |  F5  |  F6  |  F7   |down arrow|
   +------+------+------+------+  +------+------+-------+----------+
   |  4   |  5   |  6   |  ,   |  |  4   |  5   |  6    | rgt arrow|
   |  F9  |  F10 |  SF1 |  SF2 |  |  F9  |  F10 |  SF1  | rgt arrow|
   +------+------+------+------+  +------+------+-------+----------+
   |  1   |  2   |  3   |  E   |  |  1   |  2   |  3    |left arrow|
   |  SF3 |  SF4 |  SF5 |  n  S|  |  SF3 |  SF4 |  SF5  |left arrow|
   +------+------+------+  t  F|  +------+------+-------+----------+
   |  0------0   |  .   |  e  6|  |  0------0   |  .    |  Enter   |
   |   SF7       |  SF8 |  r   |  |  SF7        |  SF8  |  SF6     |
   +-------------+------+------+  +-------------+-------+----------+
 
SF1 means push Shift and F1 keys simultaneously
---------------------------------------------------------------------------
Below, the acronyms CSI and SS3 stand for 8-bit control codes in an 8-bit
environment or for their 7-bit equivalents "ESC [" and "ESC O", respectively.
Command SET TERMINAL CONTROL {8-BIT | 7-BIT}, and an equivalent command from
the host, determines the usage for output text; use of parity forces 7-bit
mode.  CSI is decimal 155, SS3 is decimal 143.  Similarly, DCS is decimal 144
or ESC P and ST is decimal 156 or ESC \.  APC is decimal 159 or ESC _.
---------------------------------------------------------------------------
Codes sent by DEC and Heath arrow keys
Key		Verb	IBM	VT320/VT102 mode	VT52/H19 mode
			key	Cursor	Application	Cursor or Application

up		uparr	up	CSI A	SS3 A		ESC A
down		dnarr	down	CSI B	SS3 B		ESC B
right		rtarr	right	CSI C	SS3 C		ESC C
left		lfarr	left	CSI D	SS3 D		ESC D

Codes sent by DEC editing keys, not preassigned to keys.
Key		Verb		VT320 mode		VT102/VT52/H19 mode

Find		decFind		CSI 1 ~			these keys
Insert Here	decInsert	CSI 2 ~			 send nothing
Remove		decRemove	CSI 3 ~
Select		decSelect	CSI 4 ~
Prev Screen	decPrev		CSI 5 ~
Next Screen	decNext		CSI 6 ~			~ is ASCII chart 7/14

Codes sent by DEC Numeric Keypad
Key		Verb	IBM	ANSI VT320/VT102 mode	VT52/H19 mode
			key	Numeric	Application	Numeric	Application

PF1/HF7/Blue   Gold,pf1 F1	SS3 P	SS3 P		ESC P	ESC P
PF2/HF8/Red 	pf2	F2	SS3 Q	SS3 Q		ESC Q	ESC Q
PF3/HF9/Grey	pf3	F3	SS3 R	SS3 R		ESC R	ESC R
PF4/HF1     	pf4	F4	SS3 S	SS3 S		ESC S	ESC S
0		kp0	SF7	0	SS3 p		0	ESC ? p
1		kp1	SF3	1	SS3 q		1	ESC ? q
2		kp2	SF4	2	SS3 r		2	ESC ? r
3		kp3	SF5	3	SS3 s		3	ESC ? s
4		kp4	F9	4	SS3 t		4	ESC ? t
5		kp5	F10	5	SS3 u		5	ESC ? u
6		kp6	SF1	6	SS3 v		6	ESC ? v
7		kp7	F5	7	SS3 w		7	ESC ? w
8		kp8	F6	8	SS3 x		8	ESC ? x
9		kp9	F7	9	SS3 y		9	ESC ? y
comma (,)	kpcoma	SF2	,	SS3 l		,	ESC ? l
minus (-)	kpminus	F8	-	SS3 m		-	ESC ? m
period (.)	kpdot	SF8	.	SS3 n		.	ESC ? n
Enter		kpenter	SF6	CR or	SS3 M		CR or	ESC ? M
				CR LF	(newline on)	CR LF
 (SFn means hold down Shift key while pressing Function key n.)
---------------

	Please note that \Kkp0...\Kkp0 are placed on IBM PC function
keys by default. You can redefine such things using Kermit command
SET KEY, as discussed in depth in "Using MS-DOS Kermit."

	I don't quite understand why you are using SET PORT BIOS3. Do
you have some Int 14h interceptor present to route traffic to the net?
For real serial ports BIOS3 is terrible. If you are using Novell's ODI
material then Kermit can operate as a native ODI client (using it's
internal TCP/IP stack). This is discussed in the release notes.

	Joe D.

 //////////////////////////////////////////////////////////////////////////////

Newsgroups: comp.terminals
NNTP-Posting-Host: jupiter.cse.cuhk.edu.hk
NNTP-Posting-Date: Tue, 6 Sep 2005 02:44:40 +0000 (UTC)
References: <1125804366.11301@jupiter.cse.cuhk.edu.hk>
    <1125714909.123061@jupiter.cse.cuhk.edu.hk>
    <11hjcatdhuf21e2@corp.supernews.com> <rshu_20050905112020@stratagy.com>
    <11hpji7jvq8g488@corp.supernews.com>
Message-ID: <1125974680.426456@jupiter.cse.cuhk.edu.hk>
Organization: The Chinese University of Hong Kong
Date: Tue, 6 Sep 2005 10:44:39 +0800
From: PeTer <ymng3@cse.cuhk.edu.hk>
Subject: Re: numpad in Vim in Putty

   PeTer <ymng3*cse.cuhk.edu.hk> wrote:
>>|
>>| In terminal when I use numpad, it really shows me the number
>>| but in Vim the output is very strange,
>>| Including <F12>, Carriage Return + a letter etc
>>| Of course I want my numpad work normally...

   Richard S. Shuford wrote:
>>
>> Perhaps your problem is that "application keypad" mode is getting set.

 "Thomas Dickey" <dickey*saltmine.radix.net> wrote:
>
> That's what I would think.  One of the odd features with PuTTY is that
> it sends application sequences when NumLock is set.   Otherwise (in
> application mode) it sends other escapes).  PuTTY's documentation does
> not appear to correspond in this area to its actual behavior, so some
> experimentation would be needed to see what the OP is describing.
> -- 
> Thomas E. Dickey

I know finally what it is happening...thanks

but if there is anyway to close the application mode,
I tried all the 3 mode but none of them works...

When I open vim and it enters application mode,
but I don't know how to disable it.

 ..............................................................................

Newsgroups: comp.terminals
References: <1125804366.11301@jupiter.cse.cuhk.edu.hk>
    <1125714909.123061@jupiter.cse.cuhk.edu.hk>
    <11hjcatdhuf21e2@corp.supernews.com> <rshu_20050905112020@stratagy.com>
    <11hpji7jvq8g488@corp.supernews.com>
    <1125974680.426456@jupiter.cse.cuhk.edu.hk>
Message-ID: <11hsdtht9f72n92@corp.supernews.com>
Organization: RadixNet Internet Services
Date: Wed, 07 Sep 2005 00:43:29 -0000
From: Thomas Dickey <dickey@saltmine.radix.net>
Subject: Re: numpad in Vim in Putty

PeTer <ymng3*cse.cuhk.edu.hk> wrote:
>
> I know finally what it is happening...thanks
>
> but if there is anyway to close the application mode,
> I tried all the 3 mode but none of them works...
>
> When I open vim and it enters application mode,
> but I don't know how to disable it.


If vim's paying attention to the termcap (it doesn't always - has some
internal copies), it would be looking at the termcap ks/ke strings.
They're related to the terminfo (which would be the real representation
on most systems).

The terminfo manpage lists the corresponding long-terminfo, terminfo,
and termcap names:

     keypad_local           rmkx       ke        Out of ``keypad-transmit''
                                                 mode

     keypad_xmit            smkx       ks        Put terminal in
                                                 ``keypad-transmit'' mode

If you made a terminfo entry without those, and used that, vim might
not put the terminal into keypad application mode.  Also vim has lots
of options - it might even have one for doing just this.  Asking in
comp.editors might help for that.

To make a terminfo entry, use infocmp and tic, e.g.,

        infocmp >foo
        vi foo
        tic foo
-- 
Thomas E. Dickey
http://invisible-island.net/
 ftp://invisible-island.net/
 ..............................................................................

Newsgroups: comp.terminals
NNTP-Posting-Host: jupiter.cse.cuhk.edu.hk
NNTP-Posting-Date: Wed, 7 Sep 2005 05:45:14 +0000 (UTC)
References: <1125804366.11301@jupiter.cse.cuhk.edu.hk>
    <1125714909.123061@jupiter.cse.cuhk.edu.hk>
    <11hjcatdhuf21e2@corp.supernews.com> <rshu_20050905112020@stratagy.com>
    <11hpji7jvq8g488@corp.supernews.com>
    <1125974680.426456@jupiter.cse.cuhk.edu.hk>
    <11hsdtht9f72n92@corp.supernews.com>
Message-ID: <1126071914.720288@jupiter.cse.cuhk.edu.hk>
Organization: The Chinese University of Hong Kong
Date: Wed, 7 Sep 2005 13:45:15 +0800
From: PeTer <ymng3@cse.cuhk.edu.hk>
Subject: Re: numpad in Vim in Putty

I found it is a way to disable application mode now.
Thanks for your great help.

 //////////////////////////////////////////////////////////////////////////////

