xref: /original-bsd/lib/libcurses/clrtobot.c (revision 730930d2)
1 /*
2  * Copyright (c) 1981, 1993, 1994
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)clrtobot.c	8.2 (Berkeley) 05/04/94";
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, starty, y;
23 	register __LDATA *sp, *end, *maxx;
24 
25 	if (win->lines[win->cury]->flags & __ISPASTEOL) {
26 		starty = win->cury + 1;
27 		startx = 0;
28 	} else {
29 		starty = win->cury;
30 		startx = win->curx;
31 	}
32 	for (y = starty; y < win->maxy; y++) {
33 		minx = -1;
34 		end = &win->lines[y]->line[win->maxx];
35 		for (sp = &win->lines[y]->line[startx]; sp < end; sp++)
36 			if (sp->ch != ' ' || sp->attr != 0) {
37 				maxx = sp;
38 				if (minx == -1)
39 					minx = sp - win->lines[y]->line;
40 				sp->ch = ' ';
41 				sp->attr = 0;
42 			}
43 		if (minx != -1)
44 			__touchline(win, y, minx, maxx - win->lines[y]->line,
45 		            0);
46 		startx = 0;
47 	}
48 	return (OK);
49 }
50