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