xref: /titanic_41/usr/src/ucblib/libcurses/clrtoeol.c (revision ac88567a7a5bb7f01cf22cf366bc9d6203e24d7a)
1 /*
2  * Copyright 2001 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
7 /*	  All Rights Reserved  	*/
8 
9 /*
10  * Copyright (c) 1980 Regents of the University of California.
11  * All rights reserved.  The Berkeley software License Agreement
12  * specifies the terms and conditions for redistribution.
13  */
14 
15 #pragma ident	"%Z%%M%	%I%	%E% SMI"
16 
17 /*LINTLIBRARY*/
18 
19 #ifndef lint
20 static char
21 sccsid[] = "@(#)clrtoeol.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */
22 #endif /* not lint */
23 
24 #include	<stddef.h>
25 #include	"curses.ext"
26 
27 /*
28  *	This routine clears up to the end of line
29  */
30 
31 int
32 wclrtoeol(WINDOW *win)
33 {
34 	char	*sp, *end;
35 	int	y, x;
36 	char	*maxx;
37 	ptrdiff_t	minx;
38 
39 	y = win->_cury;
40 	x = win->_curx;
41 	end = &win->_y[y][win->_maxx];
42 	minx = _NOCHANGE;
43 	maxx = &win->_y[y][x];
44 	for (sp = maxx; sp < end; sp++)
45 		if (*sp != ' ') {
46 			maxx = sp;
47 			if (minx == _NOCHANGE)
48 				minx = sp - win->_y[y];
49 			*sp = ' ';
50 		}
51 	/*
52 	 * update firstch and lastch for the line
53 	 */
54 	(void) touchline(win, y, win->_curx, win->_maxx - 1);
55 
56 #ifdef DEBUG
57 	fprintf(outf, "CLRTOEOL: minx = %d, maxx = %d, firstch = %d,"
58 	    " lastch = %d\n", minx, maxx - win->_y[y], win->_firstch[y],
59 	    win->_lastch[y]);
60 #endif
61 	return (OK);
62 }
63