]> ncurses.scripts.mit.edu Git - ncurses.git/blob - ncurses/lib_erase.c
ncurses 4.1
[ncurses.git] / ncurses / lib_erase.c
1
2 /***************************************************************************
3 *                            COPYRIGHT NOTICE                              *
4 ****************************************************************************
5 *                ncurses is copyright (C) 1992-1995                        *
6 *                          Zeyd M. Ben-Halim                               *
7 *                          zmbenhal@netcom.com                             *
8 *                          Eric S. Raymond                                 *
9 *                          esr@snark.thyrsus.com                           *
10 *                                                                          *
11 *        Permission is hereby granted to reproduce and distribute ncurses  *
12 *        by any means and for any fee, whether alone or as part of a       *
13 *        larger distribution, in source or in binary form, PROVIDED        *
14 *        this notice is included with any such distribution, and is not    *
15 *        removed from any of its header files. Mention of ncurses in any   *
16 *        applications linked with it is highly appreciated.                *
17 *                                                                          *
18 *        ncurses comes AS IS with no warranty, implied or expressed.       *
19 *                                                                          *
20 ***************************************************************************/
21
22
23 /*
24 **      lib_erase.c
25 **
26 **      The routine werase().
27 **
28 */
29
30 #include <curses.priv.h>
31
32 MODULE_ID("$Id: lib_erase.c,v 1.7 1997/02/01 23:18:18 tom Exp $")
33
34 int  werase(WINDOW      *win)
35 {
36 int     y;
37 chtype  *sp, *end, *start, *maxx = NULL;
38 short   minx;
39
40         T((T_CALLED("werase(%p)"), win));
41
42         for (y = 0; y <= win->_maxy; y++) {
43                 minx = _NOCHANGE;
44                 start = win->_line[y].text;
45                 end = &start[win->_maxx];
46
47                 maxx = start;
48                 for (sp = start; sp <= end; sp++) {
49                         maxx = sp;
50                         if (minx == _NOCHANGE)
51                                         minx = sp - start;
52                         *sp = _nc_background(win);
53                 }
54
55                 if (minx != _NOCHANGE) {
56                         if (win->_line[y].firstchar > minx ||
57                             win->_line[y].firstchar == _NOCHANGE)
58                                 win->_line[y].firstchar = minx;
59
60                         if (win->_line[y].lastchar < maxx - win->_line[y].text)
61                             win->_line[y].lastchar = maxx - win->_line[y].text;
62                 }
63         }
64         win->_curx = win->_cury = 0;
65         win->_flags &= ~_WRAPPED;
66         _nc_synchook(win);
67         returnCode(OK);
68 }