mark@cogent.UUCP (Captain Neptune) (07/24/87)
This is a very early version of "fnkey", a program which allows you to maintain function key settings in text files. It is device dependant in that it works only on the HP 2392a terminal and those terminals that are compatible in the way they program their function keys. "Fnkey" actually loads your specified labels and commands into the programmable function keys on your terminal. The function key configurations are held in "description files". Description files can be put in a central place, where all users can use them. Also, individual users can add description files of their own, either augmenting or overriding the main set of description files. Read the manual page for more details. Read the README file before doing anything. Good luck, keep me informed on how it goes. ihnp4!ptsfa!cogent!mark ----------------- cut here ---------------- cut here ---------------- #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create: # Makefile # README # fnkey.1 # fnkey.c # samples # This archive created: Wed Jul 22 23:02:02 1987 export PATH; PATH=/bin:/usr/bin:$PATH echo shar: "extracting 'Makefile'" '(608 characters)' if test -f 'Makefile' then echo shar: "will not over-write existing file 'Makefile'" else sed 's/^X//' << \SHAR_EOF > 'Makefile' XCFLAGS= -O XCC= cc XDESTDIR=/usr/local/bin XLIBDIR=/usr/local/lib XMANDIR=/usr/local/man/man1 X Xall: fnkey X Xfnkey: fnkey.o X $(CC) $(CFLAGS) fnkey.o -o fnkey X Xinstall: X strip fnkey X cp fnkey $(DESTDIR) X cp fnkey.1 $(MANDIR) X -mkdir $(LIBDIR) $(LIBDIR)/fnkey X -chmod +x $(LIBDIR) $(LIBDIR)/fnkey X Xsample: X -mkdir $HOME/.fnkey X -chmod +x $HOME/.fnkey X -cp samples/* $HOME/.fnkey X fnkey X @echo "\n\t\t***************************************\n\t\t** Warning: these samples need to be **\n\t\t** edited to suit your own needs ! ! **\n\t\t***************************************\n" X Xclean: X -rm -f fnkey *.o a.out core X SHAR_EOF if test 608 -ne "`wc -c < 'Makefile'`" then echo shar: "error transmitting 'Makefile'" '(should have been 608 characters)' fi fi echo shar: "extracting 'README'" '(3669 characters)' if test -f 'README' then echo shar: "will not over-write existing file 'README'" else sed 's/^X//' << \SHAR_EOF > 'README' XHello. X XThis is a very early version of "fnkey", a program which allows Xyou to maintain function key settings in text files. It is device Xdependant in that it works only on the HP 2392a terminal and Xthose terminals that are compatible in the way they program their Xfunction keys. Zentec makes a clone of this terminal and "fnkey" Xshould work on it as well. X X"Fnkey" actually loads your specified labels and commands into Xthe programmable function keys on your terminal. The function key Xconfigurations are held in "description files". Description files Xcan be put in a central place (created automatically when you Xinstall "fnkey"), where all users can use them. Also, individual Xusers can add description files of their own, either augmenting Xor overriding the main set of description files. Read the manual Xpage for more details. X XCurrently, "fnkey" requires that your current terminal driver be Xeither "hp2392" or "ansi-d" (a terminfo driver for using HP X2392a's in ANSI mode). X XNote: the "ansi-d" driver is included here as a freebie, since it Xis pertinent to the discussion; if any of you are sick and tired Xof the awful escape sequences in HP mode, try ANSI mode with this Xdriver. It might be helpful to you. X XAlthough this is an early version, it seems to run fairly well. XWhile I wouldn't call it a beta-test version, I would say that Xpeople who try it out should keep their eyes open for any odd Xbehavior (except for known bugs listed below) and inform me of Xtheir observations. X XI am willing to do some maintenance of the program, including the Xrelease of future versions with improvements/fixes that you Xsuggest to me. Please email your feedback, diffs of patches, etc. Xto this mail path: X Xihnp4!ptsfa!cogent!mark X X----------------------------------------------------------------- XKnown bugs/limitations: X X1. For each newline that is programmed into a function key, X"fnkey" leaks a newline to the screen, causing unsightly Xscrolling. It is probably HP's fault and not mine, but I am open Xto suggestions on how to supress the scrolling. X X2. "Fnkey" does not use terminfo entries. If it did, the hardware Xdependancy might be largely overcome. I don't know, however, if Xterminfo has enough smarts for this, however. It can handle Xfunction keys that emit a fixed escape sequence, but a sequence Xto load a programmable function key? Hmmm... X X3. Some programs will not see all the characters that you program Xyour function key to send (since they have a short delay then Xflush the input buffer, etc...). An example of this is in the X"rn" news reader when you try to type "cy" (the catchup command Xplus "yes" verification). You can program a function key to Xoutput "cy", but "rn" will not see the letter "y". Again, not Xreally the fault of "fnkey" or the function keys, but I'm open to Xideas on how to get around it nonetheless. X X4. Given enough interest and/or advice from Unix PC users, I Xcould be persuaded to explore the possibilities of implementing X"fnkey" on the Unix PC. X X----------------------------------------------------------------- XTo compile and install: X XLook over the declarations in "Makefile", in case you want the Xexecutable, manual page, or whatever, to reside in a different Xplace. X Xmake - compiles the program X Xmake install - installs it (you must be root or super-user) X Xmake sample - loads sample "fnkey" description files into X "$HOME/.fnkey" for you to try out and tailor X to your own needs X Xmake clean - cleans up junk X X----------------------------------------------------------------- XGood luck, keep me informed on how it goes. SHAR_EOF if test 3669 -ne "`wc -c < 'README'`" then echo shar: "error transmitting 'README'" '(should have been 3669 characters)' fi fi echo shar: "extracting 'fnkey.1'" '(6081 characters)' if test -f 'fnkey.1' then echo shar: "will not over-write existing file 'fnkey.1'" else sed 's/^X//' << \SHAR_EOF > 'fnkey.1' X.TH Cogent Local "MSJ 7/16/87" X.SH NAME Xfnkey \- A user-defined function-key manager for \fIHP 2392a\fR terminals X(and clones) X.SH SYNOPSIS X.B fnkey X[ \fIfk_file\fR ] X.SH DESCRIPTION X.B Fnkey Xis a program which allows you to program function keys conveniently Xon \fIHP 2392a\fR terminals and any terminals which have compatible Xescape sequences. Details about how the function keys should be Xprogrammed are stored in a user-defined definition file X.I fk_file Xin the format described below. The definition file is read by X.B fnkey Xand the definitions are inserted into the terminals function key Xmemory automatically. If no definition file is specified, X.B fnkey Xuses the '\fIfn_default\fR' as the name of the definition file to Xread. Also, if '\fB\-\fR' is given as the definition file, then Xstandard input is read instead. X.PP X.B Fnkey Xlooks in the following places to find the definition file that has Xbeen specified, and in this order: X.nf X X - in the directory $FNKEY, if the environment variable X $FNKEY exists and if the directory exists X X - in the directory $H, if the environment variable X $H exists and if the directory exists X X - in the directory $H/.fnkey, if the environment X variable $H exists and if the directory exists X X - in the directory $HOME, if the environment variable X $HOME exists and if the directory exists X X - in the directory $HOME/.fnkey, if the environment X variable $HOME exists and if the directory exists X X - in the directory /usr/local/fnkeys, if it exists X X.fi XUpon finding a directory where the description file exists and is Xreadable, the search is ended and that file is used. X.SH "DESCRIPTION FILE FORMAT" XThe description file contains one or more lines, each of which defines Xone function key. Each line consists of four mandatory fields and an Xoptional fifth field, all of which are delimited by colons ('\fB:\fR'). XColons can not be a part of any field. X.PP XThe first field is a single numeric digit ranging from 1 to 8, Xspecifying the number of the function key. X.PP XThe second and third fields specify the contents of the upper and lower, Xrespectively, rows of the screen label for the specified function key. XThese fields should be padded with whatever leading spaces are desired, Xand their lengths must not exceed 8. The second field can be a '\fB*\fR', Xwhich causes the function key to be disabled. Either field can be null, Xwhich will appear on the screen as blank. X.PP XThe fourth field specifies the actual string which is to be output by the Xspecified function key. This field has no size limit (within reason) and Xcan include both leading and trailing spaces. If you wish for a carriage Xreturn to be automatically entered after the string (e.g. for a command Xwhich is to be executed in the shell), then a carriage return must be Ximbedded in this field (as shown in the next section). X.PP XA typical definition file might look like this: X.nf X X1:Get keys:for Tape:fnkey tape\\n X2:Read the:time:clock\\n:this is just a shell script X3:Who's on::who\\n X6:* X7:Check my:Process':ps -f\\n X8:Other:Process':ps -ef\\n X X.fi XIn the above example, the first function key would execute X.B fnkey Xin order to load function key definitions used for handling magnetic Xtapes. This pseudo-recursive use of X.B fnkey Xallows you to set up entire 'menus' of function keys. The second Xfunction key executes a shell script called 'clock'. The third function Xkey executes the 'who' command. Since there are no entries for function Xkeys 4 and 5, they will be unaffected and remain as they were. The sixth Xfunction key will be disabled and output merely a carriage return. The Xlast two function keys will execute the 'ps' command with various options. X XThe definition of function key 2 includes a comment field. All fourth Xfields have '\fB\\n\fR' at the end in order to assure that a carriage Xreturn is issued. There will, of course, be times when a carriage return Xis not preferred. An example would be this line: X.nf X X1:Delete:the line:dd X X.fi Xwhich would cause function key 1 to issue the 'delete line' command while Xediting with 'vi'. X.SH "IMBEDDED CHARACTERS" XIn the second, third and fourth fields of the description file, special Xcharacters can be imbedded by using '\fB^\fR' to imply control characters Xand '\fB\\\fR' to imply other special escape codes. For example: X.nf X X ^X - this would be interpreted as 'control-X' X X.fi XAny alphabetic character may follow the '\fB^\fR' in order to signify a Xcontrol character. This can be used, for example, to enter a 'control-D' Xinto the fourth field, for a 'logoff' function key: X.nf X X8:Log off:system:^D X X.fi XThe following uses of '\fB\\\fR' are supported: X.nf X X \\n - newline X X \\r - carriage return X X \\b - bell (^G) X X \\E - escape X X.fi XAny other characters placed after an '\fB\\\fR' will be interpreted Xliterally ('\fB\\\\\fR' would allow an '\fB\\\fR' to be a part of the Xfield, '\fB\\^\fR' would allow '\fB^\fR' to be a part of the field, etc). X.SH WARNINGS X.B Fnkey Xwill complain if your terminal is not capable of having it's function keys Xset or if the escape sequences of your terminal are not \fIHP 2392a\fR Xcompatible. The environment variable \fI$TERM\fR is checked to determine Xthis. X.SH BUGS XIn keeping with HP's policy of making their terminals braindamaged, the Xescape sequence to program function keys leaks carriage returns to the Xscreen. Thus, each occurance of a newline ('\fB\\n\fR') in a fourth field Xwill cause the cursor to drop down one line and possibly scroll. If you Ximbed this command in any screen-oriented programs, beware. You will Xprobably have to home the cursor, execute the X.B fnkey Xcommand, then reposition the cursor to wherever you had intended it to Xbe all this time. X.PP XThis program is device dependant. I will not adapt it to other Xterminals except for cases of my own personal preference. If you want Xit on a different terminal, then you must hack it yourself. Using X.I terminfo Xfor portability would be nice, but I don't know if it is capable of this Xstuff. X.SH AUTHOR XMark Steven Jeghers, Cogent Software Solutions, July 1987 SHAR_EOF if test 6081 -ne "`wc -c < 'fnkey.1'`" then echo shar: "error transmitting 'fnkey.1'" '(should have been 6081 characters)' fi fi echo shar: "extracting 'fnkey.c'" '(5393 characters)' if test -f 'fnkey.c' then echo shar: "will not over-write existing file 'fnkey.c'" else sed 's/^X//' << \SHAR_EOF > 'fnkey.c' X/**************************************************************** X * fnkey.c - a program to maintain function key definitions X * X * Author: Mark Steven Jeghers X * X * SCCS Version: @(#)fnkey.c 1.1 X * X * Last Modified: 07/22/87 22:46:59 X * Last Retrieved: 07/22/87 22:47:19 X * X * The author of "fnkey" grants permission to use and X * redistribute this program as long as these three conditions X * are met: X * X * 1. The program is not sold for profit, distributed for X * personal gain, or given to anyone else (unless it is X * given with ABSOLUTELY no strings attached and at NO X * expense to the recipient). X * X * 2. The contents of this box (title, version numbers, author X * info and terms of permissions) are left intact at the top X * of this program. X * X * 3. No other person takes credit for authorship of this program. X * X **************************************************************** X * X * Author's whereabouts: (last known whereabouts, at any rate...) X * X * Business Address: Home Address: X * ------------------------- ---------------------- X * Cogent Software Solutions Mark Jeghers X * 221 Tuxedo Ct. #F 2014 W. Willow X * Stockton CA 95204 Stockton CA 95203 X * (209) 467-0276 (209) 465-0391 X * X ****************************************************************/ X X#include <fcntl.h> X#include <stdio.h> X#include <string.h> X Xchar record[256]; X Xstatic char *TERM[] = { /* list of $TERM values we can deal with */ X "hp2392", X "ansi-d", X "*end*" /* <--- end of the list */ X }; X Xmain(argc, argv) Xint argc; Xchar *argv[]; X{ X int i, fd, termok = 0; X FILE *strm; X char fk_num[2]; X X for (i=0; strcmp(TERM[i], "*end*") != 0; i++) X if ((strcmp(TERM[i], getenv("TERM"))) == 0) X termok = 1; X X if (termok != 1) { X fprintf(stderr, "%s: Inadequate terminal type '%s'\n", argv[0], getenv("TERM")); X exit(1); X } X X if (argc == 2) { X if (strcmp(argv[1], "-") == 0) { /* hook stdin to fd */ X fd = dup(0); X close(0); X } else { /* open normal file */ X fd = find_open(argv[1]); X } X } else { X fd = find_open("fn_default"); X } X if (fd == -1) { X fprintf(stderr, "%s: Cannot open any source file\n", argv[0]); X exit(1); X } X strm = fdopen(fd, "r"); X X all_keys_off(); X X while (fgets(record, 256, strm) != NULL) { X if (strlen(record) > 1) { X parse(record, fk_num); X if ((atoi(fk_num) > 0) && (atoi(fk_num) < 9)) X process_key(fk_num); X else X complain(argv[0], fk_num); X } X } X X all_keys_on(); X X fclose(strm); X close(fd); X X exit(0); X} /* end of main */ X Xprocess_key(k_num) Xchar *k_num; X{ X char Label1[9], Label2[9], Command[99]; X X parse(record, Label1); X if (strcmp(Label1, "*") != 0) { X process_string(Label1); X pad(Label1, 8); X parse(record, Label2); X process_string(Label2); X pad(Label2, 8); X parse(record, Command); X process_string(Command); X } else { X strcpy(Label1, " "); X strcpy(Label2, " "); X strcpy(Command, "\n"); X } X output_fkey(k_num, Label1, Label2, Command); X} X Xoutput_fkey(k_num, L1, L2, Cmd) Xchar *k_num, *L1, *L2, *Cmd; X{ X char string[199], tmp[99]; X X strcpy(string, "\033&f"); X sprintf(tmp, "%dk", atoi(k_num)); X strcat(string, tmp); X strcat(string, "16d"); X sprintf(tmp, "%d\L", strlen(Cmd)); X strcat(string, tmp); X strcat(string, L1); X strcat(string, L2); X strcat(string, Cmd); X printf(string); X} X Xall_keys_on() X{ X printf("\033&jB"); X} X Xall_keys_off() X{ X printf("\033&j@"); X} X Xcomplain(pgname, k) Xchar *pgname, *k; X{ X fprintf(stderr, "%s: Invalid entry for key '%s'\n", pgname, k); X} X Xpad(str, len) Xchar *str; Xint len; X{ X while (strlen(str) < len) X strcat(str, " "); X} X Xprocess_string(str) Xchar *str; X{ X int i, j; X char escape(), control(); X X for (i=0; i<strlen(str); i++) { X switch(str[i]) { X case '\\': X str[i] = escape(str[i+1]); X for (j=i+1; j<strlen(str); j++) X str[j] = str[j+1]; X str[strlen(str)] = '\0'; X break; X case '^': X str[i] = control(str[i+1]); X for (j=i+1; j<strlen(str); j++) X str[j] = str[j+1]; X str[strlen(str)] = '\0'; X break; X } X } X} X Xchar escape(c) Xchar c; X{ X switch(c) { X case 'n': X return('\012'); X case 'r': X return('\015'); X case 'b': X return('\007'); X case 'E': X return('\033'); X } X return(c); X} X Xchar control(c) Xchar c; X{ X c = toupper(c); X return(c - 'A' + 1); X} X Xparse(rec, str) Xchar *rec, *str; X{ X int i = 0, j, k; X char *ptr1 = rec, *ptr2 = rec; X X while ((ptr1[0] != ':') && (ptr1[0] != '\012') && (ptr1[0] != '\0')) X ptr1++; X while (ptr2 != ptr1) { X str[i] = ptr2[0]; X ptr2++; X i++; X } X str[i] = '\0'; X k = strlen(rec); /* get it now because it will change!! */ X for (j=0; j != k-i; j++) X rec[j] = rec[j+i+1]; X} X Xfind_open(file) Xchar *file; X{ X int fd; X X if (getenv("FNKEY") != NULL) { X if ((fd = chk_path(getenv("FNKEY"), file)) != -1) X return(fd); X } X if (getenv("H") != NULL) { X if ((fd = chk_path(getenv("H"), file)) != -1) X return(fd); X if ((fd = chk_path(strcat(getenv("H"), "/.fnkey"), file)) != -1) X return(fd); X } X if (getenv("HOME") != NULL) { X if ((fd = chk_path(getenv("HOME"), file)) != -1) X return(fd); X if ((fd = chk_path(strcat(getenv("HOME"), "/.fnkey"), file)) != -1) X return(fd); X } X if ((fd = chk_path("/usr/local/lib/fnkey", file)) != -1) X return(fd); X X return(-1); X} X Xchk_path(dir, file) Xchar *dir, *file; X{ X int fd; X char path[99]; X X strcpy(path, dir); X strcat(path, "/"); X strcat(path, file); X if (access(path, 4) == 0) { X return(fd = open(path, O_RDONLY)); X } else { X return(-1); X } X} X SHAR_EOF if test 5393 -ne "`wc -c < 'fnkey.c'`" then echo shar: "error transmitting 'fnkey.c'" '(should have been 5393 characters)' fi fi if test ! -d 'samples' then echo shar: "creating directory 'samples'" mkdir 'samples' fi echo shar: "entering directory 'samples'" cd 'samples' echo shar: "extracting 'dial'" '(274 characters)' if test -f 'dial' then echo shar: "will not over-write existing file 'dial'" else sed 's/^X//' << \SHAR_EOF > 'dial' X1:Hook to: Modem:cu -s2400 -m -lcul0p1\n X2: Manual: Dial:cu -s2400 X3: Call: Jersey:cu nj\n: often used X4: Call: Argo:cu argo\n: often used X5: Call:Stockton:cu stkn\n: seldom used X6: Call:Winston:cu ws\n: seldom used X7:Back to:top set:fnkey\n X8: Logoff:or Exit:exit\n SHAR_EOF if test 274 -ne "`wc -c < 'dial'`" then echo shar: "error transmitting 'dial'" '(should have been 274 characters)' fi fi echo shar: "extracting 'fn_default'" '(236 characters)' if test -f 'fn_default' then echo shar: "will not over-write existing file 'fn_default'" else sed 's/^X//' << \SHAR_EOF > 'fn_default' X1: Go to:main set:fnkey main\n X2: Go to:UUCP set:fnkey uucp\n X3: Go to:dial set:fnkey dial\n X4: Go to:news set:fnkey news\n X5: Go to:unix set:fnkey unix\n X6: Go to: fun set:fnkey fun\n X7: Read:the Mail:mailx\n X8: Logoff:or Exit:exit\n SHAR_EOF if test 236 -ne "`wc -c < 'fn_default'`" then echo shar: "error transmitting 'fn_default'" '(should have been 236 characters)' fi fi echo shar: "extracting 'fun'" '(184 characters)' if test -f 'fun' then echo shar: "will not over-write existing file 'fun'" else sed 's/^X//' << \SHAR_EOF > 'fun' X1: Read a:fortune:fortune\n X2: Read a:Headline:spew\n X3: Play: Chess:chess\n X4: Play:Othello:othello\n X5: Play:Advnture:adv\n X6:* X7:Back to:top set:fnkey\n X8: Logoff:or Exit:exit\n SHAR_EOF if test 184 -ne "`wc -c < 'fun'`" then echo shar: "error transmitting 'fun'" '(should have been 184 characters)' fi fi echo shar: "extracting 'main'" '(262 characters)' if test -f 'main' then echo shar: "will not over-write existing file 'main'" else sed 's/^X//' << \SHAR_EOF > 'main' X1: Do a: uusnap:uusnap\n X2: Do a: uulog:uulog | tail\n X3: Call: Jersey:cu nj\n: often used X4: Call: Argo:cu argo\n: often used X5: Call:Stockton:cu stkn\n: seldom used X6: Call:Winston:cu ws\n: seldom used X7:Back to:top set:fnkey\n X8: Logoff:or Exit:exit\n SHAR_EOF if test 262 -ne "`wc -c < 'main'`" then echo shar: "error transmitting 'main'" '(should have been 262 characters)' fi fi echo shar: "extracting 'news'" '(297 characters)' if test -f 'news' then echo shar: "will not over-write existing file 'news'" else sed 's/^X//' << \SHAR_EOF > 'news' X1:Post new:article:!Pnews\n X2: Post:Followup:F:followup command in 'rn' X3:Reply by: Mail:R:reply command in 'rn' X4:Catch up:articles:c:catch-up command in 'rn' X5: Browse :articles:=:browse command in 'rn' X6: Quit: this:q:quit command in 'rn' X7:Back to:top set:fnkey\n X8: Logoff:or Exit:exit\n SHAR_EOF if test 297 -ne "`wc -c < 'news'`" then echo shar: "error transmitting 'news'" '(should have been 297 characters)' fi fi echo shar: "extracting 'tape'" '(357 characters)' if test -f 'tape' then echo shar: "will not over-write existing file 'tape'" else sed 's/^X//' << \SHAR_EOF > 'tape' X1:Read the: Tape:tape.read\n:a tape-reading script X2:Save out:my area:tape.save -u mark\n:a tape-saving script X3:|pipe to:tapesave: | tape.save\n:same as 2, but via pipeline X4:|pipe to:raw tape: | dd of=/dev/rmt/0m obs=5120\n X5:read in:raw tape:dd if=/dev/rmt/0m ibs=5120 X6:Back to:unix set:fnkey unix\n X7:Back to:top set:fnkey\n X8: Logoff:or Exit:exit\n SHAR_EOF if test 357 -ne "`wc -c < 'tape'`" then echo shar: "error transmitting 'tape'" '(should have been 357 characters)' fi fi echo shar: "extracting 'unix'" '(182 characters)' if test -f 'unix' then echo shar: "will not over-write existing file 'unix'" else sed 's/^X//' << \SHAR_EOF > 'unix' X1: Go to:Tape set:fnkey tape\n X2:Read the: time:date\n X3: Who is: on?:who\n X4: Disk: space?:df\n X5:Check my:Process':ps -f\n X6: Check:Process':ps -ef\n X7:Back to:top set:fnkey\n SHAR_EOF if test 182 -ne "`wc -c < 'unix'`" then echo shar: "error transmitting 'unix'" '(should have been 182 characters)' fi fi echo shar: "extracting 'uucp'" '(274 characters)' if test -f 'uucp' then echo shar: "will not over-write existing file 'uucp'" else sed 's/^X//' << \SHAR_EOF > 'uucp' X1: Do a: uusnap:uusnap\n X2: Do a: uulog:uulog | tail\n X3: Poll: Jersey:uupoll nj\n:often used X4: Poll: Argo:uupoll argo\n:often used X5: Poll:Stockton:uupoll stkn\n:seldom used X6: Poll:Winston:uupoll ws\n:seldom used X7:Back to:top set:fnkey\n X8: Logoff:or Exit:exit\n SHAR_EOF if test 274 -ne "`wc -c < 'uucp'`" then echo shar: "error transmitting 'uucp'" '(should have been 274 characters)' fi fi echo shar: "done with directory 'samples'" cd .. exit 0 # End of shell archive -- +----------------------------------------------------------------------------+ | Mark Steven Jeghers: the terrorist smuggling CIA weapons to Libya | | | | {ihnp4,cbosgd,lll-lcc,lll-crg}|{dual,ptsfa}!cogent!mark | | | | Standard Disclaimer: Contents may have settled during shipment. | +----------------------------------------------------------------------------+
amos@nsta.UUCP (Amos Shapir) (07/28/87)
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 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