home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / C / CURSES.ZIP / KBDSTAT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1987-11-11  |  3.3 KB  |  87 lines

  1. /*#cdg#cursesdemo#******************************************************
  2. *                                                                      *
  3. *               Copyright 1987 Cygnus Development Group                *
  4. *                                                                      *
  5. *               This software is a proprietary product of              *
  6. *               the Cygnus Development Group (CDG).                    *
  7. *               ALL RIGHTS RESERVED                                    *
  8. *                                                                      *
  9. ************************************************************************
  10. *                                                                      *
  11. *       Purpose:                                                       *
  12. *                The executable demonstration program may be freely    *
  13. *       distributed.  The source code included on this disk, along     *
  14. *       with the 'readme.doc' file MUST be included with the           *
  15. *       program.  This program and its source code remain the          *
  16. *       property of the Cygnus Development Group, and may not be       *
  17. *       redistributed for profit, in whole or in part, without         *
  18. *       the express WRITTEN permission of the Cygnus Development       *
  19. *       Group.                                                         *
  20. *                                                                      *
  21. *                                                                      *
  22. ***********************************************************************/
  23.  
  24.  
  25.  
  26. #include <curses.h>
  27. #include <dostools.h>
  28. #include <xchars.h>
  29.  
  30.  
  31. /*********************************
  32.  *    Keyboard status routine...
  33.  */
  34.  
  35. static  WINDOW  *keyw = NULL;
  36.  
  37. int    update_status()
  38. {
  39.     if ( keyw ) {
  40.         mvwaddstr( keyw, 1, 17, left_shift ? "On " : "Off");
  41.         mvwaddstr( keyw, 2, 17, right_shift ? "On " : "Off");
  42.         mvwaddstr( keyw, 3, 17, ctrl_key ? "On " : "Off");
  43.         mvwaddstr( keyw, 4, 17, alt_key ? "On " : "Off");
  44.         mvwaddstr( keyw, 1, 39, caps_lock ? "On " : "Off");
  45.         mvwaddstr( keyw, 2, 39, num_lock ? "On " : "Off");
  46.         mvwaddstr( keyw, 3, 39, scroll_lock ? "On " : "Off");
  47.         mvwaddstr( keyw, 4, 39, insert ? "On " : "Off");
  48.         wrefresh( keyw);
  49.     }
  50. }
  51. /*
  52.  *    012345678901234567890123456789012345678901234
  53.  *    -|12345678901234567890123456|----------------
  54.  *    |  Left Shift:   xxx     Caps Lock:    xxx  |
  55.  *    |  Right Shift:  xxx     Num Lock:     xxx  |
  56.  *    |  Ctrl Shift:   xxx     Scroll Lock:  xxx  |
  57.  *    |  Alt Shift:    xxx     Insert:       xxx  |
  58.  *    ---------------------------------------------
  59.  */
  60.  
  61. int    build_status_window()
  62. {
  63.     if ( !keyw ) {
  64.         keyw = newwin( 6, 45, 1, 2);
  65.         wattrset( keyw, A_FG_BLACK | A_BG_CYAN);
  66.         wclear( keyw);
  67.         box( keyw, VS_LINE, HD_LINE);
  68.         leaveok( keyw, TRUE);
  69.         wmove( keyw, 0, 1);
  70.         wputch( keyw, R_HD_VS_TEE);
  71.         wstandout( keyw);
  72.         waddstr( keyw, " Current Keyboard Status ");
  73.         wstandend( keyw);
  74.         wputch( keyw, L_HD_VS_TEE);
  75.         mvwaddstr( keyw, 1, 3, "Left Shift:           Caps Lock:");
  76.          mvwaddstr( keyw, 2, 3, "Right Shift:          Num Lock:");
  77.          mvwaddstr( keyw, 3, 3, "Ctrl Shift:           Scroll Lock:");
  78.          mvwaddstr( keyw, 4, 3, "Alt Shift:            Insert:");
  79.     }
  80. }
  81.  
  82. int    delete_status_window()
  83. {
  84.     delwin( keyw);
  85.     keyw = NULL;
  86. }
  87.