1 /*
2 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
5
6 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
8
9 /*
10 * Copyright (c) 1980 Regents of the University of California.
11 * All rights reserved. The Berkeley software License Agreement
12 * specifies the terms and conditions for redistribution.
13 */
14
15 /*LINTLIBRARY*/
16
17 #ifndef lint
18 static char
19 sccsid[] = "@(#)mvwin.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */
20 #endif /* not lint */
21
22 #include "curses.ext"
23
24 /*
25 * relocate the starting position of a window
26 */
27
28 int
mvwin(WINDOW * win,int by,int bx)29 mvwin(WINDOW *win, int by, int bx)
30 {
31 WINDOW *orig;
32 int dy, dx;
33
34 if (by + win->_maxy > LINES || bx + win->_maxx > COLS)
35 return (ERR);
36 dy = by - win->_begy;
37 dx = bx - win->_begx;
38 orig = win->_orig;
39 if (orig == NULL) {
40 orig = win;
41 do {
42 win->_begy += dy;
43 win->_begx += dx;
44 _swflags_(win);
45 win = win->_nextp;
46 } while (win != orig);
47 } else {
48 if (by < orig->_begy || win->_maxy + dy > orig->_maxy)
49 return (ERR);
50 if (bx < orig->_begx || win->_maxx + dx > orig->_maxx)
51 return (ERR);
52 win->_begy = (short)by;
53 win->_begx = (short)bx;
54 _swflags_(win);
55 _set_subwin_(orig, win);
56 }
57 (void) touchwin(win);
58 return (OK);
59 }
60