aboutsummaryrefslogtreecommitdiff
path: root/lib/libncurses/lib_erase.c
blob: 38bf5ea8d93ea473237cab9519d484a6b4fe2cad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for   *
*  details. If they are missing then this copy is in violation of    *
*  the copyright conditions.                                        */

/*
**	lib_erase.c
**
**	The routine werase().
**
*/

#include "curses.priv.h"
#include "terminfo.h"

int  werase(WINDOW	*win)
{
int	y;
chtype	*sp, *end, *start, *maxx = NULL;
int	minx;

	T(("werase(%x) called", win));

	for (y = win->_regtop; y <= win->_regbottom; y++) {
	    	minx = _NOCHANGE;
	    	start = win->_line[y];
	    	end = &start[win->_maxx];

	    	maxx = start;
	    	for (sp = start; sp <= end; sp++) {
		    	maxx = sp;
		    	if (minx == _NOCHANGE)
					minx = sp - start;
			*sp = _nc_background(win);
	    	}

	    	if (minx != _NOCHANGE) {
			if (win->_firstchar[y] > minx ||
		    	    win->_firstchar[y] == _NOCHANGE)
		    		win->_firstchar[y] = minx;

			if (win->_lastchar[y] < maxx - win->_line[y])
		    	win->_lastchar[y] = maxx - win->_line[y];
	    	}
	}
	win->_curx = win->_cury = 0;
	return OK;
}