home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 428_02 / libsrc / pushcurs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-13  |  940 b   |  50 lines

  1. /*
  2. ** pushcurs.c
  3. **
  4. ** Pictor, Version 1.51, Copyright (c) 1992-94 SoftCircuits
  5. ** Redistributed by permission.
  6. */
  7.  
  8. #include "pictor.h"
  9.  
  10. #define STACK_SIZE   10
  11. static struct {
  12.     int ctype;
  13.     int cpos;
  14. } cstack[STACK_SIZE];
  15.  
  16. static int curr = 0;
  17.  
  18. /*
  19. ** Saves the cursor location and style so that it can later be
  20. ** restored using popcurs. Returns TRUE if successful, FALSE if
  21. ** the stack is full.
  22. */
  23. int pushcurs(void)
  24. {
  25.     if(curr < STACK_SIZE) {
  26.         cstack[curr].ctype = getcurstype();
  27.         cstack[curr].cpos = getcurs();
  28.         curr++;
  29.         return(TRUE);
  30.     }
  31.     return(FALSE);
  32.  
  33. } /* pushcurs */
  34.  
  35. /*
  36. ** Restores the cursor saved by last call to pushcurs.
  37. ** Returns TRUE if successful, FALSE if stack is empty.
  38. */
  39. int popcurs(void)
  40. {
  41.     if(curr > 0) {
  42.         curr--;
  43.         setcurstype(cstack[curr].ctype);
  44.         setcurs(cstack[curr].cpos >> 8,cstack[curr].cpos & 0xFF);
  45.         return(TRUE);
  46.     }
  47.     return(FALSE);
  48.  
  49. } /* popcurs */
  50.