xref: /original-bsd/lib/libcurses/clrtobot.c (revision c4695039)
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.12 (Berkeley) 01/11/93";
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 __LDATA *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->ch != ' ' || sp->attr != 0) {
31 				maxx = sp;
32 				if (minx == -1)
33 					minx = sp - win->lines[y]->line;
34 				sp->ch = ' ';
35 				sp->attr = 0;
36 			}
37 		if (minx != -1)
38 			__touchline(win, y, minx, maxx - win->lines[y]->line,
39 		            0);
40 		startx = 0;
41 	}
42 	return (OK);
43 }
44