Commit | Line | Data |
---|---|---|
60de5df9 | 1 | /* |
46e9ea25 KB |
2 | * Copyright (c) 1983 Regents of the University of California. |
3 | * All rights reserved. | |
4 | * | |
3dd3a9e5 KB |
5 | * This code is derived from software contributed to Berkeley by |
6 | * Edward Wang at The University of California, Berkeley. | |
7 | * | |
87f529ec | 8 | * %sccs.include.redist.c% |
60de5df9 EW |
9 | */ |
10 | ||
46e9ea25 | 11 | #ifndef lint |
3dd3a9e5 | 12 | static char sccsid[] = "@(#)wwdelete.c 3.19 (Berkeley) %G%"; |
46e9ea25 KB |
13 | #endif /* not lint */ |
14 | ||
07662491 EW |
15 | #include "ww.h" |
16 | ||
17 | /* | |
18 | * Pull w free from the cover list. | |
19 | */ | |
20 | wwdelete(w) | |
21 | register struct ww *w; | |
22 | { | |
c05972b9 EW |
23 | register i; |
24 | ||
25 | for (i = w->ww_i.t; i < w->ww_i.b; i++) { | |
26 | register j; | |
27 | register char *smap = wwsmap[i]; | |
6ef62e9e | 28 | register union ww_char *ns = wwns[i]; |
04d70db4 | 29 | register int nchanged = 0; |
84ad208b | 30 | |
84ad208b | 31 | for (j = w->ww_i.l; j < w->ww_i.r; j++) |
c05972b9 EW |
32 | if (smap[j] == w->ww_index) { |
33 | smap[j] = WWX_NOBODY; | |
34 | ns[j].c_w = ' '; | |
04d70db4 | 35 | nchanged++; |
84ad208b | 36 | } |
6a1ef78a | 37 | if (nchanged > 0) |
04d70db4 | 38 | wwtouched[i] |= WWU_TOUCHED; |
c05972b9 | 39 | } |
84ad208b | 40 | |
c05972b9 EW |
41 | { |
42 | register struct ww *wp; | |
665bc9e7 | 43 | |
c05972b9 EW |
44 | for (wp = w->ww_forw; wp != &wwhead; wp = wp->ww_forw) |
45 | wp->ww_order--; | |
46 | } | |
47 | ||
48 | if (w->ww_forw != &wwhead) | |
49 | wwdelete1(w->ww_forw, | |
50 | w->ww_i.t, w->ww_i.b, w->ww_i.l, w->ww_i.r); | |
861cd1ed | 51 | |
07662491 EW |
52 | w->ww_back->ww_forw = w->ww_forw; |
53 | w->ww_forw->ww_back = w->ww_back; | |
54 | w->ww_forw = w->ww_back = 0; | |
55 | } | |
665bc9e7 EW |
56 | |
57 | wwdelete1(w, t, b, l, r) | |
58 | register struct ww *w; | |
59 | { | |
60 | int i; | |
61 | int tt, bb, ll, rr; | |
1ceeb7e2 | 62 | char hasglass; |
665bc9e7 | 63 | |
1ceeb7e2 EW |
64 | again: |
65 | hasglass = 0; | |
665bc9e7 EW |
66 | tt = MAX(t, w->ww_i.t); |
67 | bb = MIN(b, w->ww_i.b); | |
68 | ll = MAX(l, w->ww_i.l); | |
69 | rr = MIN(r, w->ww_i.r); | |
1ceeb7e2 EW |
70 | if (tt >= bb || ll >= rr) { |
71 | if ((w = w->ww_forw) == &wwhead) | |
72 | return; | |
73 | goto again; | |
74 | } | |
665bc9e7 | 75 | for (i = tt; i < bb; i++) { |
c05972b9 | 76 | register j; |
665bc9e7 EW |
77 | register char *smap = wwsmap[i]; |
78 | register union ww_char *ns = wwns[i]; | |
79 | register char *win = w->ww_win[i]; | |
80 | register union ww_char *buf = w->ww_buf[i]; | |
81 | int nvis = w->ww_nvis[i]; | |
04d70db4 | 82 | int nchanged = 0; |
665bc9e7 EW |
83 | |
84 | for (j = ll; j < rr; j++) { | |
1ceeb7e2 EW |
85 | if (smap[j] != WWX_NOBODY) |
86 | continue; | |
87 | if (win[j] & WWM_GLS) { | |
88 | hasglass = 1; | |
665bc9e7 | 89 | continue; |
1ceeb7e2 | 90 | } |
c05972b9 EW |
91 | smap[j] = w->ww_index; |
92 | ns[j].c_w = buf[j].c_w ^ win[j] << WWC_MSHIFT; | |
04d70db4 | 93 | nchanged++; |
c05972b9 EW |
94 | if (win[j] == 0) |
95 | nvis++; | |
665bc9e7 | 96 | } |
6a1ef78a | 97 | if (nchanged > 0) |
04d70db4 | 98 | wwtouched[i] |= WWU_TOUCHED; |
665bc9e7 EW |
99 | w->ww_nvis[i] = nvis; |
100 | } | |
101 | if ((w = w->ww_forw) == &wwhead) | |
102 | return; | |
1ceeb7e2 EW |
103 | if (hasglass) |
104 | goto again; | |
665bc9e7 EW |
105 | if (tt > t) |
106 | wwdelete1(w, t, tt, l, r); | |
107 | if (bb < b) | |
108 | wwdelete1(w, bb, b, l, r); | |
109 | if (ll > l) | |
1ceeb7e2 | 110 | wwdelete1(w, tt, bb, l, ll); |
665bc9e7 | 111 | if (rr < r) |
1ceeb7e2 | 112 | wwdelete1(w, tt, bb, rr, r); |
665bc9e7 | 113 | } |