122684Sdist /* 2*34677Sbostic * Copyright (c) 1981 Regents of the University of California. 3*34677Sbostic * All rights reserved. 4*34677Sbostic * 5*34677Sbostic * Redistribution and use in source and binary forms are permitted 6*34677Sbostic * provided that this notice is preserved and that due credit is given 7*34677Sbostic * to the University of California at Berkeley. The name of the University 8*34677Sbostic * may not be used to endorse or promote products derived from this 9*34677Sbostic * software without specific prior written permission. This software 10*34677Sbostic * is provided ``as is'' without express or implied warranty. 1122684Sdist */ 1222684Sdist 1322684Sdist #ifndef lint 14*34677Sbostic static char sccsid[] = "@(#)toucholap.c 5.2 (Berkeley) 06/08/88"; 15*34677Sbostic #endif /* not lint */ 1622684Sdist 1719897Sbloom # include "curses.ext" 1819897Sbloom 1919897Sbloom # define min(a,b) (a < b ? a : b) 2019897Sbloom # define max(a,b) (a > b ? a : b) 2119897Sbloom 2219897Sbloom /* 2319897Sbloom * Touch, on win2, the part that overlaps with win1. 2419897Sbloom * 2519897Sbloom */ 2619897Sbloom touchoverlap(win1, win2) 2719897Sbloom reg WINDOW *win1, *win2; { 2819897Sbloom 2919897Sbloom reg int x, y, endy, endx, starty, startx; 3019897Sbloom 3119897Sbloom # ifdef DEBUG 3219897Sbloom fprintf(outf, "TOUCHOVERLAP(%0.2o, %0.2o);\n", win1, win2); 3319897Sbloom # endif 3419897Sbloom starty = max(win1->_begy, win2->_begy); 3519897Sbloom startx = max(win1->_begx, win2->_begx); 3619897Sbloom endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begx); 3719897Sbloom endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx); 3819897Sbloom # ifdef DEBUG 3919897Sbloom fprintf(outf, "TOUCHOVERLAP:from (%d,%d) to (%d,%d)\n", starty, startx, endy, endx); 4019897Sbloom fprintf(outf, "TOUCHOVERLAP:win1 (%d,%d) to (%d,%d)\n", win1->_begy, win1->_begx, win1->_begy + win1->_maxy, win1->_begx + win1->_maxx); 4119897Sbloom fprintf(outf, "TOUCHOVERLAP:win2 (%d,%d) to (%d,%d)\n", win2->_begy, win2->_begx, win2->_begy + win2->_maxy, win2->_begx + win2->_maxx); 4219897Sbloom # endif 4319897Sbloom if (starty >= endy || startx >= endx) 4419897Sbloom return; 4519897Sbloom starty -= win2->_begy; 4619897Sbloom startx -= win2->_begx; 4719897Sbloom endy -= win2->_begy; 4819897Sbloom endx -= win2->_begx; 4919897Sbloom endx--; 5019897Sbloom for (y = starty; y < endy; y++) 5119897Sbloom touchline(win2, y, startx, endx); 5219897Sbloom } 53