[comp.terminals] Can ANSI/DEC terminals report keypad mode?

leilabd@syma.sussex.ac.uk (Leila Burrell-Davis) (08/07/89)

On leaving a program, I'd like to put the keyboard back into the same
state it was in at the start, in particular the numeric keypad into
either applications or numeric mode. Can anyone tell me if ANSI/DEC
terminals will report this information and, if not, suggest how I
might do this?
-- 
Leila Burrell-Davis, Computing Service, University of Sussex, Brighton, UK
Tel: +44 273 678390   Fax: +44 273 678335  JANET: leilabd@uk.ac.sussex.syma
INTERNET: leilabd%syma.sussex.ac.uk@nsfnet-relay.ac.uk
BITNET: leilabd@syma.sussex.ac.uk      UUCP: leilabd@syma.uucp

leichter@CS.YALE.EDU (Jerry Leichter) (08/08/89)

In article <1217@syma.sussex.ac.uk>, leilabd@syma.sussex.ac.uk
  (Leila Burrell-Davis) writes...
>On leaving a program, I'd like to put the keyboard back into the same
>state it was in at the start, in particular the numeric keypad into
>either applications or numeric mode. Can anyone tell me if ANSI/DEC
>terminals will report this information and, if not, suggest how I
>might do this?

There is no ANSI-specified code for determining this state.  In fact, I don't
believe the ANSI spec has anything to say about applications vs. numeric mode
at all - these are DEC extensions dating back to the original VT100 (actually
to the VT52, though the encoding used was changed to be ANSI-compatible when
the VT100 replaced the VT52).

DEC VT300-series terminals support the ability to read the state of all the
terminal settings, keypad mode among them.  I forget the exact name of the
control sequence involved.  This feature was added in the VT300's, and is not
in any earlier DEC terminal.  (As the person who originally spec'ed this
functionality - after having failed to convince people of its importance at
the time the VT200's were designed - I'm very aware of the distinction!)

I don't know whether any 3rd-party ANSI- or VT200-compatible vendors have
defined similar extensions for their products; I don't recall ever seeing
any, however.  Of course, any correct VT300-compatible will have to support
the DEC-defined extensions.
							-- Jerry

bph@buengc.BU.EDU (Blair P. Houghton) (08/09/89)

In article <1217@syma.sussex.ac.uk> leilabd@syma.sussex.ac.uk (Leila Burrell-Davis) writes:
>On leaving a program, I'd like to put the keyboard back into the same
>state it was in at the start, in particular the numeric keypad into
>either applications or numeric mode. Can anyone tell me if ANSI/DEC
>terminals will report this information and, if not, suggest how I
>might do this?

I don't see it explicitly.  Here's an experiment, though:

According to my vt340 programmers' manual, which may be applicable only
to vt300's for this feature, (but who can tell with DEC's "go fish"
documentation-organizational style) you might try a Terminal Status
Report (called DECTSR, I don't know if the ANSI name for it exists):

	CSI 1 $ u

(CSI is ^[[, most places; spaces are for readability only and should
not be inserted, but you know that, right?)

Which will send back 196 bytes of data on the terminal status (essentially
everything determinate about it) which are of the form 0100xxxx in binary;
i.e., the 4 MSB's are always 0100, and the 4 LSB's indicate the value.

The data come back as

	DCS 1 $ s d ..d    <cksum1><cksum2> ST
                   1   196

(DCS and ST are control sequences, as is CSI.)

What the checksums look like, I have no idea.  "Look for the ST" is
my advice.

I see no information on decoding the TSR.  You just put it back when you
want the terminal back the way it was (shades of setjmp() :-) ) with
a DECRSTS:

        DCS 1 $ d ...d    ST
                 1    196

Notice that the checksums are gone.  Oboy is this gonna be fun to
program...

There is a note warning that the format of the report is not compatible
for all vt300's, so you couldn't, say, snarf the setup on yours and
send it to your friend Freddy and expect it to auto-configure his.

				--Blair
				  "I just wanna turn off my vt220
				   without losing the user-defined-
				   keys... :-("

gwyn@smoke.BRL.MIL (Doug Gwyn) (08/09/89)

In article <69006@yale-celray.yale.UUCP> leichter@CS.YALE.EDU (Jerry Leichter) writes:
>In article <1217@syma.sussex.ac.uk>, leilabd@syma.sussex.ac.uk
>  (Leila Burrell-Davis) writes...
>>On leaving a program, I'd like to put the keyboard back into the same
>>state it was in at the start, in particular the numeric keypad ...
>There is no ANSI-specified code for determining this state.  ...

The right answer, as usual, is another question:  How did you alter the
state in the first place?  There should be inverse operators for whatever
you did.  Termcap and terminfo have official enter/leave various-mode
capability definitions, for example.