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
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.
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]
22 /* Copyright (c) 1988 AT&T */
23 /* All Rights Reserved */
27 * Copyright (c) 1997, by Sun Mircrosystems, Inc.
28 * All rights reserved.
31 #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.10 */
35 #include <sys/types.h>
39 menu_driver(MENU
*m
, int c
)
47 return (E_BAD_ARGUMENT
);
54 return (E_NOT_POSTED
);
59 if (c
> KEY_MAX
&& c
< MAX_COMMAND
) {
61 /* Clear the pattern buffer if not one of these requests */
62 if (c
!= REQ_BACK_PATTERN
&&
63 c
!= REQ_NEXT_MATCH
&&
64 c
!= REQ_PREV_MATCH
) {
66 IthPattern(m
, 0) = '\0';
71 case REQ_RIGHT_ITEM
: {
72 if (Right(current
) == (ITEM
*)0) {
73 ret
= E_REQUEST_DENIED
;
76 current
= Right(current
);
80 if (Left(current
) == (ITEM
*)0) {
81 ret
= E_REQUEST_DENIED
;
84 current
= Left(current
);
88 if (Up(current
) == (ITEM
*)0) {
89 ret
= E_REQUEST_DENIED
;
92 current
= Up(current
);
96 if (Down(current
) == (ITEM
*)0) {
97 ret
= E_REQUEST_DENIED
;
100 current
= Down(current
);
103 case REQ_SCR_ULINE
: {
106 ret
= E_REQUEST_DENIED
;
109 current
= Up(current
);
112 case REQ_SCR_DLINE
: {
113 if (++top
> Rows(m
) - Height(m
)) {
115 ret
= E_REQUEST_DENIED
;
118 current
= Down(current
);
121 case REQ_SCR_UPAGE
: {
122 n
= min(Height(m
), top
);
126 current
= Up(current
);
129 ret
= E_REQUEST_DENIED
;
134 case REQ_SCR_DPAGE
: {
135 n
= min(Height(m
), Rows(m
) - Height(m
) - top
);
139 current
= Down(current
);
142 ret
= E_REQUEST_DENIED
;
147 case REQ_FIRST_ITEM
: {
148 current
= IthItem(m
, 0);
151 case REQ_LAST_ITEM
: {
152 current
= IthItem(m
, Nitems(m
)-1);
155 case REQ_NEXT_MATCH
: {
156 if (IthPattern(m
, 0) != NULL
) {
157 ret
= _match(m
, NULL
, ¤t
);
159 if (Index(current
)+1 >= Nitems(m
)) {
160 current
= IthItem(m
, 0);
162 current
= IthItem(m
, Index(current
)+1);
167 case REQ_NEXT_ITEM
: {
168 if (Index(current
)+1 >= Nitems(m
)) {
170 current
= IthItem(m
, 0);
172 ret
= E_REQUEST_DENIED
;
175 current
= IthItem(m
, Index(current
)+1);
179 case REQ_PREV_MATCH
: {
180 if (IthPattern(m
, 0) != NULL
) {
181 ret
= _match(m
, '\b', ¤t
);
183 /* This differs from PREV_ITEM in that */
185 if (Index(current
)-1 < 0) {
186 current
= IthItem(m
, Nitems(m
)-1);
188 current
= IthItem(m
, Index(current
)-1);
193 case REQ_PREV_ITEM
: {
194 if (Index(current
)-1 < 0) {
196 current
= IthItem(m
, Nitems(m
)-1);
198 ret
= E_REQUEST_DENIED
;
201 current
= IthItem(m
, Index(current
)-1);
205 case REQ_TOGGLE_ITEM
: {
207 if (Selectable(Current(m
))) {
208 Value(Current(m
)) ^= TRUE
;
209 _move_post_item(m
, Current(m
));
212 ret
= E_NOT_SELECTABLE
;
215 ret
= E_REQUEST_DENIED
;
219 case REQ_BACK_PATTERN
: {
222 IthPattern(m
, Pindex(m
)) = '\0';
225 ret
= E_REQUEST_DENIED
;
229 case REQ_CLEAR_PATTERN
: {
230 /* This was already done at the top */
234 ret
= E_UNKNOWN_COMMAND
;
238 if (c
> 037 && c
< 0177) {
239 /*LINTED [E_PASS_INT_TO_SMALL_INT]*/
240 ret
= _match(m
, c
, ¤t
);
242 ret
= E_UNKNOWN_COMMAND
;
246 /* Verify the location of the top row */
248 _chk_top(m
, &top
, current
);
250 /* Go change the actual values of Top and Current and do init/term */
252 _affect_change(m
, top
, current
);