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 /* Copyright (c) 1988 AT&T */ 23 /* All Rights Reserved */ 24 25 26 /* 27 * Copyright (c) 1997, by Sun Mircrosystems, Inc. 28 * All rights reserved. 29 */ 30 31 /*LINTLIBRARY*/ 32 33 #include <sys/types.h> 34 #include "private.h" 35 36 /* 37 * This routine checks the supplied values against the values of 38 * current and top items. If a value has changed then one of 39 * terminate routines is called. Following the actual change of 40 * the value is the calling of the initialize routines. 41 */ 42 43 void 44 _affect_change(MENU *m, int newtop, ITEM *newcurrent) 45 { 46 ITEM *oldcur; 47 int topchange = FALSE, curchange = FALSE; 48 49 /* Call term and init routines if posted */ 50 if (Posted(m)) { 51 52 /* If current has changed terminate the old item. */ 53 if (newcurrent != Current(m)) { 54 Iterm(m); 55 curchange = TRUE; 56 } 57 58 /* If top has changed then call menu init function */ 59 if (newtop != Top(m)) { 60 Mterm(m); 61 topchange = TRUE; 62 } 63 64 oldcur = Current(m); 65 Top(m) = newtop; 66 Current(m) = newcurrent; 67 68 if (topchange) { 69 /* Init the new page if top has changed */ 70 Minit(m); 71 } 72 73 if (curchange) { 74 /* Unmark the old item and mark the new one */ 75 _movecurrent(m, oldcur); 76 /* Init the new item if current changed */ 77 Iinit(m); 78 } 79 80 /* If anything changed go change user's copy of menu */ 81 if (topchange || curchange) { 82 _show(m); 83 } else { 84 _position_cursor(m); 85 } 86 87 } else { 88 /* Just change Top and Current if not posted */ 89 Top(m) = newtop; 90 Current(m) = newcurrent; 91 } 92 } 93