home *** CD-ROM | disk | FTP | other *** search
- #include "jam.h"
- /*
- * Character class tables.
- * Do it yourself character classification
- * macros, that understand the multinational character set,
- * and let me ask some questions the standard macros (in
- * ctype.h) don't let you ask.
- */
- #include "def.h"
-
- /*
- * This table, indexed by a character drawn
- * from the 256 member character set, is used by my
- * own character type macros to answer questions about the
- * type of a character. It handles the full multinational
- * character set, and lets me ask some questions that the
- * standard "ctype" macros cannot ask.
- */
- #ifndef SOL_0
- static char cinfo[256] = {
- _C, _C, _C, _C, /* 0x0X */
- _C, _C, _C, _C,
- _C, _C, _C, _C,
- _C, _C, _C, _C,
- _C, _C, _C, _C, /* 0x1X */
- _C, _C, _C, _C,
- _C, _C, _C, _C,
- _C, _C, _C, _C,
- 0, _P, 0, 0, /* 0x2X */
- _W, _W, 0, _W,
- 0, 0, 0, 0,
- 0, 0, _P, 0,
- _D|_W, _D|_W, _D|_W, _D|_W, /* 0x3X */
- _D|_W, _D|_W, _D|_W, _D|_W,
- _D|_W, _D|_W, 0, 0,
- 0, 0, 0, _P,
- 0, _U|_W, _U|_W, _U|_W, /* 0x4X */
- _U|_W, _U|_W, _U|_W, _U|_W,
- _U|_W, _U|_W, _U|_W, _U|_W,
- _U|_W, _U|_W, _U|_W, _U|_W,
- _U|_W, _U|_W, _U|_W, _U|_W, /* 0x5X */
- _U|_W, _U|_W, _U|_W, _U|_W,
- _U|_W, _U|_W, _U|_W, 0,
- 0, 0, 0, 0,
- 0, _L|_W, _L|_W, _L|_W, /* 0x6X */
- _L|_W, _L|_W, _L|_W, _L|_W,
- _L|_W, _L|_W, _L|_W, _L|_W,
- _L|_W, _L|_W, _L|_W, _L|_W,
- _L|_W, _L|_W, _L|_W, _L|_W, /* 0x7X */
- _L|_W, _L|_W, _L|_W, _L|_W,
- _L|_W, _L|_W, _L|_W, 0,
- 0, 0, 0, 0,
- _W, _W, _W, _W, /* 0x8X */
- _W, _W, _W, _W,
- _W, _W, _W, _W,
- _W, _W, _W, _W,
- _W, _W, _W, _W, /* 0x9X */
- _W, _W, _W, _W,
- _W, _W, _W, 0,
- 0, 0, 0, 0,
- _W, _W, _W, _W, /* 0xAX */
- _W, _W, _W, _W,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0, /* 0xBX */
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0, /* 0xCX */
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0, /* 0xDX */
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0, /* 0xEX */
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0, /* 0xFX */
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- };
- #endif
-
- /* I like my stuff static; use this access func. (JAM)
- */
- #ifndef SOL_0
- char getcinfo(c)
- int c;
- {
- return(cinfo[c]);
- }
- #endif
-
- /*
- * Find the name of a keystroke. Needs to be changed to handle 8-bit printing
- * characters and function keys better. Returns a pointer to the terminating
- * '\0'.
- */
-
- char *mykeyname(cp, k)
- register char *cp;
- register int k;
- {
- register char *np = "unknown key";
-
- if (k < 0)
- k = CHARMASK(k); /* sign extended char */
-
- switch(k) {
- case CCHR('@'):
- np = "NUL";
- break;
- case CCHR('I'):
- np = "TAB";
- break;
- case CCHR('J'):
- np = "LFD";
- break; /* yuck, but that's what GNU calls it */
- case CCHR('M'):
- np = "RET";
- break;
- case CCHR('['):
- np = "ESC";
- break;
- case ' ':
- np = "SPC";
- break; /* yuck again */
- case CCHR('?'):
- np = "DEL";
- break;
- default:
-
- if(k >= KFIRST && k <= KLAST &&
- (np = (char *)getkeystrings(k - KFIRST)) != NULL)
- break;
-
- if(k > CCHR('?')) {
- *cp++ = '0';
- *cp++ = (char)(((k>>6)&7) + '0');
- *cp++ = (char)(((k>>3)&7) + '0');
- *cp++ = (char)((k&7) + '0');
- *cp = '\0';
- return cp;
- }
- if(k < ' ') {
- *cp++ = 'C';
- *cp++ = '-';
- k = CCHR(k);
- if(ISUPPER(k))
- k = TOLOWER(k);
- }
- *cp++ = (char)k;
- *cp = '\0';
- return cp;
- }
- (VOID) strcpy(cp, np);
- return cp + strlen(cp);
- }
-
- findkeyfromstring(p)
- char *p;
- {
- int i = KFIRST;
-
- for (i = KFIRST; i <= KLAST; i++)
- if (strcmp(p, getkeystrings(i - KFIRST)) == 0)
- return(i);
- return(-1);
- }
-