1 /* $NetBSD: wwframe.c,v 1.6 2002/06/14 01:06:59 wiz Exp $ */
4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
8 * Edward Wang at The University of California, Berkeley.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <sys/cdefs.h>
38 static char sccsid
[] = "@(#)wwframe.c 8.1 (Berkeley) 6/6/93";
40 __RCSID("$NetBSD: wwframe.c,v 1.6 2002/06/14 01:06:59 wiz Exp $");
47 #define frameok(w, r, c) (w1 = wwindex[wwsmap[r][c]], \
48 w1->ww_fmap || w1->ww_order > (w)->ww_order)
51 wwframe(struct ww
*w
, struct ww
*wframe
)
65 b2
= c
< 0 || frameok(w
, r
, c
);
67 for (; c
< w
->ww_i
.r
; c
++) {
68 if (c
+ 1 >= wwncol
) {
72 a3
= w
->ww_index
== wwsmap
[r
+ 1][c
+ 1];
73 b3
= frameok(w
, r
, c
+ 1);
82 wwframec(wframe
, r
, c
, code
|WWF_TOP
);
89 if ((a1
|| a2
) && b1
&& b2
)
90 wwframec(wframe
, r
, c
, WWF_L
|WWF_TOP
);
93 if (w
->ww_w
.b
< wwnrow
) {
99 b2
= c
< 0 || frameok(w
, r
, c
);
101 for (; c
< w
->ww_i
.r
; c
++) {
102 if (c
+ 1 >= wwncol
) {
106 a3
= w
->ww_index
== wwsmap
[r
- 1][c
+ 1];
107 b3
= frameok(w
, r
, c
+ 1);
111 if ((a1
|| a2
) && b1
)
113 if ((a2
|| a3
) && b3
)
116 wwframec(wframe
, r
, c
, code
);
123 if ((a1
|| a2
) && b1
&& b2
)
124 wwframec(wframe
, r
, c
, WWF_L
);
133 b2
= r
< 0 || frameok(w
, r
, c
);
135 for (; r
< w
->ww_i
.b
; r
++) {
136 if (r
+ 1 >= wwnrow
) {
140 a3
= w
->ww_index
== wwsmap
[r
+ 1][c
+ 1];
141 b3
= frameok(w
, r
+ 1, c
);
145 if ((a1
|| a2
) && b1
)
147 if ((a2
|| a3
) && b3
)
150 wwframec(wframe
, r
, c
, code
);
157 if ((a1
|| a2
) && b1
&& b2
)
158 wwframec(wframe
, r
, c
, WWF_U
);
161 if (w
->ww_w
.r
< wwncol
) {
167 b2
= r
< 0 || frameok(w
, r
, c
);
169 for (; r
< w
->ww_i
.b
; r
++) {
170 if (r
+ 1 >= wwnrow
) {
174 a3
= w
->ww_index
== wwsmap
[r
+ 1][c
- 1];
175 b3
= frameok(w
, r
+ 1, c
);
179 if ((a1
|| a2
) && b1
)
181 if ((a2
|| a3
) && b3
)
184 wwframec(wframe
, r
, c
, code
);
191 if ((a1
|| a2
) && b1
&& b2
)
192 wwframec(wframe
, r
, c
, WWF_U
);
197 wwframec(struct ww
*f
, int r
, int c
, char code
)
202 if (r
< f
->ww_i
.t
|| r
>= f
->ww_i
.b
|| c
< f
->ww_i
.l
|| c
>= f
->ww_i
.r
)
205 smap
= &wwsmap
[r
][c
];
211 if (w
->ww_order
> f
->ww_order
) {
212 if (w
!= &wwnobody
&& w
->ww_win
[r
][c
] == 0)
218 if (f
->ww_fmap
!= 0) {
221 fmap
= &f
->ww_fmap
[r
][c
];
230 char *win
= &f
->ww_win
[r
][c
];
232 if (*win
== WWM_GLS
&& *smap
== f
->ww_index
)
236 if (oldcode
!= code
&& (code
& WWF_LABEL
) == 0) {
239 frame
= tt
.tt_frame
[code
& WWF_MASK
];
240 f
->ww_buf
[r
][c
].c_w
= frame
;
241 if (wwsmap
[r
][c
] == f
->ww_index
) {
242 wwtouched
[r
] |= WWU_TOUCHED
;
243 wwns
[r
][c
].c_w
= frame
;