BSD 4_4 release
[unix-history] / usr / src / usr.bin / window / wwframe.c
index 3c3c71d..bb0badd 100644 (file)
@@ -1,12 +1,48 @@
+/*
+ * Copyright (c) 1983, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Edward Wang at The University of California, Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwframe.c   3.10 83/09/15";
-#endif
+static char sccsid[] = "@(#)wwframe.c  8.1 (Berkeley) 6/6/93";
+#endif /* not lint */
 
 #include "ww.h"
 #include "tt.h"
 
 #define frameok(w, r, c) (w1 = wwindex[wwsmap[r][c]], \
 
 #include "ww.h"
 #include "tt.h"
 
 #define frameok(w, r, c) (w1 = wwindex[wwsmap[r][c]], \
-       !w1->ww_hasframe || w1->ww_order > (w)->ww_order)
+       w1->ww_fmap || w1->ww_order > (w)->ww_order)
 
 wwframe(w, wframe)
 register struct ww *w;
 
 wwframe(w, wframe)
 register struct ww *w;
@@ -164,20 +200,21 @@ register r, c;
 char code;
 {
        char oldcode;
 char code;
 {
        char oldcode;
+       register char *smap;
 
        if (r < f->ww_i.t || r >= f->ww_i.b || c < f->ww_i.l || c >= f->ww_i.r)
                return;
 
        if (r < f->ww_i.t || r >= f->ww_i.b || c < f->ww_i.l || c >= f->ww_i.r)
                return;
+
+       smap = &wwsmap[r][c];
+
        {
                register struct ww *w;
 
        {
                register struct ww *w;
 
-               w = wwindex[wwsmap[r][c]];
+               w = wwindex[*smap];
                if (w->ww_order > f->ww_order) {
                if (w->ww_order > f->ww_order) {
-                       if (w != &wwnobody) {
-                               if ((w->ww_win[r][c] |= WWM_COV) == WWM_COV)
-                                       w->ww_nvis[r]--;
-                               w->ww_cov[r][c] = f->ww_index;
-                       }
-                       wwsmap[r][c] = f->ww_index;
+                       if (w != &wwnobody && w->ww_win[r][c] == 0)
+                               w->ww_nvis[r]--;
+                       *smap = f->ww_index;
                }
        }
 
                }
        }
 
@@ -195,17 +232,17 @@ char code;
        {
                register char *win = &f->ww_win[r][c];
 
        {
                register char *win = &f->ww_win[r][c];
 
-               if (*win == WWM_GLS)
+               if (*win == WWM_GLS && *smap == f->ww_index)
                        f->ww_nvis[r]++;
                *win &= ~WWM_GLS;
        }
        if (oldcode != code && (code & WWF_LABEL) == 0) {
                register short frame;
 
                        f->ww_nvis[r]++;
                *win &= ~WWM_GLS;
        }
        if (oldcode != code && (code & WWF_LABEL) == 0) {
                register short frame;
 
-               frame = tt.tt_frame[code & WWF_MASK] & WWC_CMASK;
+               frame = tt.tt_frame[code & WWF_MASK];
                f->ww_buf[r][c].c_w = frame;
                if (wwsmap[r][c] == f->ww_index) {
                f->ww_buf[r][c].c_w = frame;
                if (wwsmap[r][c] == f->ww_index) {
-                       wwtouched[r] = 1;
+                       wwtouched[r] |= WWU_TOUCHED;
                        wwns[r][c].c_w = frame;
                }
        }
                        wwns[r][c].c_w = frame;
                }
        }