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

  1. /*-----------------------------------------------------------------------*
  2.  * filename - movetext.c
  3.  *
  4.  * function(s)
  5.  *        movetext - copies text from one rectangle to another.
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*[]------------------------------------------------------------[]*/
  9. /*|                                                              |*/
  10. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  11. /*|                                                              |*/
  12. /*|                                                              |*/
  13. /*|     Copyright (c) 1987,1988,1990 by Borland International    |*/
  14. /*|     All Rights Reserved.                                     |*/
  15. /*|                                                              |*/
  16. /*[]------------------------------------------------------------[]*/
  17.  
  18. #include <_video.h>
  19. #include <conio.h>
  20.  
  21.  
  22. /*---------------------------------------------------------------------*
  23.  
  24. Name        movetext - copies text from one rectangle to another.
  25.  
  26. Usage        int movetext(int sx1, int sy1, int sx2, int sy2, int dx1, int dy1)
  27.  
  28. Prototype in    conio.h
  29.  
  30. Description     movetext copies the contents of the on screen rectangle
  31.                 {sx1, sy1, sx2, sy2} to a source rectangle of the same
  32.         dimensions which has its upper left hand corner at dx1, dy1.
  33.  
  34. Return value    on success, one is returned; zero is returned on failure.
  35.  
  36. *---------------------------------------------------------------------*/
  37. int movetext(int sx1, int sy1, int sx2, int sy2, int dx1, int dy1)
  38. {
  39.     int first, last, direction, y;
  40.  
  41.     if (!__validatexy(sx1,sy1,sx2,sy2) || !__validatexy(dx1,dy1,dx1+(sx2-sx1),dy1+(sy2-sy1)))
  42.         return 0;
  43.  
  44.     first = sy1;
  45.     last = sy2;
  46.     direction = 1;
  47.  
  48.     if (sy1 < dy1)
  49.     {
  50.         first = sy2;
  51.         last = sy1;
  52.         direction = -1;
  53.     }
  54.  
  55.     for (y = first; y != last + direction; y += direction)
  56.         __screenio(__vptr(dx1,dy1+(y-sy1)), __vptr(sx1,y), sx2-sx1+1);
  57.  
  58.     return 1;
  59. }
  60.