1 /* 2 * Copyright (c) 1983 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 */ 17 18 #ifndef lint 19 static char sccsid[] = "@(#)wwadd.c 3.12 (Berkeley) 08/04/88"; 20 #endif /* not lint */ 21 22 #include "ww.h" 23 24 /* 25 * Stick w1 behind w2. 26 */ 27 wwadd(w1, w2) 28 register struct ww *w1; 29 struct ww *w2; 30 { 31 register i; 32 register struct ww *w; 33 34 w1->ww_order = w2->ww_order + 1; 35 w1->ww_back = w2; 36 w1->ww_forw = w2->ww_forw; 37 w2->ww_forw->ww_back = w1; 38 w2->ww_forw = w1; 39 40 for (w = w1->ww_forw; w != &wwhead; w = w->ww_forw) 41 w->ww_order++; 42 for (i = w1->ww_i.t; i < w1->ww_i.b; i++) { 43 register j; 44 register char *smap = wwsmap[i]; 45 register char *win = w1->ww_win[i]; 46 union ww_char *ns = wwns[i]; 47 union ww_char *buf = w1->ww_buf[i]; 48 int nvis = 0; 49 int nchanged = 0; 50 51 for (j = w1->ww_i.l; j < w1->ww_i.r; j++) { 52 w = wwindex[smap[j]]; 53 if (w1->ww_order > w->ww_order) 54 continue; 55 if (win[j] & WWM_GLS) 56 continue; 57 if (w != &wwnobody && w->ww_win[i][j] == 0) 58 w->ww_nvis[i]--; 59 smap[j] = w1->ww_index; 60 if (win[j] == 0) 61 nvis++; 62 ns[j].c_w = buf[j].c_w ^ win[j] << WWC_MSHIFT; 63 nchanged++; 64 } 65 if (nchanged > 0) 66 wwtouched[i] |= WWU_TOUCHED; 67 w1->ww_nvis[i] = nvis; 68 } 69 } 70