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 /*LINTLIBRARY*/
16
17 #ifndef lint
18 static char
19 sccsid[] = "@(#)clrtoeol.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */
20 #endif /* not lint */
21
22 #include <stddef.h>
23 #include "curses.ext"
24
25 /*
26 * This routine clears up to the end of line
27 */
28
29 int
wclrtoeol(WINDOW * win)30 wclrtoeol(WINDOW *win)
31 {
32 char *sp, *end;
33 int y, x;
34 char *maxx;
35 ptrdiff_t minx;
36
37 y = win->_cury;
38 x = win->_curx;
39 end = &win->_y[y][win->_maxx];
40 minx = _NOCHANGE;
41 maxx = &win->_y[y][x];
42 for (sp = maxx; sp < end; sp++)
43 if (*sp != ' ') {
44 maxx = sp;
45 if (minx == _NOCHANGE)
46 minx = sp - win->_y[y];
47 *sp = ' ';
48 }
49 /*
50 * update firstch and lastch for the line
51 */
52 (void) touchline(win, y, win->_curx, win->_maxx - 1);
53
54 #ifdef DEBUG
55 fprintf(outf, "CLRTOEOL: minx = %d, maxx = %d, firstch = %d,"
56 " lastch = %d\n", minx, maxx - win->_y[y], win->_firstch[y],
57 win->_lastch[y]);
58 #endif
59 return (OK);
60 }
61