xref: /titanic_41/usr/src/ucblib/libcurses/touchwin.c (revision 1402f64f9efa57c2c2cba776f3f45c67e6055deb)
1 /*
2  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
7 /*	  All Rights Reserved  	*/
8 
9 /*
10  * Copyright (c) 1980 Regents of the University of California.
11  * All rights reserved.  The Berkeley software License Agreement
12  * specifies the terms and conditions for redistribution.
13  */
14 
15 #pragma ident	"%Z%%M%	%I%	%E% SMI"
16 
17 /*LINTLIBRARY*/
18 
19 #ifndef lint
20 static char
21 sccsid[] = "@(#)touchwin.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */
22 #endif	/* not lint */
23 
24 #include	"curses.ext"
25 
26 /*
27  * make it look like the whole window has been changed.
28  *
29  */
30 
31 int
32 touchwin(WINDOW *win)
33 {
34 	int	y, maxy;
35 
36 #ifdef	DEBUG
37 	fprintf(outf, "TOUCHWIN(%0.2o)\n", win);
38 #endif
39 	maxy = win->_maxy;
40 	for (y = 0; y < maxy; y++)
41 		(void) touchline(win, y, 0, win->_maxx - 1);
42 	return (OK);
43 }
44 
45 /*
46  * touch a given line
47  */
48 
49 int
50 touchline(WINDOW *win, int y, int sx, int ex)
51 {
52 #ifdef DEBUG
53 	fprintf(outf, "TOUCHLINE(%0.2o, %d, %d, %d)\n", win, y, sx, ex);
54 	fprintf(outf, "TOUCHLINE:first = %d, last = %d\n",
55 	    win->_firstch[y], win->_lastch[y]);
56 #endif
57 	sx += win->_ch_off;
58 	ex += win->_ch_off;
59 	if (win->_firstch[y] == _NOCHANGE) {
60 		win->_firstch[y] = (short)sx;
61 		win->_lastch[y] = (short)ex;
62 	} else {
63 		if (win->_firstch[y] > sx)
64 			win->_firstch[y] = (short)sx;
65 		if (win->_lastch[y] < ex)
66 			win->_lastch[y] = (short)ex;
67 	}
68 #ifdef	DEBUG
69 	fprintf(outf, "TOUCHLINE:first = %d, last = %d\n",
70 	    win->_firstch[y], win->_lastch[y]);
71 #endif
72 	return (OK);
73 }
74