xref: /csrg-svn/lib/libcurses/touchwin.c (revision 57472)
122685Sdist /*
234677Sbostic  * Copyright (c) 1981 Regents of the University of California.
334677Sbostic  * All rights reserved.
434677Sbostic  *
542657Sbostic  * %sccs.include.redist.c%
622685Sdist  */
722685Sdist 
822685Sdist #ifndef lint
9*57472Sbostic static char sccsid[] = "@(#)touchwin.c	5.10 (Berkeley) 01/11/93";
1034677Sbostic #endif /* not lint */
1122685Sdist 
1255981Sbostic #include <curses.h>
132265Sarnold 
1456650Selan 
152265Sarnold /*
1656650Selan  * touchline --
1756650Selan  *	Touch a given line.
1856650Selan  */
1956650Selan int
2056650Selan touchline(win, y, sx, ex)
2156650Selan 	WINDOW *win;
2256650Selan 	register int y, sx, ex;
2356650Selan {
2456650Selan 	__touchline(win, y, sx, ex, 1);
2556650Selan }
2656650Selan 
2756650Selan 
2856650Selan /*
2955981Sbostic  * touchwin --
3055981Sbostic  *	Make it look like the whole window has been changed.
312265Sarnold  */
3255981Sbostic int
332265Sarnold touchwin(win)
3455981Sbostic 	register WINDOW *win;
352265Sarnold {
3655981Sbostic 	register int y, maxy;
3712341Sarnold 
3855981Sbostic #ifdef DEBUG
3955981Sbostic 	__TRACE("touchwin: (%0.2o)\n", win);
4055981Sbostic #endif
4156238Selan 	maxy = win->maxy;
4219898Sbloom 	for (y = 0; y < maxy; y++)
4356650Selan 		__touchline(win, y, 0, win->maxx - 1, 1);
44*57472Sbostic 	return (OK);
4512341Sarnold }
4612341Sarnold 
4756650Selan 
4855981Sbostic int
4956650Selan __touchwin(win)
5055981Sbostic 	register WINDOW *win;
5156650Selan {
5256650Selan 	register int y, maxy;
5356650Selan 
5456650Selan #ifdef DEBUG
5556650Selan 	__TRACE("touchwin: (%0.2o)\n", win);
5656650Selan #endif
5756650Selan 	maxy = win->maxy;
5856650Selan 	for (y = 0; y < maxy; y++)
5956650Selan 		__touchline(win, y, 0, win->maxx - 1, 0);
60*57472Sbostic 	return (OK);
6156650Selan }
6256650Selan 
6356650Selan int
6456650Selan __touchline(win, y, sx, ex, force)
6556650Selan 	register WINDOW *win;
6655981Sbostic 	register int y, sx, ex;
6756650Selan 	int force;
6819898Sbloom {
6955981Sbostic #ifdef DEBUG
7056650Selan 	__TRACE("touchline: (%0.2o, %d, %d, %d, %d)\n", win, y, sx, ex, force);
7155981Sbostic 	__TRACE("touchline: first = %d, last = %d\n",
7256715Selan 	    *win->lines[y]->firstchp, *win->lines[y]->lastchp);
7355981Sbostic #endif
7456650Selan 	if (force)
7556650Selan 		win->lines[y]->flags |= __FORCEPAINT;
7656238Selan 	sx += win->ch_off;
7756238Selan 	ex += win->ch_off;
7856238Selan 	if (!(win->lines[y]->flags & __ISDIRTY)) {
7956238Selan 		win->lines[y]->flags |= __ISDIRTY;
8056715Selan 		*win->lines[y]->firstchp = sx;
8156715Selan 		*win->lines[y]->lastchp = ex;
8255981Sbostic 	} else {
8356715Selan 		if (*win->lines[y]->firstchp > sx)
8456715Selan 			*win->lines[y]->firstchp = sx;
8556715Selan 		if (*win->lines[y]->lastchp < ex)
8656715Selan 			*win->lines[y]->lastchp = ex;
8719898Sbloom 	}
8855981Sbostic #ifdef DEBUG
8955981Sbostic 	__TRACE("touchline: first = %d, last = %d\n",
9056715Selan 	    *win->lines[y]->firstchp, *win->lines[y]->lastchp);
9155981Sbostic #endif
92*57472Sbostic 	return (OK);
932265Sarnold }
94