home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 1.ddi / CLIBSRC1.ZIP / MOVETEXT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.7 KB  |  59 lines

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