1*22684Sdist /* 2*22684Sdist * Copyright (c) 1980 Regents of the University of California. 3*22684Sdist * All rights reserved. The Berkeley software License Agreement 4*22684Sdist * specifies the terms and conditions for redistribution. 5*22684Sdist */ 6*22684Sdist 7*22684Sdist #ifndef lint 8*22684Sdist static char sccsid[] = "@(#)toucholap.c 5.1 (Berkeley) 06/07/85"; 9*22684Sdist #endif not lint 10*22684Sdist 1119897Sbloom # include "curses.ext" 1219897Sbloom 1319897Sbloom # define min(a,b) (a < b ? a : b) 1419897Sbloom # define max(a,b) (a > b ? a : b) 1519897Sbloom 1619897Sbloom /* 1719897Sbloom * Touch, on win2, the part that overlaps with win1. 1819897Sbloom * 1919897Sbloom */ 2019897Sbloom touchoverlap(win1, win2) 2119897Sbloom reg WINDOW *win1, *win2; { 2219897Sbloom 2319897Sbloom reg int x, y, endy, endx, starty, startx; 2419897Sbloom 2519897Sbloom # ifdef DEBUG 2619897Sbloom fprintf(outf, "TOUCHOVERLAP(%0.2o, %0.2o);\n", win1, win2); 2719897Sbloom # endif 2819897Sbloom starty = max(win1->_begy, win2->_begy); 2919897Sbloom startx = max(win1->_begx, win2->_begx); 3019897Sbloom endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begx); 3119897Sbloom endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx); 3219897Sbloom # ifdef DEBUG 3319897Sbloom fprintf(outf, "TOUCHOVERLAP:from (%d,%d) to (%d,%d)\n", starty, startx, endy, endx); 3419897Sbloom fprintf(outf, "TOUCHOVERLAP:win1 (%d,%d) to (%d,%d)\n", win1->_begy, win1->_begx, win1->_begy + win1->_maxy, win1->_begx + win1->_maxx); 3519897Sbloom fprintf(outf, "TOUCHOVERLAP:win2 (%d,%d) to (%d,%d)\n", win2->_begy, win2->_begx, win2->_begy + win2->_maxy, win2->_begx + win2->_maxx); 3619897Sbloom # endif 3719897Sbloom if (starty >= endy || startx >= endx) 3819897Sbloom return; 3919897Sbloom starty -= win2->_begy; 4019897Sbloom startx -= win2->_begx; 4119897Sbloom endy -= win2->_begy; 4219897Sbloom endx -= win2->_begx; 4319897Sbloom endx--; 4419897Sbloom for (y = starty; y < endy; y++) 4519897Sbloom touchline(win2, y, startx, endx); 4619897Sbloom } 47