xref: /original-bsd/lib/libcurses/id_subwins.c (revision 092d9b4e)
1 /*
2  * Copyright (c) 1981 Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that this notice is preserved and that due credit is given
7  * to the University of California at Berkeley. The name of the University
8  * may not be used to endorse or promote products derived from this
9  * software without specific prior written permission. This software
10  * is provided ``as is'' without express or implied warranty.
11  */
12 
13 #ifndef lint
14 static char sccsid[] = "@(#)id_subwins.c	5.2 (Berkeley) 06/08/88";
15 #endif /* not lint */
16 
17 # include	"curses.ext"
18 
19 /*
20  * _id_subwins:
21  *	Re-sync the pointers to _y for all the subwindows.
22  *
23  */
24 _id_subwins(orig)
25 register WINDOW	*orig;
26 {
27 	register WINDOW	*win;
28 	register int	realy;
29 	register int	y, oy, x;
30 
31 	realy = orig->_begy + orig->_cury;
32 	for (win = orig->_nextp; win != orig; win = win->_nextp) {
33 		/*
34 		 * If the window ends before our current position,
35 		 * don't need to do anything.
36 		 */
37 		if (win->_begy + win->_maxy <= realy)
38 			continue;
39 
40 		oy = orig->_cury;
41 		for (y = realy - win->_begy; y < win->_maxy; y++, oy++)
42 			win->_y[y] = &orig->_y[oy][win->_ch_off];
43 	}
44 }
45