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-1998 by Sun Microsystems, Inc. 24 * All rights reserved. 25 */ 26 27 #pragma ident "%Z%%M% %I% %E% SMI" 28 29 /* LINTLIBRARY */ 30 31 /* 32 * mvwin.c 33 * 34 * XCurses Library 35 * 36 * Copyright 1990, 1995 by Mortice Kern Systems Inc. All rights reserved. 37 * 38 */ 39 40 #ifdef M_RCSID 41 #ifndef lint 42 static char rcsID[] = "$Header: /rd/src/libc/xcurses/rcs/mvwin.c 1.3 " 43 "1995/06/15 19:19:58 ant Exp $"; 44 #endif 45 #endif 46 47 #include <private.h> 48 49 /* 50 * Move window so that the upper left-hand corner is at (x,y). If the move 51 * would cause the window to be off the screen, it is an error and the 52 * window is not moved. Moving subwindows is allowed, but should be 53 * avoided. 54 */ 55 int 56 mvwin(WINDOW *w, int by, int bx) 57 { 58 int i, dx, dy; 59 WINDOW *parent = w->_parent; 60 61 /* Check lower bounds of new window position. */ 62 if (by < 0 || bx < 0) 63 return (ERR); 64 65 if (parent == NULL) { 66 /* Check upper bounds of normal window. */ 67 if (lines < by + w->_maxy || columns < bx + w->_maxx) 68 return (ERR); 69 } else { 70 /* Check upper bounds of sub-window. */ 71 if (parent->_begy + parent->_maxy < by + w->_maxy || 72 parent->_begx + parent->_maxx < bx + w->_maxx) 73 return (ERR); 74 75 /* 76 * Move the sub-window's line pointers to the parent 77 * window's data. 78 */ 79 dy = by - parent->_begy; 80 dx = bx - parent->_begx; 81 82 for (i = 0; i <= w->_maxy; ++i) 83 w->_line[i] = &parent->_line[dy++][dx]; 84 } 85 86 w->_begy = (short) by; 87 w->_begx = (short) bx; 88 (void) wtouchln(w, 0, w->_maxy, 1); 89 90 return (OK); 91 } 92 93 int 94 mvderwin(WINDOW *w, int py, int px) 95 { 96 int code; 97 WINDOW *parent; 98 99 parent = w->_parent; 100 101 if (parent == NULL) 102 return (ERR); 103 104 /* Absolute screen address. */ 105 py += parent->_begy; 106 px += parent->_begx; 107 108 code = mvwin(w, py, px); 109 110 return (code); 111 } 112