static char rcsid[] = "$Id: tokc.c,v 1.2 1992/12/28 00:41:32 mike Exp $"; /* $Log: tokc.c,v $ * Revision 1.2 1992/12/28 00:41:32 mike * - `Eto_keycode' returns 0 in case of an invalid key prefix. * - `Eto_keycode' recognizes the `A-' prefix. * * Revision 1.1 1992/09/14 13:02:14 mike * Initial revision * */ /* tokc.c : Convert a key string to KeyCode * For example: * "A" => A * "^A" => C-A * "C-A" => C-A * Input: * key_text : pointer to text to convert. * prefixable : * C Durland */ /* Copyright 1990, 1991 Craig Durland * Distributed under the terms of the GNU General Public License. * Distributed "as is", without warranties of any kind, but comments, * suggestions and bug reports are welcome. */ #include #include #include "ed.h" extern KeyCode Eprefixes[]; KeyCode Eto_keycode(pkeys,key_text,prefixable) PKey *pkeys; unsigned char *key_text; { register KeyCode keycode = 0; register unsigned char c; register int j; for (; c = *key_text; key_text++) { if (key_text[1] == '-') /* maybe its something like "C-A" */ { switch (c) { #ifdef atarist default: return 0; /* Wrong prefix */ #else default: goto next; /* must be just a dash */ #endif case 'C' : keycode |= CTRL; break; case 'F' : keycode |= SOFKEY; break; case 'M' : keycode |= META; break; case 'S' : keycode |= SHIFT; break; #ifdef atarist case 'A' : keycode |= PFIX2; break; #endif } key_text++; continue; } next: if (iscntrl(c)) keycode |= CTRL | (c ^ 0x40); else if ((keycode & (CTRL | META | PFIX1 | PFIX2 | PFIX3)) && (keycode & SOFKEY) == 0) keycode |= TOUPPER(c); else keycode |= c; if (prefixable) { for (j = PKEYS; j--; ) /* check for prefix keys */ if (keycode == pkeys[j]) { keycode = Eprefixes[j]; break; } prefixable = FALSE; } } return keycode; }