home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 332_01 / setmode.c < prev    next >
C/C++ Source or Header  |  1990-01-06  |  3KB  |  97 lines

  1. /****************************************************************/
  2. /* Terminal mode 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 make it public domain.    */
  9. /*                Bjorn Larsson (bl@infovox.se)    */
  10. /****************************************************************/
  11. /* BUT: this particualr module was written by            */
  12. /*    N. Dean Pentcheff  (dean@violet.berkeley.edu)        */
  13. /* It provides PC Curses versions of:                */
  14. /*    reset_prog_mode();                    */
  15. /*    reset_shell_mode();                    */
  16. /*    set_prog_mode();                    */
  17. /*    set_shell_mode();                    */
  18. /*                                */
  19. /* B. Larsson took the liberty to mofify it's style slightly    */
  20. /* when incorporating it into PCcurses v.1.2. The routines in    */
  21. /* this module do a similar thing to savetty() and resetty().    */
  22. /****************************************************************/
  23. /* 1.4:  Use of short wherever possible. Portability        */
  24. /*     improvements:                    900114    */
  25. /* 1.3:     MSC -W3, Turbo'C' -w -w-pro checkes:        881005    */
  26. /* 1.2:     Style clean-up, rcsid[] string for main-        */
  27. /*     tenance:                    881002    */
  28. /****************************************************************/
  29.  
  30. #include <curses.h>
  31. #include <curspriv.h>
  32.  
  33. struct cttyset
  34.   {
  35.   bool    been_set;
  36.   bool    oautocr;
  37.   bool    ocbreak;
  38.   bool    oecho;
  39.   bool    oraw;
  40.   };
  41.     
  42. char _curses_setmode_rcsid[] = "@(#)setmode.c    v.1.4  - 900114";
  43.  
  44. static    struct cttyset pr_tty = {FALSE};/* tty modes for prog_mode  */
  45.  
  46. /****************************************************************/
  47. /* Def_prog_mode() saves the current tty status, to be recalled    */
  48. /* later by reset_prog_mode.                    */
  49. /****************************************************************/
  50.  
  51. void def_prog_mode()
  52.   {
  53.   pr_tty.been_set = TRUE;
  54.   pr_tty.oautocr = _cursvar.autocr;
  55.   pr_tty.ocbreak = _cursvar.cbreak;
  56.   pr_tty.oecho    = _cursvar.echo;
  57.   pr_tty.oraw    = _cursvar.raw;
  58.   } /* def_prog_mode */
  59.  
  60. /****************************************************************/
  61. /* Reset_prog_mode() resets tty modes to the values saved in a    */
  62. /* call to def_prog_mode.                    */
  63. /****************************************************************/
  64.  
  65. void reset_prog_mode()
  66.   {
  67.   if (pr_tty.been_set == TRUE)
  68.     {
  69.     _cursvar.autocr    = pr_tty.oautocr;
  70.     _cursvar.cbreak    = pr_tty.ocbreak;
  71.     _cursvar.echo    = pr_tty.oecho;
  72.     _cursvar.raw    = pr_tty.oraw;
  73.     } /* if */
  74.   } /* reset_prog_mode */
  75.  
  76. /****************************************************************/
  77. /* Def_shell_mode() saves the tty status, to be recalled by    */
  78. /* reset_shell_mode. A noop in PCcurses.            */
  79. /****************************************************************/
  80.  
  81. void def_shell_mode()
  82.   {
  83.   } /* def_shell_mode */
  84.  
  85. /****************************************************************/
  86. /* Reset_shell_mode() resets the tty status to the status it    */
  87. /* had before curses began.                    */
  88. /****************************************************************/
  89.  
  90. void reset_shell_mode()
  91.   {
  92.   _cursvar.autocr    = TRUE;
  93.   _cursvar.cbreak    = FALSE;
  94.   _cursvar.echo    = TRUE;
  95.   _cursvar.raw    = FALSE;
  96.   } /* reset_shell_mode */
  97.