diff options
author | phk <phk@FreeBSD.org> | 2006-05-17 09:33:15 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2006-05-17 09:33:15 +0000 |
commit | 537a82e24b165d002f904dd1bbc454533a2021cd (patch) | |
tree | b9d1ad42ae7e0437e274339e458aab20bcb025d4 /usr.sbin/pcvt/userkeys | |
parent | 2d778391877a5dfddee23a04baf6b08ba0984db5 (diff) | |
download | FreeBSD-src-537a82e24b165d002f904dd1bbc454533a2021cd.zip FreeBSD-src-537a82e24b165d002f904dd1bbc454533a2021cd.tar.gz |
Send the pcvt(4) driver off to retirement.
Diffstat (limited to 'usr.sbin/pcvt/userkeys')
-rw-r--r-- | usr.sbin/pcvt/userkeys/Makefile | 5 | ||||
-rw-r--r-- | usr.sbin/pcvt/userkeys/vt220keys.1 | 175 | ||||
-rw-r--r-- | usr.sbin/pcvt/userkeys/vt220keys.c | 287 |
3 files changed, 0 insertions, 467 deletions
diff --git a/usr.sbin/pcvt/userkeys/Makefile b/usr.sbin/pcvt/userkeys/Makefile deleted file mode 100644 index 66fe022..0000000 --- a/usr.sbin/pcvt/userkeys/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# $FreeBSD$ - -PROG= vt220keys - -.include <bsd.prog.mk> diff --git a/usr.sbin/pcvt/userkeys/vt220keys.1 b/usr.sbin/pcvt/userkeys/vt220keys.1 deleted file mode 100644 index 35d80ca..0000000 --- a/usr.sbin/pcvt/userkeys/vt220keys.1 +++ /dev/null @@ -1,175 +0,0 @@ -.\" $FreeBSD$ -.\" -.Dd January 16, 2001 -.Dt VT220KEYS 1 -.Os -.Sh NAME -.Nm vt220keys -.Nd "define SHIFTED function keys on VT220 terminal" -.Sh SYNOPSIS -.Nm -.Op Fl cil -.Op Ar keyname keystring ... -.Sh DESCRIPTION -The -.Nm -utility sets up a -.Dq "vt220 terminal" -in vt200 mode to allow user -definition of the SHIFTED function keys. -Each -.Ar keyname -specified on the command line will be loaded with -the corresponding -.Ar keystring . -A -.Ar keyname -is one of the following words: -.Cm F6 F7 F8 F9 F10 F11 ESC -.Cm F12 BS F13 LF F14 HELP -.Cm DO F17 F18 F19 F20 . -.Ar Keystrings -must be quoted if spaces, tabs, or shell metacharacters are included. -.Pp -The -.Nm -utility expects to receive some combination of option flags and/or -argument pair(s), otherwise a usage message -is printed. -.Pp -The options are: -.Bl -tag -width indent -.It Fl c -Clears all SHIFTED function key definitions before setting them to user -defined strings. -.It Fl i -Read the initialization file -.Pa $HOME/.vt220rc -for SHIFTED function key definitions. -This is done before any -argument pair specified on the command line is processed. -Each line in the file must consist of two fields (separated by spaces -or tabs) where the first field is the -.Ar keyname -and the second field is the -.Ar keystring . -The second field extends to the end of the line, thus a -.Ar keystring -may include spaces or tabs. -A newline (return) may be specified -within the string by using the C Language notation for newline (\\n). -.It Fl l -Locks the function keys from further definition. -Locking occurs after processing the initialization file (if the -.Fl i -option is specified) and any argument -pairs. -The only way -to unlock is by turning the power off. -.El -.Sh FILES -.Bl -tag -width $HOME/.vt220rc -.It Pa $HOME/.vt220rc -initialization file -.El -.Sh EXAMPLES -.Bd -literal -vt220keys -ci -vt220keys F6 'nroff -ms ' -vt220keys -i F20 'cc -O -c ' -vt220keys -l HELP man -.Ed -.Sh "OTHER FEATURES" -Pressing the function keys without using the shift key, generates -a string of characters. -With -.Xr csh 1 -this string can be aliased to some command. -For example: -.Pp -.Dl alias\ ^[[17~\ "ls\ -CR\ |\ more" -.Pp -where -.Ql "^[[17~" -is what is generated by pressing the F6 key. -Therefore -F6 can perform two commands, depending if pressed with/without the SHIFT -key. -.Pp -The -.Nm -utility can be called from your -.Pa .login -or -.Pa .profile -file. -Typically an user -will create an initialization file and include a line like -.Pp -.Dl "vt220keys -ci" -OR -.Dl "vt220keys -cil" -.Pp -in the above mentioned files. -This way the SHIFTED function keys -will be set to your favorite commands when logging in. -.Sh CAVEATS -If the SHIFTED function keys are unlocked, redefinition of a SHIFTED -function key will rewrite the old string. -.Pp -There are 256 bytes available for the SHIFTED function keys. -Space is -supplied on a first\-come/first\-serve basis. -After the 256 bytes are -used, you cannot define any more keys unless space is cleared. -This -can be done by redefining a key to contain a string of fewer bytes. -.Pp -All key definitions are stored in volatile RAM, and are lost when -terminal power is lost. -.Pp -The ESC key (unshifted) no longer generates the proper escape character. -This -is of particular importance since many editors require use of the -ESC key. -Here are some available alternatives: -.Bl -bullet -.It -The escape character can be generated by typing -.Ql ^[ -(control\-[). -.It -Use -.Nm -as follows (note -.Ql ^[ -is control\-[) -.Pp -.Dl "vt220keys ESC '^['" -.Pp -This will require you -to press the SHIFT key and ESC to generate the escape sequence. -.It -Some editors, allow other character(s) to be substituted for the -escape character. -For example with -.Xr emacs 1 -include this line in your -.Pa .emacs_pro : -.Pp -.Dl (bind-to-key\ "ESC-prefix"\ "\\033[23~") -.Pp -Thus when the ESC key is pressed, -.Nm emacs -will allow the characters generated -.Pq Li ^[[23~ -to perform the same function as the escape -character. -.El -.Sh SEE ALSO -.Rs -.%B "VT220 Programmer Reference Manual" -.Re -.Rs -.%B "VT220 Programmer Pocket Guide" -.Re diff --git a/usr.sbin/pcvt/userkeys/vt220keys.c b/usr.sbin/pcvt/userkeys/vt220keys.c deleted file mode 100644 index e3fe90c..0000000 --- a/usr.sbin/pcvt/userkeys/vt220keys.c +++ /dev/null @@ -1,287 +0,0 @@ -/* - * Trivial program to load VT220 Function keys with strings, - * note that the values only get sent when the key is shifted - * (shoulda been an option to flip the shift set like the Z19!) - * - * Typing no args gives help, basically pairs of keyname/value - * strings. - * - * Author, Author: Barry Shein, Boston University - * - * HISTORY - {1} 30-Oct-85 Kenneth J. Lester (ken) at ektools - - Added the necessary code to read an initialization file. This - should make it easier to used this program. Also added code - that will set-up the terminal in vt200 (this saves the user the - trouble of checking if the set-up is in vt200). - - Restructed the main function to use getopt, for argument - processing. - - Alterated usage function to include new "i" option (init file) - - - -hm minor modifications for pcvt 2.0 release - -$FreeBSD$ -*/ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <ctype.h> -#include <unistd.h> - -/* - * The default toupper() macro is stupid, will toupper anything - */ - -#ifdef toupper -#undef toupper -#endif -#define toupper(c) (islower(c) ? ((c)-' ') : c) - -#define VT200_7BIT 1 -#define ESC 033 -#define INITFILE ".vt220rc" - -struct keynames { - char *name ; - char *string ; -} keys[] = { - "F6", "17", - "F7", "18", - "F8", "19", - "F9", "20", - "F10", "21", - "F11", "23", - "ESC", "23", - "F12", "24", - "BS", "24", - "F13", "25", - "LF", "25", - "F14", "26", - "HELP", "28", - "DO", "29", - "F17", "31", - "F18", "32", - "F19", "33", - "F20", "34", - NULL, NULL -}; - -char prog[BUFSIZ]; - -main(argc,argv) - int argc; - char *argv[]; -{ - int option; /* option character returned by getopt */ - int initf = 0; /* read initialization file */ - int lockf = 0; /* lock keys after loading strings */ - int clearf = 0; /* clear all keys before loading strings */ - - strlcpy(prog, *argv, sizeof(prog)); /* store program name */ - - if(argc == 1) usage(); /* program requires options */ - - /* get options */ - while ((option = getopt(argc, argv, "cli")) != -1) - switch(option) - { - case 'c' : - clearf++; - break; - case 'l' : - lockf++; - break; - case 'i' : - initf++; - break; - case '?' : - usage(); - } - - if (VT200_7BIT) - printf("\033[62;1\"p"); /* vt200 7 bits */ - else - printf("\033[62;2\"p"); /* vt200 8 bits */ - - if(clearf) clearkeys(); - - if (initf) getinit(); - - /* process {key, key string} pairs. Note optind is index to argv - for first pair. By adding 1 to optind insures that a pair exists - i.e. the last key has a key string. */ - - while(optind + 1 < argc) - { - dokey(argv[optind], argv[optind+1]); - optind += 2; - } - - if(lockf) lockkeys(); - - exit(0); -} - -/****************************************************************************/ - -/* - * Load the VT220 SHIFT-FNKEY value, the basic pattern is - * "\EP1;1|"+KEYNAME+"/"+VAL_AS_HEX+"\E\\" - * that is, literally what is in quotes (w/o quotes) then the - * name of the key from the keytable above (a numeric string) - * then a slash, then the string value as hex pairs then ESC-BACKSLASH - * - * Note: you can gang together key defns with semicolons but that - * would complicate things, especially error handling, so do it all - * for each pair, who cares, really. - */ - -dokey(nm,val) char *nm, *val; -{ - register char *scr; - register struct keynames *kp; - - for(scr = nm; *scr = toupper(*scr); scr++) - ; - for(kp = keys; kp->name != NULL; kp++) - if(strcmp(nm,kp->name) == 0) { - printf("%cP1;1|%s/",ESC,kp->string); - while(*val) printf("%02x",*val++); - printf("%c\\",ESC); - fflush(stdout); - return; - } - fprintf(stderr,"Bad key name: %s\n",nm); - usage(); /* bad key name, give up */ -} - -/****************************************************************************/ - -clearkeys() -{ - printf("%cP0;1|%c\\",ESC,ESC); - fflush(stdout); -} - -/****************************************************************************/ - -lockkeys() -{ - printf("%cP1;0|%c\\",ESC,ESC); - fflush(stdout); -} - -/****************************************************************************/ - -usage() -{ - int i; - - fprintf(stderr,"usage: %s [-cil] [keyname string keyname string...]\n\n",prog); - fprintf(stderr,"The following options are available\n"); - fprintf(stderr,"\t-c\tclears keys first\n"); - fprintf(stderr,"\t-l\t[sets then] locks further setting\n"); - fprintf(stderr,"\t-i\tfirst read initialization file $HOME/%s\n",INITFILE); - fprintf(stderr,"(note that the only way to unlock is via Set-Up)\n\n"); - fprintf(stderr,"Keyname is one of:\n\t"); - for(i=0; keys[i].name != NULL; i++) - fprintf(stderr,"%s ",keys[i].name); - fprintf(stderr,"\nKeyname is SHIFTED function key that sends the string\n\n"); - fprintf(stderr,"Strings may need quoting to protect from shell\n"); - fprintf(stderr,"You must specify an option or key,string pairs\n\n"); - exit(1); -} - -/****************************************************************************/ - -/* This routine process the INITFILE. This file expects lines in the format - - <ws> keyname ws string - - Where ws is white space (spaces or tabs) and <ws> is optional white space. - The string may include spaces or tabs and need not be quoted. If the - string has the sequence of "\n" then a newline character is included in - the string. - - examples: - - F6 ls -lg\n - F7 uulog -s - -*/ - -#include <sys/types.h> -#include <sys/stat.h> - -getinit() -{ - char *home; /* user's home directory */ - char path[BUFSIZ]; /* full path name of init file */ - char buf[BUFSIZ]; /* buffer to hold 1 line from init file */ - char key[BUFSIZ]; /* buffer, to hold specified fcn key */ - char keystr[BUFSIZ]; /* string associated with fcn key */ - char *ptr; /* pointer to transverse buf */ - int i, j; /* array indices */ - int statflag; /* whether init file is regular & readable */ - struct stat statbuf; /* stat of the init file */ - FILE *fp; /* file pointer to init file */ - - /* construct full path name for init file */ - home = getenv("HOME"); - snprintf(path, sizeof(path), "%s/%s", home, INITFILE); - - /* check status if init file */ - if (stat(path, &statbuf) != -1) - { - statflag = statbuf.st_mode & S_IFREG && statbuf.st_mode & S_IREAD; - if (!statflag || (fp = fopen(path, "r")) == NULL) - { - fprintf(stderr, "couldn't open initalization file: %s\n", path); - exit(1); - } - - /* process lines from init file */ - while (fgets(buf, BUFSIZ, fp) != NULL) - { - /* variable initializations */ - i = 0; j = 0; - key[0] = '\0'; keystr[0] = '\0'; - ptr = buf; - - while (*ptr == ' ' || *ptr == '\t') ptr++; /*skip whitespace*/ - - if (*ptr == '\n') break; /* we hit an emtpy line */ - - while (!isspace(*ptr) && *ptr != '\0') /* get keyname */ - key[i++] = *ptr++; - key[i] = '\0'; /* place EOS in buffer */ - - while (*ptr == ' ' || *ptr == '\t') ptr++; /*skip whitespace*/ - - while (*ptr != '\n' && *ptr != '\0') /* get string */ - { - /* check if string is to include newline i.e. \n */ - if (*ptr == '\\' && *(ptr+1) == 'n') - { - keystr[j] = '\012'; - ptr++; - } - else - keystr[j] = *ptr; - j++; ptr++; - } - keystr[j] = '\0'; /* place EOS in buffer */ - dokey(key, keystr); /* load key with string */ - } - } - else - { - fprintf(stderr, "init file %s not found\n\n", path); - usage(); - } -} |