1 /* 2 * Copyright (c) 1981, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)overwrite.c 8.1 (Berkeley) 06/04/93"; 10 #endif /* not lint */ 11 12 #include <ctype.h> 13 #include <curses.h> 14 #include <string.h> 15 16 /* 17 * overwrite -- 18 * Writes win1 on win2 destructively. 19 */ 20 int 21 overwrite(win1, win2) 22 register WINDOW *win1, *win2; 23 { 24 register int x, y, endy, endx, starty, startx; 25 26 #ifdef DEBUG 27 __CTRACE("overwrite: (%0.2o, %0.2o);\n", win1, win2); 28 #endif 29 starty = max(win1->begy, win2->begy); 30 startx = max(win1->begx, win2->begx); 31 endy = min(win1->maxy + win1->begy, win2->maxy + win2->begx); 32 endx = min(win1->maxx + win1->begx, win2->maxx + win2->begx); 33 if (starty >= endy || startx >= endx) 34 return (OK); 35 #ifdef DEBUG 36 __CTRACE("overwrite: from (%d, %d) to (%d, %d)\n", 37 starty, startx, endy, endx); 38 #endif 39 x = endx - startx; 40 for (y = starty; y < endy; y++) { 41 (void)memcpy( 42 &win2->lines[y - win2->begy]->line[startx - win2->begx], 43 &win1->lines[y - win1->begy]->line[startx - win1->begx], 44 x * __LDATASIZE); 45 __touchline(win2, y, startx - win2->begx, endx - win2->begx, 46 0); 47 } 48 return (OK); 49 } 50