open and flock defines changed
[unix-history] / usr / src / lib / libcurses / overlay.c
CommitLineData
421683f2 1# include "curses.ext"
d50ec87c
KA
2# include <ctype.h>
3
4# define min(a,b) (a < b ? a : b)
700b1e78 5# define max(a,b) (a > b ? a : b)
d50ec87c
KA
6
7/*
8 * This routine writes win1 on win2 non-destructively.
9 *
700b1e78 10 * %G% (Berkeley) @(#)overlay.c 1.4
d50ec87c
KA
11 */
12overlay(win1, win2)
13reg WINDOW *win1, *win2; {
14
15 reg char *sp, *end;
afe690b7 16 reg int x, y, endy, endx, starty, startx;
d50ec87c
KA
17
18# ifdef DEBUG
19 fprintf(outf, "OVERLAY(%0.2o, %0.2o);\n", win1, win2);
20# endif
afe690b7
KA
21 starty = max(win1->_begy, win2->_begy) - win1->_begy;
22 startx = max(win1->_begx, win2->_begx) - win1->_begx;
23 endy = min(win1->_maxy, win2->_maxy) - win1->_begy - 1;
24 endx = min(win1->_maxx, win2->_maxx) - win1->_begx - 1;
d50ec87c
KA
25 for (y = starty; y < endy; y++) {
26 end = &win1->_y[y][endx];
27 x = startx + win1->_begx;
28 for (sp = &win1->_y[y][startx]; sp <= end; sp++) {
29 if (!isspace(*sp))
30 mvwaddch(win2, y + win1->_begy, x, *sp);
31 x++;
32 }
33 }
34}