1 /* 2 * Copyright (c) 1981 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)toucholap.c 5.4 (Berkeley) 06/01/90"; 10 #endif /* not lint */ 11 12 # include "curses.ext" 13 14 # define min(a,b) (a < b ? a : b) 15 # define max(a,b) (a > b ? a : b) 16 17 /* 18 * Touch, on win2, the part that overlaps with win1. 19 * 20 */ 21 touchoverlap(win1, win2) 22 reg WINDOW *win1, *win2; { 23 24 reg int x, y, endy, endx, starty, startx; 25 26 # ifdef DEBUG 27 fprintf(outf, "TOUCHOVERLAP(%0.2o, %0.2o);\n", win1, win2); 28 # endif 29 starty = max(win1->_begy, win2->_begy); 30 startx = max(win1->_begx, win2->_begx); 31 endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begx); 32 endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx); 33 # ifdef DEBUG 34 fprintf(outf, "TOUCHOVERLAP:from (%d,%d) to (%d,%d)\n", starty, startx, endy, endx); 35 fprintf(outf, "TOUCHOVERLAP:win1 (%d,%d) to (%d,%d)\n", win1->_begy, win1->_begx, win1->_begy + win1->_maxy, win1->_begx + win1->_maxx); 36 fprintf(outf, "TOUCHOVERLAP:win2 (%d,%d) to (%d,%d)\n", win2->_begy, win2->_begx, win2->_begy + win2->_maxy, win2->_begx + win2->_maxx); 37 # endif 38 if (starty >= endy || startx >= endx) 39 return; 40 starty -= win2->_begy; 41 startx -= win2->_begx; 42 endy -= win2->_begy; 43 endx -= win2->_begx; 44 endx--; 45 for (y = starty; y < endy; y++) 46 touchline(win2, y, startx, endx); 47 } 48