Commit | Line | Data |
---|---|---|
87c6fcf8 | 1 | /* |
2f14f200 KB |
2 | * Copyright (c) 1981 Regents of the University of California. |
3 | * All rights reserved. | |
4 | * | |
e21c485a | 5 | * %sccs.include.redist.c% |
87c6fcf8 DF |
6 | */ |
7 | ||
8 | #ifndef lint | |
e21c485a | 9 | static char sccsid[] = "@(#)overlay.c 5.6 (Berkeley) %G%"; |
2f14f200 | 10 | #endif /* not lint */ |
87c6fcf8 | 11 | |
421683f2 | 12 | # include "curses.ext" |
d50ec87c KA |
13 | # include <ctype.h> |
14 | ||
15 | # define min(a,b) (a < b ? a : b) | |
700b1e78 | 16 | # define max(a,b) (a > b ? a : b) |
d50ec87c KA |
17 | |
18 | /* | |
19 | * This routine writes win1 on win2 non-destructively. | |
20 | * | |
d50ec87c KA |
21 | */ |
22 | overlay(win1, win2) | |
23 | reg WINDOW *win1, *win2; { | |
24 | ||
25 | reg char *sp, *end; | |
afe690b7 | 26 | reg int x, y, endy, endx, starty, startx; |
bd11b531 | 27 | reg int y1,y2; |
d50ec87c KA |
28 | |
29 | # ifdef DEBUG | |
30 | fprintf(outf, "OVERLAY(%0.2o, %0.2o);\n", win1, win2); | |
31 | # endif | |
52f06ac3 JB |
32 | starty = max(win1->_begy, win2->_begy); |
33 | startx = max(win1->_begx, win2->_begx); | |
34 | endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begx); | |
35 | endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx); | |
36 | # ifdef DEBUG | |
37 | fprintf(outf, "OVERLAY:from (%d,%d) to (%d,%d)\n", starty, startx, endy, endx); | |
38 | # endif | |
39 | if (starty >= endy || startx >= endx) | |
40 | return; | |
bd11b531 JB |
41 | y1 = starty - win1->_begy; |
42 | y2 = starty - win2->_begy; | |
43 | for (y = starty; y < endy; y++, y1++, y2++) { | |
44 | end = &win1->_y[y1][endx - win1->_begx]; | |
52f06ac3 | 45 | x = startx - win2->_begx; |
bd11b531 JB |
46 | for (sp = &win1->_y[y1][startx - win1->_begx]; sp < end; sp++) { |
47 | if (!isspace(*sp)) | |
48 | mvwaddch(win2, y2, x, *sp); | |
d50ec87c KA |
49 | x++; |
50 | } | |
51 | } | |
52 | } |