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[] = "@(#)overlay.c 5.6 (Berkeley) 06/01/90"; 10 #endif /* not lint */ 11 12 # include "curses.ext" 13 # include <ctype.h> 14 15 # define min(a,b) (a < b ? a : b) 16 # define max(a,b) (a > b ? a : b) 17 18 /* 19 * This routine writes win1 on win2 non-destructively. 20 * 21 */ 22 overlay(win1, win2) 23 reg WINDOW *win1, *win2; { 24 25 reg char *sp, *end; 26 reg int x, y, endy, endx, starty, startx; 27 reg int y1,y2; 28 29 # ifdef DEBUG 30 fprintf(outf, "OVERLAY(%0.2o, %0.2o);\n", win1, win2); 31 # endif 32 starty = max(win1->_begy, win2->_begy); 33 startx = max(win1->_begx, win2->_begx); 34 endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begx); 35 endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx); 36 # ifdef DEBUG 37 fprintf(outf, "OVERLAY:from (%d,%d) to (%d,%d)\n", starty, startx, endy, endx); 38 # endif 39 if (starty >= endy || startx >= endx) 40 return; 41 y1 = starty - win1->_begy; 42 y2 = starty - win2->_begy; 43 for (y = starty; y < endy; y++, y1++, y2++) { 44 end = &win1->_y[y1][endx - win1->_begx]; 45 x = startx - win2->_begx; 46 for (sp = &win1->_y[y1][startx - win1->_begx]; sp < end; sp++) { 47 if (!isspace(*sp)) 48 mvwaddch(win2, y2, x, *sp); 49 x++; 50 } 51 } 52 } 53