summaryrefslogtreecommitdiffstats
path: root/lib/libncurses/lib_refresh.c
blob: 994802525a14e108ef54788e98c24948bca33965 (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

/* 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_refresh.c
 *
 *	The routines wredrawln(), wrefresh() and wnoutrefresh().
 *
 */

#include "curses.priv.h"

int wredrawln(WINDOW *win, int beg, int num)
{
	T(("wredrawln(%x,%d,%d) called", win, beg, num));
	touchline(win, beg, num);
	wrefresh(win);
	return OK;
}

int wrefresh(WINDOW *win)
{
	T(("wrefresh(%x) called", win));

	if (win == curscr)
	    	curscr->_clear = TRUE;
	else
	    	wnoutrefresh(win);
	return(doupdate());
}

int wnoutrefresh(WINDOW *win)
{
int	i, j;
int	begx = win->_begx;
int	begy = win->_begy;
int	m, n;

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

	/*
	 * This function will break badly if we try to refresh a pad.
	 */
	if ((win == 0)
	 || (win->_flags & _ISPAD))
		return(ERR);

	/*
	 * If 'newscr' has a different background than the window that we're
	 * trying to refresh, we'll have to copy the whole thing.
	 */
	if (win->_bkgd != newscr->_bkgd) {
		touchwin(win);
		newscr->_bkgd = win->_bkgd;
	}
	newscr->_attrs = win->_attrs;

	win->_flags &= ~_HASMOVED;
	for (i = 0, m = begy; i <= win->_maxy; i++, m++) {
		if (win->_firstchar[i] != _NOCHANGE) {
			j = win->_firstchar[i];
			n = j + begx;
			for (; j <= win->_lastchar[i]; j++, n++) {
		    	if (win->_line[i][j] != newscr->_line[m][n]) {
					newscr->_line[m][n] = win->_line[i][j];

					if (newscr->_firstchar[m] == _NOCHANGE)
			   			newscr->_firstchar[m] = newscr->_lastchar[m] = n;
					else if (n < newscr->_firstchar[m])
			   			newscr->_firstchar[m] = n;
					else if (n > newscr->_lastchar[m])
			   			newscr->_lastchar[m] = n;
		    	}
			}
		}
		win->_firstchar[i] = win->_lastchar[i] = _NOCHANGE;
	}

	if (win->_clear) {
	   	win->_clear = FALSE;
	   	newscr->_clear = TRUE;
	}

	if (! win->_leave) {
	   	newscr->_cury = win->_cury + win->_begy;
	   	newscr->_curx = win->_curx + win->_begx;
	}
	return(OK);
}
OpenPOWER on IntegriCloud