xref: /original-bsd/usr.bin/window/wwclreol.c (revision 048a349a)
1 /*
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 the above copyright notice and this paragraph are
7  * duplicated in all such forms and that any documentation,
8  * advertising materials, and other materials related to such
9  * distribution and use acknowledge that the software was developed
10  * by the University of California, Berkeley.  The name of the
11  * University may not be used to endorse or promote products derived
12  * from this software without specific prior written permission.
13  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16  */
17 
18 #ifndef lint
19 static char sccsid[] = "@(#)wwclreol.c	3.18 (Berkeley) 08/04/88";
20 #endif /* not lint */
21 
22 #include "ww.h"
23 #include "tt.h"
24 
25 /*
26  * Clear w to the end of line.
27  * If cleared is true, then the screen line has already been cleared.
28  */
29 wwclreol1(w, row, col, cleared)
30 register struct ww *w;
31 int row, col;
32 char cleared;
33 {
34 	register i;
35 
36 	/*
37 	 * Clear the buffer right off
38 	 */
39 	{
40 		register union ww_char *buf;
41 
42 		buf = &w->ww_buf[row][col];
43 		for (i = w->ww_b.r - col; --i >= 0;)
44 			buf++->c_w = ' ';
45 	}
46 
47 	/*
48 	 * If can't see it, just return.
49 	 */
50 	if (row < w->ww_i.t || row >= w->ww_i.b
51 	    || w->ww_i.r <= 0 || w->ww_i.r <= col)
52 		return;
53 
54 	if (col < w->ww_i.l)
55 		col = w->ww_i.l;
56 
57 	/*
58 	 * Now fix wwns.
59 	 */
60 	{
61 		register union ww_char *s;
62 		register char *smap, *win;
63 
64 		i = col;
65 		smap = &wwsmap[row][i];
66 		s = &wwns[row][i];
67 		win = &w->ww_win[row][i];
68 		for (i = w->ww_i.r - i; --i >= 0;)
69 			if (*smap++ == w->ww_index)
70 				s++->c_w = ' ' | *win++ << WWC_MSHIFT;
71 			else
72 				s++, win++;
73 	}
74 	if (!cleared)
75 		wwtouched[row] |= WWU_TOUCHED;
76 }
77