Ken Arnold edits for document distributed with 4.3BSD
[unix-history] / usr / src / lib / libcurses / mvwin.c
CommitLineData
87c6fcf8
DF
1/*
2 * Copyright (c) 1980 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 */
6
7#ifndef lint
8static char sccsid[] = "@(#)mvwin.c 5.1 (Berkeley) %G%";
9#endif not lint
10
45d02bb5
KA
11# include "curses.ext"
12
13/*
14 * relocate the starting position of a window
15 *
45d02bb5
KA
16 */
17
18mvwin(win, by, bx)
19reg WINDOW *win;
20reg int by, bx; {
21
52f06ac3
JB
22 register WINDOW *orig;
23 register int dy, dx;
24
45d02bb5
KA
25 if (by + win->_maxy > LINES || bx + win->_maxx > COLS)
26 return ERR;
52f06ac3
JB
27 dy = by - win->_begy;
28 dx = bx - win->_begx;
29 orig = win->_orig;
30 if (orig == NULL) {
31 orig = win;
32 do {
33 win->_begy += dy;
34 win->_begx += dx;
35 _swflags_(win);
36 win = win->_nextp;
37 } while (win != orig);
38 }
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 }
45d02bb5
KA
49 touchwin(win);
50 return OK;
51}