home *** CD-ROM | disk | FTP | other *** search
/ vsiftp.vmssoftware.com / VSIPUBLIC@vsiftp.vmssoftware.com.tar / FREEWARE / FREEWARE40.ZIP / flistfrontend / src / chrcmd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-04  |  1.4 KB  |  77 lines

  1. #ifndef NO_IDENT
  2. static char *Id = "$Id: chrcmd.c,v 1.6 1995/06/04 18:49:02 tom Exp $";
  3. #endif
  4.  
  5. /*
  6.  * Title:    chrcmd.c
  7.  * Author:    Thomas E. Dickey
  8.  * Created:    14 Apr 1985
  9.  * Last update:
  10.  *        19 Feb 1995, prototyped
  11.  *
  12.  * Function:    Return a pointer to a string which interprets a code which
  13.  *        may be one of:
  14.  *
  15.  *        a) ASCII character (including a control)
  16.  *        b) A GETPAD-code
  17.  *        c) An FLIST sort-code
  18.  */
  19.  
  20. #include    <rms.h>
  21. #include    <stdio.h>
  22. #include    <ctype.h>
  23. #include    <string.h>
  24.  
  25. #include    "flist.h"
  26. #include    "getpad.h"
  27.  
  28. #include    "dircmd.h"
  29.  
  30. char    *chrcmd (int command)
  31. {
  32. int    j;
  33. static    char    bfr[30];
  34.  
  35. static    struct    {
  36.     int    code;
  37.     char    *show;
  38.     }    table[]    = {
  39.         '\r',        "<CR>",
  40.         '\b',        "<BS>",
  41.         '\n',        "<LF>",
  42.         '\177',        "<DEL>",
  43.         padUP,        "<up-arrow>",
  44.         padDOWN,    "<down-arrow>",
  45.         padLEFT,    "<left-arrow>",
  46.         padRIGHT,    "<right-arrow>",
  47.         padPF1,        "<PF1>",
  48.         padPF2,        "<PF2>",
  49.         padPF3,        "<PF3>",
  50.         padPF4,        "<PF4>",
  51.         padENTER,    "<ENTER>"
  52.     };
  53.  
  54.     for (j = 0; j < SIZEOF(table); j++)
  55.         if (table[j].code == command)    return (table[j].show);
  56.  
  57.     if (isascii (command))
  58.     {
  59.         if (iscntrl(command))
  60.             sprintf (bfr, "^%c", command | 0100);
  61.         else
  62.             sprintf (bfr, "%c", command);
  63.     }
  64.     else if (is_PAD(command))
  65.         sprintf (bfr, "<Keypad %c>", toascii(command));
  66. #if UNUSED
  67.     else if (is_sCMD(command))
  68.     {
  69.         command = toascii(command);
  70.         sprintf (bfr, "/%c%c", islower(command) ? 's' : 'r', command);
  71.     }
  72. #endif
  73.     else
  74.         strcpy (bfr, "<??>");
  75.     return (bfr);
  76. }
  77.