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