xref: /original-bsd/usr.bin/window/wwclreol.c (revision ee66054d)
1 /*
2  * Copyright (c) 1983, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Edward Wang at The University of California, Berkeley.
7  *
8  * %sccs.include.redist.c%
9  */
10 
11 #ifndef lint
12 static char sccsid[] = "@(#)wwclreol.c	8.1 (Berkeley) 06/06/93";
13 #endif /* not lint */
14 
15 #include "ww.h"
16 #include "tt.h"
17 
18 /*
19  * Clear w to the end of line.
20  * If cleared is true, then the screen line has already been cleared.
21  */
22 wwclreol1(w, row, col, cleared)
23 register struct ww *w;
24 int row, col;
25 char cleared;
26 {
27 	register i;
28 
29 	/*
30 	 * Clear the buffer right off
31 	 */
32 	{
33 		register union ww_char *buf;
34 
35 		buf = &w->ww_buf[row][col];
36 		for (i = w->ww_b.r - col; --i >= 0;)
37 			buf++->c_w = ' ';
38 	}
39 
40 	/*
41 	 * If can't see it, just return.
42 	 */
43 	if (row < w->ww_i.t || row >= w->ww_i.b
44 	    || w->ww_i.r <= 0 || w->ww_i.r <= col)
45 		return;
46 
47 	if (col < w->ww_i.l)
48 		col = w->ww_i.l;
49 
50 	/*
51 	 * Now fix wwns.
52 	 */
53 	{
54 		register union ww_char *s;
55 		register char *smap, *win;
56 
57 		i = col;
58 		smap = &wwsmap[row][i];
59 		s = &wwns[row][i];
60 		win = &w->ww_win[row][i];
61 		for (i = w->ww_i.r - i; --i >= 0;)
62 			if (*smap++ == w->ww_index)
63 				s++->c_w = ' ' | *win++ << WWC_MSHIFT;
64 			else
65 				s++, win++;
66 	}
67 	if (!cleared)
68 		wwtouched[row] |= WWU_TOUCHED;
69 }
70