home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / cprog / cursesp.zip / UNCTRL.C < prev    next >
C/C++ Source or Header  |  1991-12-02  |  3KB  |  56 lines

  1. /****************************************************************/
  2. /* Unctrl() routines of the PCcurses package                    */
  3. /*                                                              */
  4. /****************************************************************/
  5. /* This version of curses is based on ncurses, a curses version */
  6. /* originally written by Pavel Curtis at Cornell University.    */
  7. /* I have made substantial changes to make it run on IBM PC's,  */
  8. /* and therefore consider myself free to make it public domain. */
  9. /*              Bjorn Larsson (...mcvax!enea!infovax!bl)        */
  10. /****************************************************************/
  11. /*                   IMPLEMENTATION NOTE                        */
  12. /* The conversion from a control character to a two-character   */
  13. /* sequence is done by the unctrl() function. In the BSD ver-   */
  14. /* sion of curses it is done by a macro, which uses a publi-    */
  15. /* cally available translation table. Some ill-behaved appli-   */
  16. /* cation programs use the table directly, and since it does    */
  17. /* not exist in this curses version such application will link  */
  18. /* with an error message complainting about undefined symbols.  */
  19. /****************************************************************/
  20. /* 1.0: Release:                                        870515  */
  21. /* 1.2: Rcsid[] string for maintenance:                 881002  */
  22. /* 1.3: MSC -W3, Turbo'C' -w -w-pro checkes:            881005  */
  23. /****************************************************************/
  24.  
  25. #include <curses.h>
  26. #include <curspriv.h>
  27.  
  28. static char     strbuf[3] = {0,0,0};
  29.  
  30. char _curses_unctrl_rcsid[] = "@(#)unctrl.c v1.3 - 881005";
  31.  
  32. /****************************************************************/
  33. /* Unctrl() returns a char pointer to a string corresponding to */
  34. /* argument character 'c'.                                      */
  35. /****************************************************************/
  36.  
  37. char *unctrl(c)
  38.   char c;
  39.   {
  40.   int ic = c;
  41.   ic &= 0xff;
  42.   
  43.   if ((ic >= ' ') && (ic != 0x7f))              /* normal characters */
  44.     {
  45.     strbuf[0] = (char) ic;
  46.     strbuf[1] = '\0';
  47.     return(strbuf);
  48.     } /* if */
  49.   strbuf[0] = '^';                              /* '^' prefix */
  50.   if (c == 0x7f)                                /* DEL */
  51.     strbuf[1] = '?';
  52.   else                                          /* other control */
  53.     strbuf[1] = ((char) ic) + '@';
  54.   return(strbuf);
  55.   } /* unctrl */
  56.