xref: /illumos-gate/usr/src/lib/libeti/menu/inc/menu.h (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
23*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
24*7c478bd9Sstevel@tonic-gate 
25*7c478bd9Sstevel@tonic-gate 
26*7c478bd9Sstevel@tonic-gate /*
27*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1997, by Sun Microsystems, Inc.
28*7c478bd9Sstevel@tonic-gate  * All rights reserved.
29*7c478bd9Sstevel@tonic-gate  */
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate #ifndef	_MENU_H
32*7c478bd9Sstevel@tonic-gate #define	_MENU_H
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.15	*/
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #include <curses.h>
37*7c478bd9Sstevel@tonic-gate #include <eti.h>
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
40*7c478bd9Sstevel@tonic-gate extern "C" {
41*7c478bd9Sstevel@tonic-gate #endif
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate /* Menu options: */
44*7c478bd9Sstevel@tonic-gate #define	O_ONEVALUE	0x01
45*7c478bd9Sstevel@tonic-gate #define	O_SHOWDESC	0x02
46*7c478bd9Sstevel@tonic-gate #define	O_ROWMAJOR	0x04
47*7c478bd9Sstevel@tonic-gate #define	O_IGNORECASE	0x08
48*7c478bd9Sstevel@tonic-gate #define	O_SHOWMATCH	0x10
49*7c478bd9Sstevel@tonic-gate #define	O_NONCYCLIC	0x20
50*7c478bd9Sstevel@tonic-gate 
51*7c478bd9Sstevel@tonic-gate /* Item options: */
52*7c478bd9Sstevel@tonic-gate #define	O_SELECTABLE	0x01
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate typedef struct {
55*7c478bd9Sstevel@tonic-gate 	char	*str;
56*7c478bd9Sstevel@tonic-gate 	int	length;
57*7c478bd9Sstevel@tonic-gate } TEXT;
58*7c478bd9Sstevel@tonic-gate 
59*7c478bd9Sstevel@tonic-gate typedef struct ITEM {
60*7c478bd9Sstevel@tonic-gate 	TEXT		name;
61*7c478bd9Sstevel@tonic-gate 	TEXT		description;
62*7c478bd9Sstevel@tonic-gate 	int		index;		/* Item number */
63*7c478bd9Sstevel@tonic-gate 	struct MENU	*imenu;		/* Pointer to parent menu */
64*7c478bd9Sstevel@tonic-gate 	int		 value;
65*7c478bd9Sstevel@tonic-gate 	char		*userptr;
66*7c478bd9Sstevel@tonic-gate 	OPTIONS		 opt;
67*7c478bd9Sstevel@tonic-gate 	int		 status;
68*7c478bd9Sstevel@tonic-gate 	short		 y;		/* y and x location of item in menu */
69*7c478bd9Sstevel@tonic-gate 	short		 x;
70*7c478bd9Sstevel@tonic-gate 	struct ITEM	 *left;
71*7c478bd9Sstevel@tonic-gate 	struct ITEM	 *right;
72*7c478bd9Sstevel@tonic-gate 	struct ITEM	 *up;
73*7c478bd9Sstevel@tonic-gate 	struct ITEM	 *down;
74*7c478bd9Sstevel@tonic-gate } ITEM;
75*7c478bd9Sstevel@tonic-gate 
76*7c478bd9Sstevel@tonic-gate #define	_POSTED		0x1
77*7c478bd9Sstevel@tonic-gate #define	_IN_DRIVER	0x2
78*7c478bd9Sstevel@tonic-gate #define	_LINK_NEEDED	0x4
79*7c478bd9Sstevel@tonic-gate 
80*7c478bd9Sstevel@tonic-gate typedef struct MENU {
81*7c478bd9Sstevel@tonic-gate 	int		height;		/* Number of chars high */
82*7c478bd9Sstevel@tonic-gate 	int		width;		/* Number of chars wide */
83*7c478bd9Sstevel@tonic-gate 	int		rows;		/* Number of items high */
84*7c478bd9Sstevel@tonic-gate 	int		cols;		/* Number of items wide */
85*7c478bd9Sstevel@tonic-gate 	int		frows;		/* Number of formated items high */
86*7c478bd9Sstevel@tonic-gate 	int		fcols;		/* Number of formated items wide */
87*7c478bd9Sstevel@tonic-gate 	int		namelen;	/* Length of widest name */
88*7c478bd9Sstevel@tonic-gate 	int		desclen;	/* Length of widest description */
89*7c478bd9Sstevel@tonic-gate 	int		marklen;	/* Length of mark */
90*7c478bd9Sstevel@tonic-gate 	int		itemlen;	/* Length of an one item */
91*7c478bd9Sstevel@tonic-gate 	char		*pattern;	/* Buffer used to store match chars */
92*7c478bd9Sstevel@tonic-gate 	int		pindex;		/* Index into pattern buffer */
93*7c478bd9Sstevel@tonic-gate 	WINDOW		*win;		/* Window containing entire menu */
94*7c478bd9Sstevel@tonic-gate 	WINDOW		*sub;		/* Portion of menu displayed */
95*7c478bd9Sstevel@tonic-gate 	WINDOW		*userwin;	/* User's window */
96*7c478bd9Sstevel@tonic-gate 	WINDOW		*usersub;	/* User's subwindow */
97*7c478bd9Sstevel@tonic-gate 	ITEM		**items;
98*7c478bd9Sstevel@tonic-gate 	int 		nitems;		/* Total number of items in menu */
99*7c478bd9Sstevel@tonic-gate 	ITEM		*curitem;	/* Current item */
100*7c478bd9Sstevel@tonic-gate 	int		toprow;		/* Top row of menu */
101*7c478bd9Sstevel@tonic-gate 	int		pad;		/* Pad character */
102*7c478bd9Sstevel@tonic-gate 	chtype		fore;		/* Attribute for selection */
103*7c478bd9Sstevel@tonic-gate 	chtype		back;		/* Attribute for nonselection */
104*7c478bd9Sstevel@tonic-gate 	chtype		grey;		/* Attribute for inactive */
105*7c478bd9Sstevel@tonic-gate 	PTF_void	menuinit;
106*7c478bd9Sstevel@tonic-gate 	PTF_void	menuterm;
107*7c478bd9Sstevel@tonic-gate 	PTF_void	iteminit;
108*7c478bd9Sstevel@tonic-gate 	PTF_void	itemterm;
109*7c478bd9Sstevel@tonic-gate 	char		*userptr;
110*7c478bd9Sstevel@tonic-gate 	char		*mark;
111*7c478bd9Sstevel@tonic-gate 	OPTIONS		opt;
112*7c478bd9Sstevel@tonic-gate 	int		status;
113*7c478bd9Sstevel@tonic-gate } MENU;
114*7c478bd9Sstevel@tonic-gate 
115*7c478bd9Sstevel@tonic-gate /* Define keys */
116*7c478bd9Sstevel@tonic-gate 
117*7c478bd9Sstevel@tonic-gate #define	REQ_LEFT_ITEM		KEY_MAX+1
118*7c478bd9Sstevel@tonic-gate #define	REQ_RIGHT_ITEM		KEY_MAX+2
119*7c478bd9Sstevel@tonic-gate #define	REQ_UP_ITEM		KEY_MAX+3
120*7c478bd9Sstevel@tonic-gate #define	REQ_DOWN_ITEM		KEY_MAX+4
121*7c478bd9Sstevel@tonic-gate #define	REQ_SCR_ULINE		KEY_MAX+5
122*7c478bd9Sstevel@tonic-gate #define	REQ_SCR_DLINE		KEY_MAX+6
123*7c478bd9Sstevel@tonic-gate #define	REQ_SCR_DPAGE		KEY_MAX+7
124*7c478bd9Sstevel@tonic-gate #define	REQ_SCR_UPAGE		KEY_MAX+8
125*7c478bd9Sstevel@tonic-gate #define	REQ_FIRST_ITEM		KEY_MAX+9
126*7c478bd9Sstevel@tonic-gate #define	REQ_LAST_ITEM		KEY_MAX+10
127*7c478bd9Sstevel@tonic-gate #define	REQ_NEXT_ITEM		KEY_MAX+11
128*7c478bd9Sstevel@tonic-gate #define	REQ_PREV_ITEM		KEY_MAX+12
129*7c478bd9Sstevel@tonic-gate #define	REQ_TOGGLE_ITEM		KEY_MAX+13
130*7c478bd9Sstevel@tonic-gate #define	REQ_CLEAR_PATTERN	KEY_MAX+14
131*7c478bd9Sstevel@tonic-gate #define	REQ_BACK_PATTERN	KEY_MAX+15
132*7c478bd9Sstevel@tonic-gate #define	REQ_NEXT_MATCH		KEY_MAX+16
133*7c478bd9Sstevel@tonic-gate #define	REQ_PREV_MATCH		KEY_MAX+17
134*7c478bd9Sstevel@tonic-gate 
135*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
136*7c478bd9Sstevel@tonic-gate 
137*7c478bd9Sstevel@tonic-gate extern ITEM	**menu_items(MENU *),
138*7c478bd9Sstevel@tonic-gate 		*current_item(MENU *),
139*7c478bd9Sstevel@tonic-gate 		*new_item(char *, char *);
140*7c478bd9Sstevel@tonic-gate extern MENU	*new_menu(ITEM **);
141*7c478bd9Sstevel@tonic-gate extern OPTIONS	item_opts(ITEM *),
142*7c478bd9Sstevel@tonic-gate 		menu_opts(MENU *);
143*7c478bd9Sstevel@tonic-gate extern PTF_void	item_init(MENU *),
144*7c478bd9Sstevel@tonic-gate 		item_term(MENU *),
145*7c478bd9Sstevel@tonic-gate 		menu_init(MENU *),
146*7c478bd9Sstevel@tonic-gate 		menu_term(MENU *);
147*7c478bd9Sstevel@tonic-gate extern WINDOW	*menu_sub(MENU *),
148*7c478bd9Sstevel@tonic-gate 		*menu_win(MENU *);
149*7c478bd9Sstevel@tonic-gate extern char	*item_description(ITEM *),
150*7c478bd9Sstevel@tonic-gate 		*item_name(ITEM *),
151*7c478bd9Sstevel@tonic-gate 		*item_userptr(ITEM *),
152*7c478bd9Sstevel@tonic-gate 		*menu_mark(MENU *),
153*7c478bd9Sstevel@tonic-gate 		*menu_pattern(MENU *),
154*7c478bd9Sstevel@tonic-gate 		*menu_userptr(MENU *);
155*7c478bd9Sstevel@tonic-gate extern chtype	menu_back(MENU *),
156*7c478bd9Sstevel@tonic-gate 		menu_fore(MENU *),
157*7c478bd9Sstevel@tonic-gate 		menu_grey(MENU *);
158*7c478bd9Sstevel@tonic-gate extern int	free_item(ITEM *),
159*7c478bd9Sstevel@tonic-gate 		free_menu(MENU *),
160*7c478bd9Sstevel@tonic-gate 		item_count(MENU *),
161*7c478bd9Sstevel@tonic-gate 		item_index(ITEM *),
162*7c478bd9Sstevel@tonic-gate 		item_opts_off(ITEM *, OPTIONS),
163*7c478bd9Sstevel@tonic-gate 		item_opts_on(ITEM *, OPTIONS),
164*7c478bd9Sstevel@tonic-gate 		item_value(ITEM *),
165*7c478bd9Sstevel@tonic-gate 		item_visible(ITEM *),
166*7c478bd9Sstevel@tonic-gate 		menu_driver(MENU *, int),
167*7c478bd9Sstevel@tonic-gate 		menu_opts_off(MENU *, OPTIONS),
168*7c478bd9Sstevel@tonic-gate 		menu_opts_on(MENU *, OPTIONS),
169*7c478bd9Sstevel@tonic-gate 		menu_pad(MENU *),
170*7c478bd9Sstevel@tonic-gate 		pos_menu_cursor(MENU *),
171*7c478bd9Sstevel@tonic-gate 		post_menu(MENU *),
172*7c478bd9Sstevel@tonic-gate 		scale_menu(MENU *, int *, int *),
173*7c478bd9Sstevel@tonic-gate 		set_current_item(MENU *, ITEM *),
174*7c478bd9Sstevel@tonic-gate 		set_item_init(MENU *, PTF_void),
175*7c478bd9Sstevel@tonic-gate 		set_item_opts(ITEM *, OPTIONS),
176*7c478bd9Sstevel@tonic-gate 		set_item_term(MENU *, PTF_void),
177*7c478bd9Sstevel@tonic-gate 		set_item_userptr(ITEM *, char *),
178*7c478bd9Sstevel@tonic-gate 		set_item_value(ITEM *, int),
179*7c478bd9Sstevel@tonic-gate 		set_menu_back(MENU *, chtype),
180*7c478bd9Sstevel@tonic-gate 		set_menu_fore(MENU *, chtype),
181*7c478bd9Sstevel@tonic-gate 		set_menu_format(MENU *, int, int),
182*7c478bd9Sstevel@tonic-gate 		set_menu_grey(MENU *, chtype),
183*7c478bd9Sstevel@tonic-gate 		set_menu_init(MENU *, PTF_void),
184*7c478bd9Sstevel@tonic-gate 		set_menu_items(MENU *, ITEM **),
185*7c478bd9Sstevel@tonic-gate 		set_menu_mark(MENU *, char *),
186*7c478bd9Sstevel@tonic-gate 		set_menu_opts(MENU *, OPTIONS),
187*7c478bd9Sstevel@tonic-gate 		set_menu_pad(MENU *, int),
188*7c478bd9Sstevel@tonic-gate 		set_menu_pattern(MENU *, char *),
189*7c478bd9Sstevel@tonic-gate 		set_menu_sub(MENU *, WINDOW *),
190*7c478bd9Sstevel@tonic-gate 		set_menu_term(MENU *, PTF_void),
191*7c478bd9Sstevel@tonic-gate 		set_menu_userptr(MENU *, char *),
192*7c478bd9Sstevel@tonic-gate 		set_menu_win(MENU *, WINDOW *),
193*7c478bd9Sstevel@tonic-gate 		set_top_row(MENU *, int),
194*7c478bd9Sstevel@tonic-gate 		top_row(MENU *),
195*7c478bd9Sstevel@tonic-gate 		unpost_menu(MENU *);
196*7c478bd9Sstevel@tonic-gate void		menu_format(MENU *, int *, int *);
197*7c478bd9Sstevel@tonic-gate 
198*7c478bd9Sstevel@tonic-gate #else	/* old style extern's */
199*7c478bd9Sstevel@tonic-gate 
200*7c478bd9Sstevel@tonic-gate extern ITEM	**menu_items(),
201*7c478bd9Sstevel@tonic-gate 		*current_item(),
202*7c478bd9Sstevel@tonic-gate 		*new_item();
203*7c478bd9Sstevel@tonic-gate extern MENU	*new_menu();
204*7c478bd9Sstevel@tonic-gate extern OPTIONS	item_opts(),
205*7c478bd9Sstevel@tonic-gate 		menu_opts();
206*7c478bd9Sstevel@tonic-gate extern PTF_void	item_init(),
207*7c478bd9Sstevel@tonic-gate 		item_term(),
208*7c478bd9Sstevel@tonic-gate 		menu_init(),
209*7c478bd9Sstevel@tonic-gate 		menu_term();
210*7c478bd9Sstevel@tonic-gate extern WINDOW	*menu_sub(),
211*7c478bd9Sstevel@tonic-gate 		*menu_win();
212*7c478bd9Sstevel@tonic-gate extern char	*item_description(),
213*7c478bd9Sstevel@tonic-gate 		*item_name(),
214*7c478bd9Sstevel@tonic-gate 		*item_userptr(),
215*7c478bd9Sstevel@tonic-gate 		*menu_mark(),
216*7c478bd9Sstevel@tonic-gate 		*menu_pattern(),
217*7c478bd9Sstevel@tonic-gate 		*menu_userptr();
218*7c478bd9Sstevel@tonic-gate extern chtype	menu_back(),
219*7c478bd9Sstevel@tonic-gate 		menu_fore(),
220*7c478bd9Sstevel@tonic-gate 		menu_grey();
221*7c478bd9Sstevel@tonic-gate extern int	free_item(),
222*7c478bd9Sstevel@tonic-gate 		free_menu(),
223*7c478bd9Sstevel@tonic-gate 		item_count(),
224*7c478bd9Sstevel@tonic-gate 		item_index(),
225*7c478bd9Sstevel@tonic-gate 		item_opts_off(),
226*7c478bd9Sstevel@tonic-gate 		item_opts_on(),
227*7c478bd9Sstevel@tonic-gate 		item_value(),
228*7c478bd9Sstevel@tonic-gate 		item_visible(),
229*7c478bd9Sstevel@tonic-gate 		menu_driver(),
230*7c478bd9Sstevel@tonic-gate 		menu_opts_off(),
231*7c478bd9Sstevel@tonic-gate 		menu_opts_on(),
232*7c478bd9Sstevel@tonic-gate 		menu_pad(),
233*7c478bd9Sstevel@tonic-gate 		pos_menu_cursor(),
234*7c478bd9Sstevel@tonic-gate 		post_menu(),
235*7c478bd9Sstevel@tonic-gate 		scale_menu(),
236*7c478bd9Sstevel@tonic-gate 		set_current_item(),
237*7c478bd9Sstevel@tonic-gate 		set_item_init(),
238*7c478bd9Sstevel@tonic-gate 		set_item_opts(),
239*7c478bd9Sstevel@tonic-gate 		set_item_term(),
240*7c478bd9Sstevel@tonic-gate 		set_item_userptr(),
241*7c478bd9Sstevel@tonic-gate 		set_item_value(),
242*7c478bd9Sstevel@tonic-gate 		set_menu_back(),
243*7c478bd9Sstevel@tonic-gate 		set_menu_fore(),
244*7c478bd9Sstevel@tonic-gate 		set_menu_format(),
245*7c478bd9Sstevel@tonic-gate 		set_menu_grey(),
246*7c478bd9Sstevel@tonic-gate 		set_menu_init(),
247*7c478bd9Sstevel@tonic-gate 		set_menu_items(),
248*7c478bd9Sstevel@tonic-gate 		set_menu_mark(),
249*7c478bd9Sstevel@tonic-gate 		set_menu_opts(),
250*7c478bd9Sstevel@tonic-gate 		set_menu_pad(),
251*7c478bd9Sstevel@tonic-gate 		set_menu_pattern(),
252*7c478bd9Sstevel@tonic-gate 		set_menu_sub(),
253*7c478bd9Sstevel@tonic-gate 		set_menu_term(),
254*7c478bd9Sstevel@tonic-gate 		set_menu_userptr(),
255*7c478bd9Sstevel@tonic-gate 		set_menu_win(),
256*7c478bd9Sstevel@tonic-gate 		set_top_row(),
257*7c478bd9Sstevel@tonic-gate 		top_row(),
258*7c478bd9Sstevel@tonic-gate 		unpost_menu();
259*7c478bd9Sstevel@tonic-gate void		menu_format();
260*7c478bd9Sstevel@tonic-gate 
261*7c478bd9Sstevel@tonic-gate #endif	/* __STDC__ */
262*7c478bd9Sstevel@tonic-gate 
263*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
264*7c478bd9Sstevel@tonic-gate }
265*7c478bd9Sstevel@tonic-gate #endif
266*7c478bd9Sstevel@tonic-gate 
267*7c478bd9Sstevel@tonic-gate #endif	/* _MENU_H */
268