xref: /original-bsd/lib/libcurses/erase.c (revision 860e07fc)
1 /*
2  * Copyright (c) 1981 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)erase.c	5.5 (Berkeley) 08/23/92";
10 #endif	/* not lint */
11 
12 #include <curses.h>
13 
14 /*
15  * werase --
16  *	Erases everything on the window.
17  */
18 int
19 werase(win)
20 	register WINDOW *win;
21 {
22 
23 	register int minx, y;
24 	register char *sp, *end, *start, *maxx;
25 
26 #ifdef DEBUG
27 	__TRACE("werase: (%0.2o)\n", win);
28 #endif
29 	for (y = 0; y < win->_maxy; y++) {
30 		minx = _NOCHANGE;
31 		start = win->_y[y];
32 		end = &start[win->_maxx];
33 		for (sp = start; sp < end; sp++)
34 			if (*sp != ' ') {
35 				maxx = sp;
36 				if (minx == _NOCHANGE)
37 					minx = sp - start;
38 				*sp = ' ';
39 			}
40 		if (minx != _NOCHANGE)
41 			touchline(win, y, minx, maxx - win->_y[y]);
42 	}
43 	win->_curx = win->_cury = 0;
44 	return (OK);
45 }
46