122678Sdist /* 234677Sbostic * Copyright (c) 1981 Regents of the University of California. 334677Sbostic * All rights reserved. 434677Sbostic * 542655Sbostic * %sccs.include.redist.c% 622678Sdist */ 722678Sdist 822678Sdist #ifndef lint 9*58041Selan static char sccsid[] = "@(#)overwrite.c 5.13 (Berkeley) 02/18/93"; 1055973Sbostic #endif /* not lint */ 1122678Sdist 1255973Sbostic #include <ctype.h> 1355973Sbostic #include <curses.h> 1455984Sbostic #include <string.h> 152259Sarnold 162259Sarnold /* 1755973Sbostic * overwrite -- 1855973Sbostic * Writes win1 on win2 destructively. 192259Sarnold */ 2055973Sbostic int 212259Sarnold overwrite(win1, win2) 2255973Sbostic register WINDOW *win1, *win2; 2355973Sbostic { 2455973Sbostic register int x, y, endy, endx, starty, startx; 252259Sarnold 2655973Sbostic #ifdef DEBUG 2755973Sbostic __TRACE("overwrite: (%0.2o, %0.2o);\n", win1, win2); 2855973Sbostic #endif 2956238Selan starty = max(win1->begy, win2->begy); 3056238Selan startx = max(win1->begx, win2->begx); 3156238Selan endy = min(win1->maxy + win1->begy, win2->maxy + win2->begx); 3256238Selan endx = min(win1->maxx + win1->begx, win2->maxx + win2->begx); 3319890Sbloom if (starty >= endy || startx >= endx) 3457472Sbostic return (OK); 3555973Sbostic #ifdef DEBUG 3655973Sbostic __TRACE("overwrite: from (%d, %d) to (%d, %d)\n", 3755973Sbostic starty, startx, endy, endx); 3855973Sbostic #endif 3919890Sbloom x = endx - startx; 4019890Sbloom for (y = starty; y < endy; y++) { 41*58041Selan (void)memcpy( 4256238Selan &win2->lines[y - win2->begy]->line[startx - win2->begx], 43*58041Selan &win1->lines[y - win1->begy]->line[startx - win1->begx], 4456647Selan x * __LDATASIZE); 4556650Selan __touchline(win2, y, startx - win2->begx, endx - win2->begx, 4656650Selan 0); 4719890Sbloom } 4857472Sbostic return (OK); 492259Sarnold } 50