1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright (c) 1995, by Sun Microsystems, Inc. 24 * All rights reserved. 25 */ 26 27 #pragma ident "%Z%%M% %I% %E% SMI" 28 29 /* 30 * mvwin.c 31 * 32 * XCurses Library 33 * 34 * Copyright 1990, 1995 by Mortice Kern Systems Inc. All rights reserved. 35 * 36 */ 37 38 #ifdef M_RCSID 39 #ifndef lint 40 static char rcsID[] = "$Header: /rd/src/libc/xcurses/rcs/mvwin.c 1.3 1995/06/15 19:19:58 ant Exp $"; 41 #endif 42 #endif 43 44 #include <private.h> 45 46 /*f 47 * Move window so that the upper left-hand corner is at (x,y). If the move 48 * would cause the window to be off the screen, it is an error and the 49 * window is not moved. Moving subwindows is allowed, but should be 50 * avoided. 51 */ 52 int 53 mvwin(w, by, bx) 54 WINDOW *w; 55 int by, bx; 56 { 57 int i, dx, dy; 58 WINDOW *parent = w->_parent; 59 60 #ifdef M_CURSES_TRACE 61 __m_trace("mvwin(%p, %d, %d)", w, by, bx); 62 #endif 63 64 /* Check lower bounds of new window position. */ 65 if (by < 0 || bx < 0) 66 return __m_return_code("mvwin", ERR); 67 68 if (parent == (WINDOW *) 0) { 69 /* Check upper bounds of normal window. */ 70 if (lines < by + w->_maxy || columns < bx + w->_maxx) 71 return __m_return_code("mvwin", ERR); 72 } else { 73 /* Check upper bounds of sub-window. */ 74 if (parent->_begy + parent->_maxy < by + w->_maxy 75 || parent->_begx + parent->_maxx < bx + w->_maxx) 76 return __m_return_code("mvwin", ERR); 77 78 /* Move the sub-window's line pointers to the parent 79 * window's data. 80 */ 81 dy = by - parent->_begy; 82 dx = bx - parent->_begx; 83 84 for (i = 0; i <= w->_maxy; ++i) 85 w->_line[i] = &parent->_line[dy++][dx]; 86 } 87 88 w->_begy = by; 89 w->_begx = bx; 90 (void) wtouchln(w, 0, w->_maxy, 1); 91 92 return __m_return_code("mvwin", OK); 93 } 94 95 int 96 mvderwin(w, py, px) 97 WINDOW *w; 98 int py, px; 99 { 100 int code; 101 WINDOW *parent; 102 103 #ifdef M_CURSES_TRACE 104 __m_trace("mvderwin(%p, %d, %d)", w, py, px); 105 #endif 106 107 parent = w->_parent; 108 109 if (parent == (WINDOW *) 0) 110 return __m_return_code("mvderwin", ERR); 111 112 /* Absolute screen address. */ 113 py += parent->_begy; 114 px += parent->_begx; 115 116 code = mvwin(w, py, px); 117 118 return __m_return_code("mvderwin", code); 119 } 120