1 /* 2 * Copyright (c) 1981 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)mvwin.c 5.5 (Berkeley) 08/23/92"; 10 #endif /* not lint */ 11 12 #include <curses.h> 13 14 /* 15 * mvwin -- 16 * Relocate the starting position of a window. 17 */ 18 int 19 mvwin(win, by, bx) 20 register WINDOW *win; 21 register int by, bx; 22 { 23 register WINDOW *orig; 24 register int dy, dx; 25 26 if (by + win->_maxy > LINES || bx + win->_maxx > COLS) 27 return (ERR); 28 dy = by - win->_begy; 29 dx = bx - win->_begx; 30 orig = win->_orig; 31 if (orig == NULL) { 32 orig = win; 33 do { 34 win->_begy += dy; 35 win->_begx += dx; 36 __swflags(win); 37 win = win->_nextp; 38 } while (win != orig); 39 } else { 40 if (by < orig->_begy || win->_maxy + dy > orig->_maxy) 41 return (ERR); 42 if (bx < orig->_begx || win->_maxx + dx > orig->_maxx) 43 return (ERR); 44 win->_begy = by; 45 win->_begx = bx; 46 __swflags(win); 47 __set_subwin(orig, win); 48 } 49 touchwin(win); 50 return (OK); 51 } 52