home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / CURSOR.C < prev    next >
C/C++ Source or Header  |  1997-07-05  |  4KB  |  90 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*****************************************************************/
  4. /**   CURSOR()                                                  **/
  5. /**   ARGUMENTS: A char variable identifying what to do with    **/
  6. /**              the cursor.                                    **/
  7. /**   RETURN: none                                              **/
  8. /**                                                             **/
  9. /**   DESCRIPTION:  This function receives a character which    **/
  10. /**                 tells it to do one of several things.       **/
  11. /**                 Turn the cursor on or off, change its size, **/
  12. /**                 save the cursor size & position, restore the**/
  13. /**                 size, restore the position, or restore both.**/
  14. /**                                                             **/
  15. /**   COMMANDS:   'S' - Save cursor size and position           **/
  16. /**               'R' - Restore cursor size and position        **/
  17. /**               'P' - Restore cursor position                 **/
  18. /**               'Z' - Restore cursor size                     **/
  19. /**               'H' - Hide cursor (cursor off)                **/
  20. /**               'O' - Cursor on                               **/
  21. /**               'N' - Cursor normal (same  as 'O')            **/
  22. /**               'B' - Cursor big                              **/
  23. /**                                                             **/
  24. /**   BY Bill Wilkie, 1988; Bob Stout, 1995                     **/
  25. /*****************************************************************/
  26.  
  27. #include <dos.h>
  28. #include <ctype.h>
  29. #include "cursor.h"
  30.  
  31. static unsigned position;       /* global to hold cursor position*/
  32. static unsigned size;           /* global to hold cursor size    */
  33.  
  34. void cursor(int tmp)
  35. {
  36.       union REGS inregs,outregs;                /* cpu registers */
  37.  
  38.       switch (toupper(tmp))
  39.       {
  40.       case 'S' :                             /* SAVE CURSOR DATA */
  41.             inregs.h.ah = 3;    /* read cursor position and size */
  42.             inregs.h.bh = 0;                   /* from page zero */
  43.             int86(0x10,&inregs,&outregs);
  44.             position = outregs.x.dx;           /* store position */
  45.             size = outregs.x.cx;                   /* store size */
  46.             break;
  47.  
  48.       case 'P' :                      /* RESTORE CURSOR POSITION */
  49.             inregs.h.ah = 2;              /* set cursor position */
  50.             inregs.h.bh = 0;                     /* on page zero */
  51.             inregs.x.dx = position;      /* at this old position */
  52.             int86(0x10,&inregs,&outregs);
  53.             break;
  54.  
  55.       case 'R' :               /* RESTORE CURSOR SIZE & POSITION */
  56.             inregs.h.ah = 2;              /* set cursor position */
  57.             inregs.h.bh = 0;                     /* on page zero */
  58.             inregs.x.dx = position;      /* at this old position */
  59.             int86(0x10,&inregs,&outregs);
  60.             /* fall through to... */
  61.  
  62.       case 'Z' :                          /* RESTORE CURSOR SIZE */
  63.             inregs.h.ah = 1;                  /* set cursor size */
  64.             inregs.x.cx = size;                /* to saved value */
  65.             int86(0x10,&inregs,&outregs);
  66.             break;
  67.  
  68.       case 'H' :                                   /* CURSOR OFF */
  69.             inregs.h.ah = 1;                  /* set cursor size */
  70.             inregs.h.ch = 0x20;      /* set bit turns cursor off */
  71.             int86(0x10,&inregs,&outregs);
  72.             break;
  73.  
  74.       case 'O' :                                    /* CURSOR ON */
  75.       case 'N' :                                /* CURSOR NORMAL */
  76.             inregs.h.ah = 1;                  /* set cursor size */
  77.             inregs.h.ch = 6;                /* cursor start line */
  78.             inregs.h.cl = 7;                  /* cursor end line */
  79.             int86(0x10,&inregs,&outregs);
  80.             break;
  81.  
  82.       case 'B' :                                   /* CURSOR BIG */
  83.             inregs.h.ah = 1;                  /* set cursor size */
  84.             inregs.h.ch = 4;                /* cursor start line */
  85.             inregs.h.cl = 7;                  /* cursor end line */
  86.             int86(0x10,&inregs,&outregs);
  87.             break;
  88.       }
  89. }
  90.