xref: /original-bsd/lib/libcurses/clrtobot.c (revision be1f24e8)
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[] = "@(#)clrtobot.c	5.7 (Berkeley) 09/14/92";
10 #endif	/* not lint */
11 
12 #include <curses.h>
13 
14 /*
15  * wclrtobot --
16  *	Erase everything on the window.
17  */
18 int
19 wclrtobot(win)
20 	register WINDOW *win;
21 {
22 	register int minx, startx, y;
23 	register char *sp, *end, *maxx;
24 
25 	startx = win->curx;
26 	for (y = win->cury; y < win->maxy; y++) {
27 		minx = -1;
28 		end = &win->lines[y]->line[win->maxx];
29 		for (sp = &win->lines[y]->line[startx]; sp < end; sp++)
30 			if (*sp != ' ') {
31 				maxx = sp;
32 				if (minx == -1)
33 					minx = sp - win->lines[y]->line;
34 				*sp = ' ';
35 			}
36 		if (minx != -1)
37 			touchline(win, y, minx,
38 			    maxx - win->lines[y]->line);
39 		startx = 0;
40 	}
41 	return (OK);
42 }
43