xref: /csrg-svn/lib/libcurses/erase.c (revision 56238)
122662Sdist /*
234677Sbostic  * Copyright (c) 1981 Regents of the University of California.
334677Sbostic  * All rights reserved.
434677Sbostic  *
542653Sbostic  * %sccs.include.redist.c%
622662Sdist  */
722662Sdist 
822662Sdist #ifndef lint
9*56238Selan static char sccsid[] = "@(#)erase.c	5.6 (Berkeley) 09/14/92";
1055957Sbostic #endif	/* not lint */
1122662Sdist 
1255957Sbostic #include <curses.h>
132248Sarnold 
142248Sarnold /*
1555957Sbostic  * werase --
1655957Sbostic  *	Erases everything on the window.
172248Sarnold  */
1855957Sbostic int
192248Sarnold werase(win)
2055957Sbostic 	register WINDOW *win;
2155957Sbostic {
222248Sarnold 
2355957Sbostic 	register int minx, y;
2455957Sbostic 	register char *sp, *end, *start, *maxx;
252248Sarnold 
2655957Sbostic #ifdef DEBUG
2755957Sbostic 	__TRACE("werase: (%0.2o)\n", win);
2855957Sbostic #endif
29*56238Selan 	for (y = 0; y < win->maxy; y++) {
30*56238Selan 		minx = -1;
31*56238Selan 		start = win->lines[y]->line;
32*56238Selan 		end = &start[win->maxx];
332248Sarnold 		for (sp = start; sp < end; sp++)
342248Sarnold 			if (*sp != ' ') {
352248Sarnold 				maxx = sp;
36*56238Selan 				if (minx == -1)
372248Sarnold 					minx = sp - start;
382248Sarnold 				*sp = ' ';
392248Sarnold 			}
40*56238Selan 		if (minx != -1)
41*56238Selan 			touchline(win, y, minx, maxx - win->lines[y]->line);
422248Sarnold 	}
43*56238Selan 	win->curx = win->cury = 0;
4455957Sbostic 	return (OK);
452248Sarnold }
46