4.4BSD snapshot (revision 8.1); add 1993 to copyright
[unix-history] / usr / src / lib / libcurses / toucholap.c
CommitLineData
87c6fcf8 1/*
2f14f200
KB
2 * Copyright (c) 1981 Regents of the University of California.
3 * All rights reserved.
4 *
7e3eac84 5 * %sccs.include.redist.c%
87c6fcf8
DF
6 */
7
8#ifndef lint
14a0061d 9static char sccsid[] = "@(#)toucholap.c 5.11 (Berkeley) %G%";
2f14f200 10#endif /* not lint */
87c6fcf8 11
4569b94e 12#include <curses.h>
08c23e5e
JB
13
14/*
4569b94e 15 * touchoverlap --
08c23e5e 16 * Touch, on win2, the part that overlaps with win1.
08c23e5e 17 */
4569b94e 18int
08c23e5e 19touchoverlap(win1, win2)
4569b94e
KB
20 register WINDOW *win1, *win2;
21{
a2af4b61 22 register int y, endy, endx, starty, startx;
08c23e5e 23
4569b94e 24#ifdef DEBUG
14a0061d 25 __CTRACE("touchoverlap: (%0.2o, %0.2o);\n", win1, win2);
4569b94e 26#endif
0c5c5188
EA
27 starty = max(win1->begy, win2->begy);
28 startx = max(win1->begx, win2->begx);
29 endy = min(win1->maxy + win1->begy, win2->maxy + win2->begx);
30 endx = min(win1->maxx + win1->begx, win2->maxx + win2->begx);
4569b94e 31#ifdef DEBUG
14a0061d 32 __CTRACE("touchoverlap: from (%d,%d) to (%d,%d)\n",
4569b94e 33 starty, startx, endy, endx);
14a0061d 34 __CTRACE("touchoverlap: win1 (%d,%d) to (%d,%d)\n",
0c5c5188
EA
35 win1->begy, win1->begx, win1->begy + win1->maxy,
36 win1->begx + win1->maxx);
14a0061d 37 __CTRACE("touchoverlap: win2 (%d,%d) to (%d,%d)\n",
0c5c5188
EA
38 win2->begy, win2->begx, win2->begy + win2->maxy,
39 win2->begx + win2->maxx);
4569b94e 40#endif
08c23e5e 41 if (starty >= endy || startx >= endx)
79ec5a07 42 return (OK);
0c5c5188
EA
43 starty -= win2->begy;
44 startx -= win2->begx;
45 endy -= win2->begy;
46 endx -= win2->begx;
4569b94e 47 for (--endx, y = starty; y < endy; y++)
e3923e32 48 __touchline(win2, y, startx, endx, 0);
79ec5a07 49 return (OK);
08c23e5e 50}
e3923e32 51