home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 1.ddi / CLIB1.ZIP / WINDOW.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-07  |  2.7 KB  |  73 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - window.c
  3.  *
  4.  * function(s)
  5.  *        window - defines a rectangular area of the screen as a window
  6.  *                 and puts the cursor inside the window
  7.  *-----------------------------------------------------------------------*/
  8.  
  9. /*[]------------------------------------------------------------[]*/
  10. /*|                                                              |*/
  11. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  12. /*|                                                              |*/
  13. /*|                                                              |*/
  14. /*|     Copyright (c) 1987,1988,1990 by Borland International    |*/
  15. /*|     All Rights Reserved.                                     |*/
  16. /*|                                                              |*/
  17. /*[]------------------------------------------------------------[]*/
  18.  
  19. #include <_video.h>
  20. #include <conio.h>
  21.  
  22. /*---------------------------------------------------------------------*
  23.  
  24. Name            window - defines a rectangular area of the screen as a
  25.                          window and puts the cursor inside the window
  26.  
  27. Usage           void window(int left, int top, int right, int bottom);
  28.  
  29. Prototype in    conio.h
  30.  
  31. Description     window defines a text window on the screen.  If the
  32.                 coordinates are in any way invalid, the call to window()
  33.                 is ignored.
  34.  
  35.                 left and top are the screen coordinates of the upper left
  36.                 corner of the window.
  37.  
  38.                 right and bottom are the screen coordinates of the lower
  39.                 right corner.
  40.  
  41.                 The minimum size of the text window is 1 column by 1
  42.                 line. The default window is full screen, with these
  43.                 coordinates:
  44.  
  45.                         80-column mode: 1, 1, 80, 25
  46.                         40-column mode: 1, 1, 40, 25
  47.  
  48. Return value    None
  49.  
  50. *---------------------------------------------------------------------*/
  51. void window(int left, int top, int right, int bottom)
  52. {
  53.         left    -= 1;
  54.         right   -= 1;
  55.         top     -= 1;
  56.         bottom  -= 1;
  57.         /* consistency checking */
  58.         if (left < 0  || right >= _video.screenwidth   ||
  59.                 top  < 0  || bottom >= _video.screenheight ||
  60.                 (right - left < 0) || (bottom - top < 0)) return;
  61.  
  62.         _video.windowx1 = left;
  63.         _video.windowx2 = right;
  64.         _video.windowy1 = top;
  65.         _video.windowy2 = bottom;
  66.  
  67.         _DL = left;             /* position to window 1,1 */
  68.         _DH = top;
  69.         _AH = V_SET_CURSOR_POS;
  70.         _BH = 0;
  71.         _VideoInt();
  72. }
  73.