xref: /csrg-svn/lib/libcurses/touchwin.c (revision 34677)
122685Sdist /*
2*34677Sbostic  * Copyright (c) 1981 Regents of the University of California.
3*34677Sbostic  * All rights reserved.
4*34677Sbostic  *
5*34677Sbostic  * Redistribution and use in source and binary forms are permitted
6*34677Sbostic  * provided that this notice is preserved and that due credit is given
7*34677Sbostic  * to the University of California at Berkeley. The name of the University
8*34677Sbostic  * may not be used to endorse or promote products derived from this
9*34677Sbostic  * software without specific prior written permission. This software
10*34677Sbostic  * is provided ``as is'' without express or implied warranty.
1122685Sdist  */
1222685Sdist 
1322685Sdist #ifndef lint
14*34677Sbostic static char sccsid[] = "@(#)touchwin.c	5.2 (Berkeley) 06/08/88";
15*34677Sbostic #endif /* not lint */
1622685Sdist 
172265Sarnold # include	"curses.ext"
182265Sarnold 
192265Sarnold /*
202265Sarnold  * make it look like the whole window has been changed.
212265Sarnold  *
222265Sarnold  */
232265Sarnold touchwin(win)
2419898Sbloom register WINDOW	*win;
252265Sarnold {
2619898Sbloom 	register int	y, maxy;
2712341Sarnold 
2819898Sbloom # ifdef	DEBUG
2919898Sbloom 	fprintf(outf, "TOUCHWIN(%0.2o)\n", win);
3019898Sbloom # endif
3119898Sbloom 	maxy = win->_maxy;
3219898Sbloom 	for (y = 0; y < maxy; y++)
3319898Sbloom 		touchline(win, y, 0, win->_maxx - 1);
3412341Sarnold }
3512341Sarnold 
3612341Sarnold /*
3719898Sbloom  * touch a given line
3812341Sarnold  */
3919898Sbloom touchline(win, y, sx, ex)
4019898Sbloom register WINDOW	*win;
4119898Sbloom register int	y, sx, ex;
4219898Sbloom {
4319898Sbloom # ifdef DEBUG
4419898Sbloom 	fprintf(outf, "TOUCHLINE(%0.2o, %d, %d, %d)\n", win, y, sx, ex);
4519898Sbloom 	fprintf(outf, "TOUCHLINE:first = %d, last = %d\n", win->_firstch[y], win->_lastch[y]);
4619898Sbloom # endif
4719898Sbloom 	sx += win->_ch_off;
4819898Sbloom 	ex += win->_ch_off;
4919898Sbloom 	if (win->_firstch[y] == _NOCHANGE) {
5019898Sbloom 		win->_firstch[y] = sx;
5119898Sbloom 		win->_lastch[y] = ex;
522265Sarnold 	}
5319898Sbloom 	else {
5419898Sbloom 		if (win->_firstch[y] > sx)
5519898Sbloom 			win->_firstch[y] = sx;
5619898Sbloom 		if (win->_lastch[y] < ex)
5719898Sbloom 			win->_lastch[y] = ex;
5819898Sbloom 	}
5919898Sbloom # ifdef	DEBUG
6019898Sbloom 	fprintf(outf, "TOUCHLINE:first = %d, last = %d\n", win->_firstch[y], win->_lastch[y]);
6119898Sbloom # endif
622265Sarnold }
63