home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / progjour / 1991 / 04 / v_deacti.c < prev    next >
C/C++ Source or Header  |  1991-05-03  |  1KB  |  35 lines

  1. /*    v_deacti.c- Deactivate Viewport */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <conio.h>
  6. #include <tools/viewport.h>
  7.  
  8. int v_deactivate( viewport *v, int hide )
  9. {
  10.     /* Vclose() effectively sets the viewport back to its original,
  11.      * pristine condition, as if it had never been opened. vdeactivate()
  12.      * is less thorough. The contents of the window are saved in a local
  13.      * buffer, and if hide is true, the original underlying text is
  14.      * restored. A subsequent vopen() call restores the window to the
  15.      * condition it was in before the vdeactivate.
  16.      */
  17.  
  18.     if( v->magic != VMAGIC  ||  v->inactive )
  19.         return 0;
  20.  
  21.     v->inactive = 1;
  22.     if( !v->old_image )
  23.         if( !(v->old_image = VMALLOC(v->nrows*v->ncols*sizeof(int))))
  24.             return 0;
  25.     _v_save_scr( v->old_image, v->row, v->col, v->nrows, v->ncols );
  26.  
  27.     if( hide && v->savebuf )    /* Restore original text. */
  28.     {
  29.         _v_restore_scr( v->savebuf, v->row, v->col, v->nrows, v->ncols );
  30.         VFREE( v->savebuf );
  31.         v->savebuf = NULL;      /* Set savebuf null to tell v_open to */
  32.     }                           /* save underlying text on reopen.    */
  33.     return 1;
  34. }
  35.