ww_availmodes and stuff
[unix-history] / usr / src / usr.bin / window / wwlabel.c
index c703b5f..b4fe0af 100644 (file)
@@ -1,21 +1,62 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwlabel.c   1.4 83/07/28";
+static char *sccsid = "@(#)wwlabel.c   3.3 83/08/16";
 #endif
 
 #include "ww.h"
 
 #endif
 
 #include "ww.h"
 
-wwlabel(w, where, l, mode)
-register struct ww *w;
-register char *l;
+/*
+ * 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)
+struct ww *w;
+struct ww *f;
+char *l;
 {
 {
-       register i;
+       int i;
+       register j;
        register char *p;
        register char *p;
-       char ulc, top, urc, left, right, llc, bottom, lrc;
+       register char *win;
+       register union ww_char *buf;
+       register union ww_char *ns;
+       register char *fmap;
+       char *touched;
 
 
-       if (w->ww_i.nrow == w->ww_w.nrow)       /* not framed */
+       if ((i = w->ww_w.t - 1 - f->ww_w.t) < 0)
                return -1;
                return -1;
-       Wauxcursor(w->ww_win, 0, where);
-       for (i = w->ww_o.ncol - where - 1; i > 0 && *l; l++)
-               for (p = unctrl(*l); *p; p++, i--)
-                       Waputc(*p, mode, w->ww_win);
+       j = w->ww_w.l + where;
+       j = MAX(j, f->ww_w.l);
+       win = &f->ww_win[i][j - f->ww_w.l];
+       buf = &f->ww_buf[w->ww_scroll + i][j - f->ww_w.l];
+       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;)
+               for (p = unctrl(*l++); j > 0 && *p; j--) {
+                       /* can't label if not already framed */
+                       if (*win & WWM_GLS) {
+                               p++;
+                               buf++;
+                               ns++;
+                               win++;
+                               fmap++;
+                       } else if (*win & WWM_COV) {
+                               buf++->c_w = mode << WWC_MSHIFT | *p++;
+                               *fmap++ |= WWF_LABEL;
+                               ns++;
+                               win++;
+                       } else {
+                               *touched = 1;
+                               ns++->c_w = (buf++->c_w
+                                       = mode << WWC_MSHIFT | *p++)
+                                               ^ *win++ << WWC_MSHIFT;
+                               *fmap++ |= WWF_LABEL;
+                       }
+               }
+
+       return 0;
 }
 }