WWU_MAJOR, clreol in wwupdate(), and more optimizations.
[unix-history] / usr / src / usr.bin / window / wwlabel.c
... / ...
CommitLineData
1#ifndef lint
2static char *sccsid = "@(#)wwlabel.c 3.10 83/12/02";
3#endif
4
5#include "ww.h"
6
7/*
8 * Label window w on f,
9 * at 1 line above w and 'where' columns from it's left edge.
10 * Gross, but it works.
11 */
12wwlabel(w, f, where, l, mode)
13struct ww *w;
14struct ww *f;
15char *l;
16{
17 int row;
18 register j;
19 int jj;
20 register char *win;
21 register union ww_char *buf;
22 register union ww_char *ns;
23 register char *fmap;
24 register char *smap;
25 char touched;
26 char *p;
27
28 if (f->ww_fmap == 0)
29 return;
30
31 row = w->ww_w.t - 1;
32 if (row < f->ww_i.t || row >= f->ww_i.b)
33 return;
34 win = f->ww_win[row];
35 buf = f->ww_buf[row];
36 fmap = f->ww_fmap[row];
37 ns = wwns[row];
38 smap = wwsmap[row];
39 touched = wwtouched[row];
40 mode <<= WWC_MSHIFT;
41
42 jj = MIN(w->ww_i.r, f->ww_i.r);
43 j = w->ww_i.l + where;
44 while (j < jj && *l)
45 for (p = unctrl(*l++); j < jj && *p; j++, p++) {
46 /* can't label if not already framed */
47 if (win[j] & WWM_GLS)
48 continue;
49 if (smap[j] != f->ww_index)
50 buf[j].c_w = mode | *p;
51 else {
52 ns[j].c_w = (buf[j].c_w = mode | *p)
53 ^ win[j] << WWC_MSHIFT;
54 touched |= WWU_TOUCHED;
55 }
56 fmap[j] |= WWF_LABEL;
57 }
58 wwtouched[row] = touched;
59}