118736Sedward /* 2*33514Sbostic * Copyright (c) 1983 Regents of the University of California. 3*33514Sbostic * All rights reserved. 4*33514Sbostic * 5*33514Sbostic * Redistribution and use in source and binary forms are permitted 6*33514Sbostic * provided that this notice is preserved and that due credit is given 7*33514Sbostic * to the University of California at Berkeley. The name of the University 8*33514Sbostic * may not be used to endorse or promote products derived from this 9*33514Sbostic * software without specific prior written permission. This software 10*33514Sbostic * is provided ``as is'' without express or implied warranty. 1118736Sedward */ 1218736Sedward 13*33514Sbostic #ifndef lint 14*33514Sbostic static char sccsid[] = "@(#)wwlabel.c 3.14 (Berkeley) 02/21/88"; 15*33514Sbostic #endif /* not lint */ 16*33514Sbostic 1713984Sedward #include "ww.h" 1816309Sedward #include "char.h" 1913984Sedward 2014415Sedward /* 2114415Sedward * Label window w on f, 2214415Sedward * at 1 line above w and 'where' columns from it's left edge. 2314415Sedward * Gross, but it works. 2414415Sedward */ 2514415Sedward wwlabel(w, f, where, l, mode) 2614591Sedward struct ww *w; 2714415Sedward struct ww *f; 2814415Sedward char *l; 2913984Sedward { 3015635Sedward int row; 3114415Sedward register j; 3215635Sedward int jj; 3314415Sedward register char *win; 3414415Sedward register union ww_char *buf; 3514415Sedward register union ww_char *ns; 3614591Sedward register char *fmap; 3715635Sedward register char *smap; 3815635Sedward char touched; 3915635Sedward char *p; 4013984Sedward 4114773Sedward if (f->ww_fmap == 0) 4214858Sedward return; 4314773Sedward 4415635Sedward row = w->ww_w.t - 1; 4515635Sedward if (row < f->ww_i.t || row >= f->ww_i.b) 4614858Sedward return; 4715635Sedward win = f->ww_win[row]; 4815635Sedward buf = f->ww_buf[row]; 4915635Sedward fmap = f->ww_fmap[row]; 5015635Sedward ns = wwns[row]; 5115635Sedward smap = wwsmap[row]; 5215635Sedward touched = wwtouched[row]; 5315635Sedward mode <<= WWC_MSHIFT; 5415635Sedward 5515635Sedward jj = MIN(w->ww_i.r, f->ww_i.r); 5614987Sedward j = w->ww_i.l + where; 5715635Sedward while (j < jj && *l) 5815635Sedward for (p = unctrl(*l++); j < jj && *p; j++, p++) { 5914415Sedward /* can't label if not already framed */ 6015635Sedward if (win[j] & WWM_GLS) 6115635Sedward continue; 6215635Sedward if (smap[j] != f->ww_index) 6315635Sedward buf[j].c_w = mode | *p; 6415635Sedward else { 6515635Sedward ns[j].c_w = (buf[j].c_w = mode | *p) 6615635Sedward ^ win[j] << WWC_MSHIFT; 6715654Sedward touched |= WWU_TOUCHED; 6814591Sedward } 6915635Sedward fmap[j] |= WWF_LABEL; 7014415Sedward } 7115635Sedward wwtouched[row] = touched; 7213984Sedward } 73