xref: /csrg-svn/lib/libcurses/touchwin.c (revision 67082)
122685Sdist /*
2*67082Sbostic  * Copyright (c) 1981, 1993, 1994
361272Sbostic  *	The Regents of the University of California.  All rights reserved.
434677Sbostic  *
542657Sbostic  * %sccs.include.redist.c%
622685Sdist  */
722685Sdist 
822685Sdist #ifndef lint
9*67082Sbostic static char sccsid[] = "@(#)touchwin.c	8.2 (Berkeley) 05/04/94";
1034677Sbostic #endif /* not lint */
1122685Sdist 
12*67082Sbostic #include "curses.h"
132265Sarnold 
142265Sarnold /*
1556650Selan  * touchline --
1656650Selan  *	Touch a given line.
1756650Selan  */
1856650Selan int
touchline(win,y,sx,ex)1956650Selan touchline(win, y, sx, ex)
2056650Selan 	WINDOW *win;
2156650Selan 	register int y, sx, ex;
2256650Selan {
2358045Selan 	return (__touchline(win, y, sx, ex, 1));
2456650Selan }
2556650Selan 
2656650Selan 
2756650Selan /*
2855981Sbostic  * touchwin --
2955981Sbostic  *	Make it look like the whole window has been changed.
302265Sarnold  */
3155981Sbostic int
touchwin(win)322265Sarnold touchwin(win)
3355981Sbostic 	register WINDOW *win;
342265Sarnold {
3555981Sbostic 	register int y, maxy;
3612341Sarnold 
3755981Sbostic #ifdef DEBUG
3860058Sbostic 	__CTRACE("touchwin: (%0.2o)\n", win);
3955981Sbostic #endif
4056238Selan 	maxy = win->maxy;
4119898Sbloom 	for (y = 0; y < maxy; y++)
4256650Selan 		__touchline(win, y, 0, win->maxx - 1, 1);
4357472Sbostic 	return (OK);
4412341Sarnold }
4512341Sarnold 
4656650Selan 
4755981Sbostic int
__touchwin(win)4856650Selan __touchwin(win)
4955981Sbostic 	register WINDOW *win;
5056650Selan {
5156650Selan 	register int y, maxy;
5256650Selan 
5356650Selan #ifdef DEBUG
5460058Sbostic 	__CTRACE("touchwin: (%0.2o)\n", win);
5556650Selan #endif
5656650Selan 	maxy = win->maxy;
5756650Selan 	for (y = 0; y < maxy; y++)
5856650Selan 		__touchline(win, y, 0, win->maxx - 1, 0);
5957472Sbostic 	return (OK);
6056650Selan }
6156650Selan 
6256650Selan int
__touchline(win,y,sx,ex,force)6356650Selan __touchline(win, y, sx, ex, force)
6456650Selan 	register WINDOW *win;
6555981Sbostic 	register int y, sx, ex;
6656650Selan 	int force;
6719898Sbloom {
6855981Sbostic #ifdef DEBUG
6960058Sbostic 	__CTRACE("touchline: (%0.2o, %d, %d, %d, %d)\n", win, y, sx, ex, force);
7060058Sbostic 	__CTRACE("touchline: first = %d, last = %d\n",
7156715Selan 	    *win->lines[y]->firstchp, *win->lines[y]->lastchp);
7255981Sbostic #endif
7356650Selan 	if (force)
7456650Selan 		win->lines[y]->flags |= __FORCEPAINT;
7556238Selan 	sx += win->ch_off;
7656238Selan 	ex += win->ch_off;
7756238Selan 	if (!(win->lines[y]->flags & __ISDIRTY)) {
7856238Selan 		win->lines[y]->flags |= __ISDIRTY;
7956715Selan 		*win->lines[y]->firstchp = sx;
8056715Selan 		*win->lines[y]->lastchp = ex;
8155981Sbostic 	} else {
8256715Selan 		if (*win->lines[y]->firstchp > sx)
8356715Selan 			*win->lines[y]->firstchp = sx;
8456715Selan 		if (*win->lines[y]->lastchp < ex)
8556715Selan 			*win->lines[y]->lastchp = ex;
8619898Sbloom 	}
8755981Sbostic #ifdef DEBUG
8860058Sbostic 	__CTRACE("touchline: first = %d, last = %d\n",
8956715Selan 	    *win->lines[y]->firstchp, *win->lines[y]->lastchp);
9055981Sbostic #endif
9157472Sbostic 	return (OK);
922265Sarnold }
9358045Selan 
9458045Selan 
95