1 /*
2 * Copyright (c) 1981, 1993, 1994
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.2 (Berkeley) 05/04/94";
10 #endif /* not lint */
11
12 #include <ctype.h>
13 #include <string.h>
14
15 #include "curses.h"
16
17 /*
18 * overwrite --
19 * Writes win1 on win2 destructively.
20 */
21 int
overwrite(win1,win2)22 overwrite(win1, win2)
23 register WINDOW *win1, *win2;
24 {
25 register int x, y, endy, endx, starty, startx;
26
27 #ifdef DEBUG
28 __CTRACE("overwrite: (%0.2o, %0.2o);\n", win1, win2);
29 #endif
30 starty = max(win1->begy, win2->begy);
31 startx = max(win1->begx, win2->begx);
32 endy = min(win1->maxy + win1->begy, win2->maxy + win2->begx);
33 endx = min(win1->maxx + win1->begx, win2->maxx + win2->begx);
34 if (starty >= endy || startx >= endx)
35 return (OK);
36 #ifdef DEBUG
37 __CTRACE("overwrite: from (%d, %d) to (%d, %d)\n",
38 starty, startx, endy, endx);
39 #endif
40 x = endx - startx;
41 for (y = starty; y < endy; y++) {
42 (void)memcpy(
43 &win2->lines[y - win2->begy]->line[startx - win2->begx],
44 &win1->lines[y - win1->begy]->line[startx - win1->begx],
45 x * __LDATASIZE);
46 __touchline(win2, y, startx - win2->begx, endx - win2->begx,
47 0);
48 }
49 return (OK);
50 }
51