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

  1. /*-----------------------------------------------------------------------*
  2.  * filename - gptext.c
  3.  *
  4.  * function(s)
  5.  *        gettext  - gets a character block from screen
  6.  *        puttext  - puts a character block on the screen
  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            gettext  - gets a character block from screen
  25.  
  26. Usage           int gettext(int left, int top, int right, int bottom, void *buffer)
  27.  
  28. Prototype in    conio.h
  29.  
  30. Description     Reads the contents of the rectangle defined by its screen
  31.                 coordinate arguments and stores the characters and attribute
  32.                 bytes in the memory referenced by buffer.
  33.  
  34. Return value    On success, one is returned;  zero on failure.
  35.  
  36. *---------------------------------------------------------------------*/
  37. int gettext(int left, int top, int right, int bottom, void *buffer)
  38. {
  39.         int y, size;
  40.  
  41.         if (!__validatexy(left, top, right, bottom))
  42.                 return 0;
  43.  
  44.         size = right-left+1;
  45.         for (y = top; y <= bottom; y++)
  46.         {
  47.                 __screenio(buffer, __vptr(left, y), size);
  48.                 (char *)buffer += size*2;
  49.         }
  50.         return 1;
  51. }
  52.  
  53.  
  54. /*---------------------------------------------------------------------*
  55.  
  56. Name            puttext  - places a character block on screen
  57.  
  58. Usage           int puttext(int left, int top, int right, int bottom, void *buffer)
  59.  
  60. Prototype in    conio.h
  61.  
  62. Description     Places the contents of memory pointed to by buffer into
  63.                 the rectangle defined by its screen coordinate arguments.
  64.  
  65. Return value    On success, one is returned;  zero on failure.
  66.  
  67. *---------------------------------------------------------------------*/
  68. int puttext(int left, int top, int right, int bottom, void *buffer)
  69. {
  70.         int y, size;
  71.  
  72.         size = right-left+1;
  73.         for (y = top; y <= bottom; y++)
  74.         {
  75.                 __screenio(__vptr(left, y), buffer, size);
  76.                 (char *)buffer += size*2;
  77.         }
  78.         return 1;
  79. }
  80.