|
|
1.1 root 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.16 (Berkeley) 6/29/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 > 4)
45: wwtouched[i] |= WWU_MAJOR|WWU_TOUCHED;
46: else if (nchanged > 0)
47: wwtouched[i] |= WWU_TOUCHED;
48: }
49:
50: {
51: register struct ww *wp;
52:
53: for (wp = w->ww_forw; wp != &wwhead; wp = wp->ww_forw)
54: wp->ww_order--;
55: }
56:
57: if (w->ww_forw != &wwhead)
58: wwdelete1(w->ww_forw,
59: w->ww_i.t, w->ww_i.b, w->ww_i.l, w->ww_i.r);
60:
61: w->ww_back->ww_forw = w->ww_forw;
62: w->ww_forw->ww_back = w->ww_back;
63: w->ww_forw = w->ww_back = 0;
64: }
65:
66: wwdelete1(w, t, b, l, r)
67: register struct ww *w;
68: {
69: int i;
70: int tt, bb, ll, rr;
71: char hasglass;
72:
73: again:
74: hasglass = 0;
75: tt = MAX(t, w->ww_i.t);
76: bb = MIN(b, w->ww_i.b);
77: ll = MAX(l, w->ww_i.l);
78: rr = MIN(r, w->ww_i.r);
79: if (tt >= bb || ll >= rr) {
80: if ((w = w->ww_forw) == &wwhead)
81: return;
82: goto again;
83: }
84: for (i = tt; i < bb; i++) {
85: register j;
86: register char *smap = wwsmap[i];
87: register union ww_char *ns = wwns[i];
88: register char *win = w->ww_win[i];
89: register union ww_char *buf = w->ww_buf[i];
90: int nvis = w->ww_nvis[i];
91: int nchanged = 0;
92:
93: for (j = ll; j < rr; j++) {
94: if (smap[j] != WWX_NOBODY)
95: continue;
96: if (win[j] & WWM_GLS) {
97: hasglass = 1;
98: continue;
99: }
100: smap[j] = w->ww_index;
101: ns[j].c_w = buf[j].c_w ^ win[j] << WWC_MSHIFT;
102: nchanged++;
103: if (win[j] == 0)
104: nvis++;
105: }
106: if (nchanged > 4)
107: wwtouched[i] |= WWU_MAJOR|WWU_TOUCHED;
108: else if (nchanged > 0)
109: wwtouched[i] |= WWU_TOUCHED;
110: w->ww_nvis[i] = nvis;
111: }
112: if ((w = w->ww_forw) == &wwhead)
113: return;
114: if (hasglass)
115: goto again;
116: if (tt > t)
117: wwdelete1(w, t, tt, l, r);
118: if (bb < b)
119: wwdelete1(w, bb, b, l, r);
120: if (ll > l)
121: wwdelete1(w, tt, bb, l, ll);
122: if (rr < r)
123: wwdelete1(w, tt, bb, rr, r);
124: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.