1 /*
2 * Copyright 2004 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[] = "@(#)erase.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 erases everything on the window.
27 */
28
29 int
werase(WINDOW * win)30 werase(WINDOW *win)
31 {
32 int y;
33 char *sp, *end, *start, *maxx;
34 ptrdiff_t minx;
35
36 #ifdef DEBUG
37 fprintf(outf, "WERASE(%0.2o)\n", win);
38 #endif
39 for (y = 0; y < win->_maxy; y++) {
40 minx = _NOCHANGE;
41 start = win->_y[y];
42 end = &start[win->_maxx];
43 for (sp = start; sp < end; sp++)
44 if (*sp != ' ') {
45 maxx = sp;
46 if (minx == _NOCHANGE)
47 minx = sp - start;
48 *sp = ' ';
49 }
50 if (minx != _NOCHANGE)
51 (void) touchline(win, y, (int)minx,
52 (int)(maxx - win->_y[y]));
53 }
54 win->_curx = win->_cury = 0;
55 return (OK);
56 }
57