move entry/exit debugging to 21.1
[unix-history] / usr / src / lib / libcurses / overlay.c
CommitLineData
87c6fcf8 1/*
826389f4 2 * Copyright (c) 1981, 1993, 1994
c8a0275f 3 * The Regents of the University of California. All rights reserved.
2f14f200 4 *
e21c485a 5 * %sccs.include.redist.c%
87c6fcf8
DF
6 */
7
8#ifndef lint
826389f4 9static char sccsid[] = "@(#)overlay.c 8.2 (Berkeley) %G%";
17120706 10#endif /* not lint */
87c6fcf8 11
17120706 12#include <ctype.h>
826389f4
KB
13
14#include "curses.h"
d50ec87c
KA
15
16/*
17120706
KB
17 * overlay --
18 * Writes win1 on win2 non-destructively.
d50ec87c 19 */
17120706 20int
d50ec87c 21overlay(win1, win2)
17120706
KB
22 register WINDOW *win1, *win2;
23{
d50ec87c 24
17120706 25 register int x, y, y1, y2, endy, endx, starty, startx;
1c04a491 26 register __LDATA *sp, *end;
d50ec87c 27
17120706 28#ifdef DEBUG
14a0061d 29 __CTRACE("overlay: (%0.2o, %0.2o);\n", win1, win2);
17120706 30#endif
0c5c5188
EA
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);
17120706 35#ifdef DEBUG
14a0061d 36 __CTRACE("overlay: from (%d,%d) to (%d,%d)\n",
17120706
KB
37 starty, startx, endy, endx);
38#endif
52f06ac3 39 if (starty >= endy || startx >= endx)
79ec5a07 40 return (OK);
0c5c5188
EA
41 y1 = starty - win1->begy;
42 y2 = starty - win2->begy;
bd11b531 43 for (y = starty; y < endy; y++, y1++, y2++) {
0c5c5188
EA
44 end = &win1->lines[y1]->line[endx - win1->begx];
45 x = startx - win2->begx;
46 for (sp = &win1->lines[y1]->line[startx - win1->begx];
47 sp < end; sp++) {
1c04a491 48 if (!isspace(sp->ch)) {
1589e7d3 49 wmove(win2, y2, x);
1c04a491 50 __waddch(win2, sp);
1589e7d3 51 }
d50ec87c
KA
52 x++;
53 }
54 }
79ec5a07 55 return (OK);
d50ec87c 56}