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[] = "@(#)wwdelete.c 3.17 (Berkeley) 08/04/88"; 20 #endif /* not lint */ 21 22 #include "ww.h" 23 24 /* 25 * Pull w free from the cover list. 26 */ 27 wwdelete(w) 28 register struct ww *w; 29 { 30 register i; 31 32 for (i = w->ww_i.t; i < w->ww_i.b; i++) { 33 register j; 34 register char *smap = wwsmap[i]; 35 register union ww_char *ns = wwns[i]; 36 register int nchanged = 0; 37 38 for (j = w->ww_i.l; j < w->ww_i.r; j++) 39 if (smap[j] == w->ww_index) { 40 smap[j] = WWX_NOBODY; 41 ns[j].c_w = ' '; 42 nchanged++; 43 } 44 if (nchanged > 0) 45 wwtouched[i] |= WWU_TOUCHED; 46 } 47 48 { 49 register struct ww *wp; 50 51 for (wp = w->ww_forw; wp != &wwhead; wp = wp->ww_forw) 52 wp->ww_order--; 53 } 54 55 if (w->ww_forw != &wwhead) 56 wwdelete1(w->ww_forw, 57 w->ww_i.t, w->ww_i.b, w->ww_i.l, w->ww_i.r); 58 59 w->ww_back->ww_forw = w->ww_forw; 60 w->ww_forw->ww_back = w->ww_back; 61 w->ww_forw = w->ww_back = 0; 62 } 63 64 wwdelete1(w, t, b, l, r) 65 register struct ww *w; 66 { 67 int i; 68 int tt, bb, ll, rr; 69 char hasglass; 70 71 again: 72 hasglass = 0; 73 tt = MAX(t, w->ww_i.t); 74 bb = MIN(b, w->ww_i.b); 75 ll = MAX(l, w->ww_i.l); 76 rr = MIN(r, w->ww_i.r); 77 if (tt >= bb || ll >= rr) { 78 if ((w = w->ww_forw) == &wwhead) 79 return; 80 goto again; 81 } 82 for (i = tt; i < bb; i++) { 83 register j; 84 register char *smap = wwsmap[i]; 85 register union ww_char *ns = wwns[i]; 86 register char *win = w->ww_win[i]; 87 register union ww_char *buf = w->ww_buf[i]; 88 int nvis = w->ww_nvis[i]; 89 int nchanged = 0; 90 91 for (j = ll; j < rr; j++) { 92 if (smap[j] != WWX_NOBODY) 93 continue; 94 if (win[j] & WWM_GLS) { 95 hasglass = 1; 96 continue; 97 } 98 smap[j] = w->ww_index; 99 ns[j].c_w = buf[j].c_w ^ win[j] << WWC_MSHIFT; 100 nchanged++; 101 if (win[j] == 0) 102 nvis++; 103 } 104 if (nchanged > 0) 105 wwtouched[i] |= WWU_TOUCHED; 106 w->ww_nvis[i] = nvis; 107 } 108 if ((w = w->ww_forw) == &wwhead) 109 return; 110 if (hasglass) 111 goto again; 112 if (tt > t) 113 wwdelete1(w, t, tt, l, r); 114 if (bb < b) 115 wwdelete1(w, bb, b, l, r); 116 if (ll > l) 117 wwdelete1(w, tt, bb, l, ll); 118 if (rr < r) 119 wwdelete1(w, tt, bb, rr, r); 120 } 121