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

  1. /*    v_size.c- Change the Viewport Size */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <conio.h>
  6. #include <tools/viewport.h>
  7.  
  8. int v_size( viewport *v, unsigned nrows, unsigned ncols )
  9. {
  10.     /* Change the viewport size. The viewport must be closed
  11.      * (not just deactivated) to change its size. False is
  12.      * returned and nothing happens if the viewport isn't
  13.      * closed, true otherwise.
  14.      */
  15.  
  16.     if( v->magic != VMAGIC  ||  !v->closed )
  17.         return 0;
  18.  
  19.     if( v->savebuf )            /* A differently sized save buffer is   */
  20.     {                           /* required for the new size. Will      */
  21.         VFREE( v->savebuf );    /* be allocated by v_open.              */
  22.         v->savebuf = NULL;
  23.     }
  24.     if( v->old_image )
  25.     {
  26.         VFREE( v->old_image );
  27.         v->old_image = NULL;
  28.     }
  29.     v->nrows = nrows;           /* Set up the new size. */
  30.     v->ncols = ncols;
  31.  
  32.     return 1;
  33. }
  34.