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 | |
8 | static char sccsid[] = "@(#)overlay.c 5.1 (Berkeley) %G%"; | |
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; |
d50ec87c KA |
26 | |
27 | # ifdef DEBUG | |
28 | fprintf(outf, "OVERLAY(%0.2o, %0.2o);\n", win1, win2); | |
29 | # endif | |
52f06ac3 JB |
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 | # ifdef DEBUG | |
35 | fprintf(outf, "OVERLAY:from (%d,%d) to (%d,%d)\n", starty, startx, endy, endx); | |
36 | # endif | |
37 | if (starty >= endy || startx >= endx) | |
38 | return; | |
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 | for (y = starty; y < endy; y++) { | |
46 | end = &win1->_y[y - win1->_begy][endx - win1->_begx]; | |
47 | x = startx - win2->_begx; | |
48 | for (sp = &win1->_y[y][startx - win1->_begx]; sp < end; sp++) { | |
49 | if (!isspace(*sp)) { | |
50 | waddch(win2, y - win2->_begy, x); | |
51 | waddch(win2, *sp); | |
52 | } | |
d50ec87c KA |
53 | x++; |
54 | } | |
55 | } | |
56 | } |