xref: /original-bsd/lib/libcurses/touchwin.c (revision 860e07fc)
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.5 (Berkeley) 08/23/92";
10 #endif /* not lint */
11 
12 #include <curses.h>
13 
14 /*
15  * touchwin --
16  *	Make it look like the whole window has been changed.
17  */
18 int
19 touchwin(win)
20 	register WINDOW *win;
21 {
22 	register int y, maxy;
23 
24 #ifdef DEBUG
25 	__TRACE("touchwin: (%0.2o)\n", win);
26 #endif
27 	maxy = win->_maxy;
28 	for (y = 0; y < maxy; y++)
29 		touchline(win, y, 0, win->_maxx - 1);
30 	return (OK);
31 }
32 
33 /*
34  * touchline --
35  *	Touch a given line.
36  */
37 int
38 touchline(win, y, sx, ex)
39 	register WINDOW *win;
40 	register int y, sx, ex;
41 {
42 #ifdef DEBUG
43 	__TRACE("touchline: (%0.2o, %d, %d, %d)\n", win, y, sx, ex);
44 	__TRACE("touchline: first = %d, last = %d\n",
45 	    win->_firstch[y], win->_lastch[y]);
46 #endif
47 	sx += win->_ch_off;
48 	ex += win->_ch_off;
49 	if (win->_firstch[y] == _NOCHANGE) {
50 		win->_firstch[y] = sx;
51 		win->_lastch[y] = ex;
52 	} else {
53 		if (win->_firstch[y] > sx)
54 			win->_firstch[y] = sx;
55 		if (win->_lastch[y] < ex)
56 			win->_lastch[y] = ex;
57 	}
58 #ifdef DEBUG
59 	__TRACE("touchline: first = %d, last = %d\n",
60 	    win->_firstch[y], win->_lastch[y]);
61 #endif
62 	return (OK);
63 }
64