2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
5 * This code is derived from software contributed to Berkeley by
6 * Edward Wang at The University of California, Berkeley.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 static char sccsid[] = "@(#)wwframe.c 8.1 (Berkeley) 6/6/93";
46 #define frameok(w, r, c) (w1 = wwindex[wwsmap[r][c]], \
47 w1->ww_fmap || w1->ww_order > (w)->ww_order)
50 register struct ww *w;
58 register struct ww *w1;
63 smap = &wwsmap[r + 1][c + 1];
67 b2 = c < 0 || frameok(w, r, c);
69 for (; c < w->ww_i.r; c++) {
70 if (c + 1 >= wwncol) {
74 a3 = w->ww_index == *smap++;
75 b3 = frameok(w, r, c + 1);
84 wwframec(wframe, r, c, code|WWF_TOP);
91 if ((a1 || a2) && b1 && b2)
92 wwframec(wframe, r, c, WWF_L|WWF_TOP);
95 if (w->ww_w.b < wwnrow) {
98 smap = &wwsmap[r - 1][c + 1];
102 b2 = c < 0 || frameok(w, r, c);
104 for (; c < w->ww_i.r; c++) {
105 if (c + 1 >= wwncol) {
109 a3 = w->ww_index == *smap++;
110 b3 = frameok(w, r, c + 1);
114 if ((a1 || a2) && b1)
116 if ((a2 || a3) && b3)
119 wwframec(wframe, r, c, code);
126 if ((a1 || a2) && b1 && b2)
127 wwframec(wframe, r, c, WWF_L);
136 b2 = r < 0 || frameok(w, r, c);
138 for (; r < w->ww_i.b; r++) {
139 if (r + 1 >= wwnrow) {
143 a3 = w->ww_index == wwsmap[r + 1][c + 1];
144 b3 = frameok(w, r + 1, c);
148 if ((a1 || a2) && b1)
150 if ((a2 || a3) && b3)
153 wwframec(wframe, r, c, code);
160 if ((a1 || a2) && b1 && b2)
161 wwframec(wframe, r, c, WWF_U);
164 if (w->ww_w.r < wwncol) {
170 b2 = r < 0 || frameok(w, r, c);
172 for (; r < w->ww_i.b; r++) {
173 if (r + 1 >= wwnrow) {
177 a3 = w->ww_index == wwsmap[r + 1][c - 1];
178 b3 = frameok(w, r + 1, c);
182 if ((a1 || a2) && b1)
184 if ((a2 || a3) && b3)
187 wwframec(wframe, r, c, code);
194 if ((a1 || a2) && b1 && b2)
195 wwframec(wframe, r, c, WWF_U);
199 wwframec(f, r, c, code)
200 register struct ww *f;
207 if (r < f->ww_i.t || r >= f->ww_i.b || c < f->ww_i.l || c >= f->ww_i.r)
210 smap = &wwsmap[r][c];
213 register struct ww *w;
216 if (w->ww_order > f->ww_order) {
217 if (w != &wwnobody && w->ww_win[r][c] == 0)
223 if (f->ww_fmap != 0) {
226 fmap = &f->ww_fmap[r][c];
235 register char *win = &f->ww_win[r][c];
237 if (*win == WWM_GLS && *smap == f->ww_index)
241 if (oldcode != code && (code & WWF_LABEL) == 0) {
242 register short frame;
244 frame = tt.tt_frame[code & WWF_MASK];
245 f->ww_buf[r][c].c_w = frame;
246 if (wwsmap[r][c] == f->ww_index) {
247 wwtouched[r] |= WWU_TOUCHED;
248 wwns[r][c].c_w = frame;