xref: /original-bsd/lib/libcurses/clrtoeol.c (revision b4971bb3)
1 /*
2  * Copyright (c) 1981, 1993
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[] = "@(#)clrtoeol.c	8.1 (Berkeley) 06/04/93";
10 #endif	/* not lint */
11 
12 #include <curses.h>
13 
14 /*
15  * wclrtoeol --
16  *	Clear up to the end of line.
17  */
18 int
19 wclrtoeol(win)
20 	register WINDOW *win;
21 {
22 	register int minx, x, y;
23 	register __LDATA *end, *maxx, *sp;
24 
25 	y = win->cury;
26 	x = win->curx;
27 	if (win->lines[y]->flags & __ISPASTEOL) {
28 		if (y < win->maxy - 1) {
29 			y++;
30 			x = 0;
31 		} else
32 			return (OK);
33 	}
34 	end = &win->lines[y]->line[win->maxx];
35 	minx = -1;
36 	maxx = &win->lines[y]->line[x];
37 	for (sp = maxx; sp < end; sp++)
38 		if (sp->ch != ' ' || sp->attr != 0) {
39 			maxx = sp;
40 			if (minx == -1)
41 				minx = sp - win->lines[y]->line;
42 			sp->ch = ' ';
43 			sp->attr = 0;
44 		}
45 #ifdef DEBUG
46 	__CTRACE("CLRTOEOL: minx = %d, maxx = %d, firstch = %d, lastch = %d\n",
47 	    minx, maxx - win->lines[y]->line, *win->lines[y]->firstchp,
48 	    *win->lines[y]->lastchp);
49 #endif
50 	/* Update firstch and lastch for the line. */
51 	return (__touchline(win, y, x, win->maxx - 1, 0));
52 }
53 
54 
55 
56 
57 
58