home *** CD-ROM | disk | FTP | other *** search
- From: amos@nsta.UUCP (Amos Shapir)
- Newsgroups: comp.sources.misc
- Subject: Re: A Function Key maintenance program for HP2392a and clones
- Message-ID: <3654@ncoast.UUCP>
- Date: 28 Jul 87 00:24:56 GMT
- Sender: allbery@ncoast.UUCP
- Organization: National Semiconductor (Israel) Ltd. Home of the 32532
- Lines: 138
- Approved: allbery@ncoast.UUCP
- Summary: This one's for vt220 & clones
- X-Archive: comp.sources.misc/8707/68
-
- The above-mentioned program reminded me of a program I wrote to do exactly
- that on a TeleVideo 9220, which is basically a vt220 clone. This program
- also works on a real VT220, in 7 bits mode, but only for shifted function
- keys (the VT220 can't program unshifted keys). I didn't check it
- on other clones, but it's fairly standard.
-
- o / o / o / o /
- -----------------X---------------X---------------X---------------X----
- o \ o \ o \ o \
-
- #!/bin/sh
- # shar: Shell Archiver
- # Run the following text with /bin/sh to create:
- # tvprg.1
- # tvprg.c
- # This archive created: Sun Jul 26 09:55:59 1987
- sed 's/^X//' << \SHAR_EOF > tvprg.1
- X.TH TVPRG 1
- X.SH NAME
- Xtvprg \- program function keys of a TeleVideo 9220 terminal
- X.SH SYNOPSIS
- X.B tvprg
- X[-v] f\fIn\fP string
- X.PP
- X.B tvprg
- XF\fIn\fP string
- X.SH DESCRIPTION
- X.I Tvprg
- Xgenerates the escape sequence to program function key
- X.I n
- Xon the a TeleVideo 9220 terminal's keyboard,
- Xto send the given
- X.I string
- Xto the host.
- XIf the key name is given as F\fIn\fP, it will be programmed to send
- X.I string
- Xwhen shifted. Special (unprintable) characters are denoted by the
- Xback-slash ('\\') notation, as used in C.
- X.PP
- XProgrammable keys are f6 through f20;
- Xthe 'Help' and 'Do' keys are considered f15 and f16, respectively.
- X.PP
- XWith the
- X.B -v
- Xflag, the arguments are also echoed to the output after the programming
- Xsequence; this is useful as a comment when saving \fItvprg\fP's output
- Xin a file for future use.
- X.SH AUTHOR
- XAmos Shapir, NSTA
- X.SH "SEE ALSO"
- XTeleVideo 9220 Operator's Manual
- X.SH BUGS
- XDue to braindamage of the terminal's firmware, keys must be programmed
- Xin sequential order.
- SHAR_EOF
- sed 's/^X//' << \SHAR_EOF > tvprg.c
- X/* program TeleVideo9220's function keys */
- Xint vflg;
- Xmain(argc, argv)
- X char **argv;
- X{
- X register n, c;
- X register char *s;
- X
- X if(argc>1 && argv[1][0]=='-' && argv[1][1]=='v') {
- X vflg++;
- X argc--;
- X argv++;
- X }
- X if(argc!=3 || *(s=argv[1])!='f' && *s!='F'
- X || (n=atoi(s+1))<6 || n>20) {
- X puts("Usage: tvprg [-v] {fn,Fn} string\n");
- X exit(1);
- X }
- X n += 11;
- X if(n>=22)
- X ++n;
- X if(n>=27)
- X ++n;
- X if(n>=30)
- X ++n;
- X if(*s == 'f')
- X n += 20;
- X puts("\033P1;1;1|");
- X putb(n, 10);
- X putchar('/');
- X s = argv[2];
- X while(c = *s++) {
- X if(c=='\\')
- X switch(c = *s++) {
- X case 'b': c = '\b'; break;
- X case 't': c = '\t'; break;
- X case 'n': c = '\n'; break;
- X case 'v': c = '\v'; break;
- X case 'f': c = '\f'; break;
- X case 'r': c = '\r'; break;
- X default:
- X if(c>='0' && c<='7') {
- X --s;
- X for(n=c=0; n<3 && *s>='0' && *s<='7'; n++)
- X c = (c<<3)+*s++-'0';
- X }
- X }
- X putb(c, 16);
- X }
- X puts("\033\\");
- X if(vflg) {
- X puts(argv[1]);
- X puts(" = ");
- X puts(argv[2]);
- X }
- X puts("\n");
- X}
- X
- Xputb(n, b)
- X register n, b;
- X{
- X register c;
- X
- X c = n/b;
- X putchar(c+(c<=9?'0':'A'-10));
- X c = n%b;
- X putchar(c+(c<=9?'0':'A'-10));
- X}
- SHAR_EOF
- # End of shell archive
- exit 0
-
- o / o / o / o /
- -----------------X---------------X---------------X---------------X----
- o \ o \ o \ o \
- May the Source be with you, always...
- --
- Amos Shapir (My other cpu is a NS32532)
- National Semiconductor (Israel)
- 6 Maskit st. P.O.B. 3007, Herzlia 46104, Israel Tel. (972)52-522261
- amos%nsta@nsc.com @{hplabs,pyramid,sun,decwrl} 34 48 E / 32 10 N
-