1 # include "curses.ext" 2 3 # define min(a,b) (a < b ? a : b) 4 # define max(a,b) (a > b ? a : b) 5 6 /* 7 * Touch, on win2, the part that overlaps with win1. 8 * 9 * @(#)toucholap.c 1.1 (Berkeley) 05/01/85 10 */ 11 touchoverlap(win1, win2) 12 reg WINDOW *win1, *win2; { 13 14 reg int x, y, endy, endx, starty, startx; 15 16 # ifdef DEBUG 17 fprintf(outf, "TOUCHOVERLAP(%0.2o, %0.2o);\n", win1, win2); 18 # endif 19 starty = max(win1->_begy, win2->_begy); 20 startx = max(win1->_begx, win2->_begx); 21 endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begx); 22 endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx); 23 # ifdef DEBUG 24 fprintf(outf, "TOUCHOVERLAP:from (%d,%d) to (%d,%d)\n", starty, startx, endy, endx); 25 fprintf(outf, "TOUCHOVERLAP:win1 (%d,%d) to (%d,%d)\n", win1->_begy, win1->_begx, win1->_begy + win1->_maxy, win1->_begx + win1->_maxx); 26 fprintf(outf, "TOUCHOVERLAP:win2 (%d,%d) to (%d,%d)\n", win2->_begy, win2->_begx, win2->_begy + win2->_maxy, win2->_begx + win2->_maxx); 27 # endif 28 if (starty >= endy || startx >= endx) 29 return; 30 starty -= win2->_begy; 31 startx -= win2->_begx; 32 endy -= win2->_begy; 33 endx -= win2->_begx; 34 endx--; 35 for (y = starty; y < endy; y++) 36 touchline(win2, y, startx, endx); 37 } 38