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