122662Sdist /*
2*67082Sbostic * Copyright (c) 1981, 1993, 1994
361268Sbostic * The Regents of the University of California. All rights reserved.
434677Sbostic *
542653Sbostic * %sccs.include.redist.c%
622662Sdist */
722662Sdist
822662Sdist #ifndef lint
9*67082Sbostic static char sccsid[] = "@(#)erase.c 8.2 (Berkeley) 05/04/94";
1055957Sbostic #endif /* not lint */
1122662Sdist
12*67082Sbostic #include "curses.h"
132248Sarnold
142248Sarnold /*
1555957Sbostic * werase --
1655957Sbostic * Erases everything on the window.
172248Sarnold */
1855957Sbostic int
werase(win)192248Sarnold werase(win)
2055957Sbostic register WINDOW *win;
2155957Sbostic {
222248Sarnold
2355957Sbostic register int minx, y;
2456647Selan register __LDATA *sp, *end, *start, *maxx;
252248Sarnold
2655957Sbostic #ifdef DEBUG
2760058Sbostic __CTRACE("werase: (%0.2o)\n", win);
2855957Sbostic #endif
2956238Selan for (y = 0; y < win->maxy; y++) {
3056238Selan minx = -1;
3156238Selan start = win->lines[y]->line;
3256238Selan end = &start[win->maxx];
332248Sarnold for (sp = start; sp < end; sp++)
3456647Selan if (sp->ch != ' ' || sp->attr != 0) {
3556647Selan maxx = sp;
3656238Selan if (minx == -1)
372248Sarnold minx = sp - start;
3856647Selan sp->ch = ' ';
3956647Selan sp->attr = 0;
402248Sarnold }
4156238Selan if (minx != -1)
4256650Selan __touchline(win, y, minx, maxx - win->lines[y]->line,
4356650Selan 0);
442248Sarnold }
4557472Sbostic return (OK);
462248Sarnold }
47