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.13 (Berkeley) 05/16/93"; 10 #endif /* not lint */ 11 12 #include <ctype.h> 13 #include <curses.h> 14 15 /* 16 * overlay -- 17 * Writes win1 on win2 non-destructively. 18 */ 19 int 20 overlay(win1, win2) 21 register WINDOW *win1, *win2; 22 { 23 24 register int x, y, y1, y2, endy, endx, starty, startx; 25 register __LDATA *sp, *end; 26 27 #ifdef DEBUG 28 __CTRACE("overlay: (%0.2o, %0.2o);\n", win1, win2); 29 #endif 30 starty = max(win1->begy, win2->begy); 31 startx = max(win1->begx, win2->begx); 32 endy = min(win1->maxy + win1->begy, win2->maxy + win2->begx); 33 endx = min(win1->maxx + win1->begx, win2->maxx + win2->begx); 34 #ifdef DEBUG 35 __CTRACE("overlay: from (%d,%d) to (%d,%d)\n", 36 starty, startx, endy, endx); 37 #endif 38 if (starty >= endy || startx >= endx) 39 return (OK); 40 y1 = starty - win1->begy; 41 y2 = starty - win2->begy; 42 for (y = starty; y < endy; y++, y1++, y2++) { 43 end = &win1->lines[y1]->line[endx - win1->begx]; 44 x = startx - win2->begx; 45 for (sp = &win1->lines[y1]->line[startx - win1->begx]; 46 sp < end; sp++) { 47 if (!isspace(sp->ch)) { 48 wmove(win2, y2, x); 49 __waddch(win2, sp); 50 } 51 x++; 52 } 53 } 54 return (OK); 55 } 56