1 /* 2 * Copyright (c) 1981 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)overwrite.c 5.6 (Berkeley) 08/23/92"; 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 __TRACE("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 __TRACE("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 bcopy(&win1->_y[y - win1->_begy][startx - win1->_begx], 42 &win2->_y[y - win2->_begy][startx - win2->_begx], x); 43 touchline(win2, y, startx - win2->_begx, endx - win2->_begx); 44 } 45 return (OK); 46 } 47