Commit | Line | Data |
---|---|---|
60de5df9 | 1 | /* |
46e9ea25 KB |
2 | * Copyright (c) 1983 Regents of the University of California. |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms are permitted | |
6 | * provided that this notice is preserved and that due credit is given | |
7 | * to the University of California at Berkeley. The name of the University | |
8 | * may not be used to endorse or promote products derived from this | |
9 | * software without specific prior written permission. This software | |
10 | * is provided ``as is'' without express or implied warranty. | |
60de5df9 EW |
11 | */ |
12 | ||
46e9ea25 KB |
13 | #ifndef lint |
14 | static char sccsid[] = "@(#)wwlabel.c 3.14 (Berkeley) %G%"; | |
15 | #endif /* not lint */ | |
16 | ||
e7fe89d1 | 17 | #include "ww.h" |
0e64e422 | 18 | #include "char.h" |
e7fe89d1 | 19 | |
85af59e4 EW |
20 | /* |
21 | * Label window w on f, | |
22 | * at 1 line above w and 'where' columns from it's left edge. | |
23 | * Gross, but it works. | |
24 | */ | |
25 | wwlabel(w, f, where, l, mode) | |
0896e17e | 26 | struct ww *w; |
85af59e4 EW |
27 | struct ww *f; |
28 | char *l; | |
e7fe89d1 | 29 | { |
d069a508 | 30 | int row; |
85af59e4 | 31 | register j; |
d069a508 | 32 | int jj; |
85af59e4 EW |
33 | register char *win; |
34 | register union ww_char *buf; | |
35 | register union ww_char *ns; | |
0896e17e | 36 | register char *fmap; |
d069a508 EW |
37 | register char *smap; |
38 | char touched; | |
39 | char *p; | |
e7fe89d1 | 40 | |
2357b64e | 41 | if (f->ww_fmap == 0) |
03e75950 | 42 | return; |
2357b64e | 43 | |
d069a508 EW |
44 | row = w->ww_w.t - 1; |
45 | if (row < f->ww_i.t || row >= f->ww_i.b) | |
03e75950 | 46 | return; |
d069a508 EW |
47 | win = f->ww_win[row]; |
48 | buf = f->ww_buf[row]; | |
49 | fmap = f->ww_fmap[row]; | |
50 | ns = wwns[row]; | |
51 | smap = wwsmap[row]; | |
52 | touched = wwtouched[row]; | |
53 | mode <<= WWC_MSHIFT; | |
85af59e4 | 54 | |
d069a508 EW |
55 | jj = MIN(w->ww_i.r, f->ww_i.r); |
56 | j = w->ww_i.l + where; | |
57 | while (j < jj && *l) | |
58 | for (p = unctrl(*l++); j < jj && *p; j++, p++) { | |
85af59e4 | 59 | /* can't label if not already framed */ |
d069a508 EW |
60 | if (win[j] & WWM_GLS) |
61 | continue; | |
62 | if (smap[j] != f->ww_index) | |
63 | buf[j].c_w = mode | *p; | |
64 | else { | |
65 | ns[j].c_w = (buf[j].c_w = mode | *p) | |
66 | ^ win[j] << WWC_MSHIFT; | |
04d70db4 | 67 | touched |= WWU_TOUCHED; |
0896e17e | 68 | } |
d069a508 | 69 | fmap[j] |= WWF_LABEL; |
85af59e4 | 70 | } |
d069a508 | 71 | wwtouched[row] = touched; |
e7fe89d1 | 72 | } |