home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / CURS13_2.ZIP / SETMODE.C < prev    next >
Text File  |  1989-12-08  |  3KB  |  95 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 (...mcvax!enea!infovax!bl)    */
  10. /****************************************************************/
  11. /* BUT: this particular 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 modify its 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.2:    Style clean-up, rcsid[] string for maintenance:    881002    */
  24. /* 1.3:    MSC -W3, Turbo'C' -w -w-pro checkes:        881005    */
  25. /****************************************************************/
  26.  
  27. #include <curses.h>
  28. #include <curspriv.h>
  29.  
  30. struct cttyset
  31.   {
  32.   bool    been_set;
  33.   bool    oautocr;
  34.   bool    ocbreak;
  35.   bool    oecho;
  36.   bool    oraw;
  37.   };
  38.     
  39. char _curses_setmode_rcsid[] = "@(#)setmode.c v1.3 - 881005";
  40.  
  41. static    struct cttyset sh_tty = {FALSE};/* tty modes for shell_mode */
  42. static    struct cttyset pr_tty = {FALSE};/* tty modes for prog_mode  */
  43.  
  44. /****************************************************************/
  45. /* Def_prog_mode() saves the current tty status, to be recalled    */
  46. /* later by reset_prog_mode.                    */
  47. /****************************************************************/
  48.  
  49. void def_prog_mode()
  50.   {
  51.   pr_tty.been_set = TRUE;
  52.   pr_tty.oautocr = _cursvar.autocr;
  53.   pr_tty.ocbreak = _cursvar.cbreak;
  54.   pr_tty.oecho    = _cursvar.echo;
  55.   pr_tty.oraw    = _cursvar.raw;
  56.   } /* def_prog_mode */
  57.  
  58. /****************************************************************/
  59. /* Reset_prog_mode() resets tty modes to the values saved in a    */
  60. /* call to def_prog_mode.                    */
  61. /****************************************************************/
  62.  
  63. void reset_prog_mode()
  64.   {
  65.   if (pr_tty.been_set == TRUE)
  66.     {
  67.     _cursvar.autocr    = pr_tty.oautocr;
  68.     _cursvar.cbreak    = pr_tty.ocbreak;
  69.     _cursvar.echo    = pr_tty.oecho;
  70.     _cursvar.raw    = pr_tty.oraw;
  71.     } /* if */
  72.   } /* reset_prog_mode */
  73.  
  74. /****************************************************************/
  75. /* Def_shell_mode() saves the tty status, to be recalled by    */
  76. /* reset_shell_mode. A noop in PCcurses.            */
  77. /****************************************************************/
  78.  
  79. void def_shell_mode()
  80.   {
  81.   } /* def_shell_mode */
  82.  
  83. /****************************************************************/
  84. /* Reset_shell_mode() resets the tty status to the status it    */
  85. /* had before curses began.                    */
  86. /****************************************************************/
  87.  
  88. void reset_shell_mode()
  89.   {
  90.   _cursvar.autocr    = TRUE;
  91.   _cursvar.cbreak    = FALSE;
  92.   _cursvar.echo    = TRUE;
  93.   _cursvar.raw    = FALSE;
  94.   } /* reset_shell_mode */
  95.