ww_availmodes and stuff
[unix-history] / usr / src / usr.bin / window / wwlabel.c
index d7e4c97..b4fe0af 100644 (file)
@@ -1,22 +1,16 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwlabel.c   2.1.1.1 83/08/09";
+static char *sccsid = "@(#)wwlabel.c   3.3 83/08/16";
 #endif
 
 #include "ww.h"
 
 #endif
 
 #include "ww.h"
 
-char **wwfmap;
-#define U 1
-#define R 2
-#define D 4
-#define L 8
-
 /*
  * Label window w on f,
  * at 1 line above w and 'where' columns from it's left edge.
  * Gross, but it works.
  */
 wwlabel(w, f, where, l, mode)
 /*
  * Label window w on f,
  * at 1 line above w and 'where' columns from it's left edge.
  * Gross, but it works.
  */
 wwlabel(w, f, where, l, mode)
-register struct ww *w;
+struct ww *w;
 struct ww *f;
 char *l;
 {
 struct ww *f;
 char *l;
 {
@@ -26,7 +20,8 @@ char *l;
        register char *win;
        register union ww_char *buf;
        register union ww_char *ns;
        register char *win;
        register union ww_char *buf;
        register union ww_char *ns;
-       char *fmap;
+       register char *fmap;
+       char *touched;
 
        if ((i = w->ww_w.t - 1 - f->ww_w.t) < 0)
                return -1;
 
        if ((i = w->ww_w.t - 1 - f->ww_w.t) < 0)
                return -1;
@@ -37,24 +32,30 @@ char *l;
        i += f->ww_w.t;
        ns = &wwns[i][j];
        fmap = &wwfmap[i][j];
        i += f->ww_w.t;
        ns = &wwns[i][j];
        fmap = &wwfmap[i][j];
+       touched = &wwtouched[i];
        j = MIN(w->ww_w.r, f->ww_w.r) - j;
 
        for (; j > 0 && *l;)
        j = MIN(w->ww_w.r, f->ww_w.r) - j;
 
        for (; j > 0 && *l;)
-               for (p = unctrl(*l++); j > 0 && *p; j--, fmap++) {
+               for (p = unctrl(*l++); j > 0 && *p; j--) {
                        /* can't label if not already framed */
                        /* can't label if not already framed */
-                       if (*win & WWM_GLS || (*fmap & (U|D)) == (U|D)) {
+                       if (*win & WWM_GLS) {
                                p++;
                                buf++;
                                ns++;
                                win++;
                                p++;
                                buf++;
                                ns++;
                                win++;
+                               fmap++;
                        } else if (*win & WWM_COV) {
                                buf++->c_w = mode << WWC_MSHIFT | *p++;
                        } else if (*win & WWM_COV) {
                                buf++->c_w = mode << WWC_MSHIFT | *p++;
+                               *fmap++ |= WWF_LABEL;
                                ns++;
                                win++;
                                ns++;
                                win++;
-                       } else
+                       } else {
+                               *touched = 1;
                                ns++->c_w = (buf++->c_w
                                        = mode << WWC_MSHIFT | *p++)
                                                ^ *win++ << WWC_MSHIFT;
                                ns++->c_w = (buf++->c_w
                                        = mode << WWC_MSHIFT | *p++)
                                                ^ *win++ << WWC_MSHIFT;
+                               *fmap++ |= WWF_LABEL;
+                       }
                }
 
        return 0;
                }
 
        return 0;