moving windows
[unix-history] / usr / src / usr.bin / window / wwlabel.c
CommitLineData
e7fe89d1 1#ifndef lint
03e75950 2static char *sccsid = "@(#)wwlabel.c 3.6 83/08/26";
e7fe89d1
EW
3#endif
4
5#include "ww.h"
6
85af59e4
EW
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)
0896e17e 13struct ww *w;
85af59e4
EW
14struct ww *f;
15char *l;
e7fe89d1 16{
85af59e4
EW
17 int i;
18 register j;
d439a752 19 register char *p;
85af59e4
EW
20 register char *win;
21 register union ww_char *buf;
22 register union ww_char *ns;
0896e17e 23 register char *fmap;
861cd1ed 24 char *touched;
e7fe89d1 25
2357b64e 26 if (f->ww_fmap == 0)
03e75950 27 return;
2357b64e
EW
28
29 i = w->ww_w.t - 1 - f->ww_w.t;
30 if (i < 0)
03e75950 31 return;
2357b64e
EW
32 j = w->ww_w.l + where - f->ww_w.l;
33 if (j < 0)
34 j = 0;
35 win = &f->ww_win[i][j];
36 buf = &f->ww_buf[f->ww_scroll + i][j];
37 fmap = &f->ww_fmap[i][j];
38
85af59e4 39 i += f->ww_w.t;
2357b64e 40 j += f->ww_w.l;
85af59e4 41 ns = &wwns[i][j];
861cd1ed 42 touched = &wwtouched[i];
85af59e4 43
2357b64e 44 j = MIN(w->ww_w.r, f->ww_w.r) - j;
85af59e4 45 for (; j > 0 && *l;)
0896e17e 46 for (p = unctrl(*l++); j > 0 && *p; j--) {
85af59e4 47 /* can't label if not already framed */
0896e17e 48 if (*win & WWM_GLS) {
85af59e4
EW
49 p++;
50 buf++;
51 ns++;
52 win++;
0896e17e 53 fmap++;
85af59e4
EW
54 } else if (*win & WWM_COV) {
55 buf++->c_w = mode << WWC_MSHIFT | *p++;
0896e17e 56 *fmap++ |= WWF_LABEL;
85af59e4
EW
57 ns++;
58 win++;
0896e17e 59 } else {
861cd1ed 60 *touched = 1;
85af59e4
EW
61 ns++->c_w = (buf++->c_w
62 = mode << WWC_MSHIFT | *p++)
63 ^ *win++ << WWC_MSHIFT;
0896e17e
EW
64 *fmap++ |= WWF_LABEL;
65 }
85af59e4 66 }
e7fe89d1 67}