xref: /original-bsd/lib/libcurses/touchwin.c (revision fa921481)
1 /*
2  * Copyright (c) 1981 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)touchwin.c	5.4 (Berkeley) 06/01/90";
10 #endif /* not lint */
11 
12 # include	"curses.ext"
13 
14 /*
15  * make it look like the whole window has been changed.
16  *
17  */
18 touchwin(win)
19 register WINDOW	*win;
20 {
21 	register int	y, maxy;
22 
23 # ifdef	DEBUG
24 	fprintf(outf, "TOUCHWIN(%0.2o)\n", win);
25 # endif
26 	maxy = win->_maxy;
27 	for (y = 0; y < maxy; y++)
28 		touchline(win, y, 0, win->_maxx - 1);
29 }
30 
31 /*
32  * touch a given line
33  */
34 touchline(win, y, sx, ex)
35 register WINDOW	*win;
36 register int	y, sx, ex;
37 {
38 # ifdef DEBUG
39 	fprintf(outf, "TOUCHLINE(%0.2o, %d, %d, %d)\n", win, y, sx, ex);
40 	fprintf(outf, "TOUCHLINE:first = %d, last = %d\n", win->_firstch[y], win->_lastch[y]);
41 # endif
42 	sx += win->_ch_off;
43 	ex += win->_ch_off;
44 	if (win->_firstch[y] == _NOCHANGE) {
45 		win->_firstch[y] = sx;
46 		win->_lastch[y] = ex;
47 	}
48 	else {
49 		if (win->_firstch[y] > sx)
50 			win->_firstch[y] = sx;
51 		if (win->_lastch[y] < ex)
52 			win->_lastch[y] = ex;
53 	}
54 # ifdef	DEBUG
55 	fprintf(outf, "TOUCHLINE:first = %d, last = %d\n", win->_firstch[y], win->_lastch[y]);
56 # endif
57 }
58