add mpool
[unix-history] / usr / src / lib / libcurses / mvwin.c
CommitLineData
87c6fcf8 1/*
2f14f200
KB
2 * Copyright (c) 1981 Regents of the University of California.
3 * All rights reserved.
4 *
e21c485a 5 * %sccs.include.redist.c%
87c6fcf8
DF
6 */
7
8#ifndef lint
e21c485a 9static char sccsid[] = "@(#)mvwin.c 5.4 (Berkeley) %G%";
2f14f200 10#endif /* not lint */
87c6fcf8 11
45d02bb5
KA
12# include "curses.ext"
13
14/*
15 * relocate the starting position of a window
16 *
45d02bb5
KA
17 */
18
19mvwin(win, by, bx)
20reg WINDOW *win;
21reg int by, bx; {
22
52f06ac3
JB
23 register WINDOW *orig;
24 register int dy, dx;
25
45d02bb5
KA
26 if (by + win->_maxy > LINES || bx + win->_maxx > COLS)
27 return ERR;
52f06ac3
JB
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 }
40 else {
41 if (by < orig->_begy || win->_maxy + dy > orig->_maxy)
42 return ERR;
43 if (bx < orig->_begx || win->_maxx + dx > orig->_maxx)
44 return ERR;
45 win->_begy = by;
46 win->_begx = bx;
47 _swflags_(win);
48 _set_subwin_(orig, win);
49 }
45d02bb5
KA
50 touchwin(win);
51 return OK;
52}