summaryrefslogtreecommitdiff
path: root/usr/src/lib/libeti/menu/inc/menu.h
blob: ee70d18db83a010b5668cbdf73a74fd51a95af63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved  	*/


/*
 * Copyright (c) 1997, by Sun Microsystems, Inc.
 * All rights reserved.
 */

#ifndef	_MENU_H
#define	_MENU_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.15	*/

#include <curses.h>
#include <eti.h>

#ifdef	__cplusplus
extern "C" {
#endif

/* Menu options: */
#define	O_ONEVALUE	0x01
#define	O_SHOWDESC	0x02
#define	O_ROWMAJOR	0x04
#define	O_IGNORECASE	0x08
#define	O_SHOWMATCH	0x10
#define	O_NONCYCLIC	0x20

/* Item options: */
#define	O_SELECTABLE	0x01

typedef struct {
	char	*str;
	int	length;
} TEXT;

typedef struct ITEM {
	TEXT		name;
	TEXT		description;
	int		index;		/* Item number */
	struct MENU	*imenu;		/* Pointer to parent menu */
	int		 value;
	char		*userptr;
	OPTIONS		 opt;
	int		 status;
	short		 y;		/* y and x location of item in menu */
	short		 x;
	struct ITEM	 *left;
	struct ITEM	 *right;
	struct ITEM	 *up;
	struct ITEM	 *down;
} ITEM;

#define	_POSTED		0x1
#define	_IN_DRIVER	0x2
#define	_LINK_NEEDED	0x4

typedef struct MENU {
	int		height;		/* Number of chars high */
	int		width;		/* Number of chars wide */
	int		rows;		/* Number of items high */
	int		cols;		/* Number of items wide */
	int		frows;		/* Number of formated items high */
	int		fcols;		/* Number of formated items wide */
	int		namelen;	/* Length of widest name */
	int		desclen;	/* Length of widest description */
	int		marklen;	/* Length of mark */
	int		itemlen;	/* Length of an one item */
	char		*pattern;	/* Buffer used to store match chars */
	int		pindex;		/* Index into pattern buffer */
	WINDOW		*win;		/* Window containing entire menu */
	WINDOW		*sub;		/* Portion of menu displayed */
	WINDOW		*userwin;	/* User's window */
	WINDOW		*usersub;	/* User's subwindow */
	ITEM		**items;
	int 		nitems;		/* Total number of items in menu */
	ITEM		*curitem;	/* Current item */
	int		toprow;		/* Top row of menu */
	int		pad;		/* Pad character */
	chtype		fore;		/* Attribute for selection */
	chtype		back;		/* Attribute for nonselection */
	chtype		grey;		/* Attribute for inactive */
	PTF_void	menuinit;
	PTF_void	menuterm;
	PTF_void	iteminit;
	PTF_void	itemterm;
	char		*userptr;
	char		*mark;
	OPTIONS		opt;
	int		status;
} MENU;

/* Define keys */

#define	REQ_LEFT_ITEM		KEY_MAX+1
#define	REQ_RIGHT_ITEM		KEY_MAX+2
#define	REQ_UP_ITEM		KEY_MAX+3
#define	REQ_DOWN_ITEM		KEY_MAX+4
#define	REQ_SCR_ULINE		KEY_MAX+5
#define	REQ_SCR_DLINE		KEY_MAX+6
#define	REQ_SCR_DPAGE		KEY_MAX+7
#define	REQ_SCR_UPAGE		KEY_MAX+8
#define	REQ_FIRST_ITEM		KEY_MAX+9
#define	REQ_LAST_ITEM		KEY_MAX+10
#define	REQ_NEXT_ITEM		KEY_MAX+11
#define	REQ_PREV_ITEM		KEY_MAX+12
#define	REQ_TOGGLE_ITEM		KEY_MAX+13
#define	REQ_CLEAR_PATTERN	KEY_MAX+14
#define	REQ_BACK_PATTERN	KEY_MAX+15
#define	REQ_NEXT_MATCH		KEY_MAX+16
#define	REQ_PREV_MATCH		KEY_MAX+17

#ifdef __STDC__

extern ITEM	**menu_items(MENU *),
		*current_item(MENU *),
		*new_item(char *, char *);
extern MENU	*new_menu(ITEM **);
extern OPTIONS	item_opts(ITEM *),
		menu_opts(MENU *);
extern PTF_void	item_init(MENU *),
		item_term(MENU *),
		menu_init(MENU *),
		menu_term(MENU *);
extern WINDOW	*menu_sub(MENU *),
		*menu_win(MENU *);
extern char	*item_description(ITEM *),
		*item_name(ITEM *),
		*item_userptr(ITEM *),
		*menu_mark(MENU *),
		*menu_pattern(MENU *),
		*menu_userptr(MENU *);
extern chtype	menu_back(MENU *),
		menu_fore(MENU *),
		menu_grey(MENU *);
extern int	free_item(ITEM *),
		free_menu(MENU *),
		item_count(MENU *),
		item_index(ITEM *),
		item_opts_off(ITEM *, OPTIONS),
		item_opts_on(ITEM *, OPTIONS),
		item_value(ITEM *),
		item_visible(ITEM *),
		menu_driver(MENU *, int),
		menu_opts_off(MENU *, OPTIONS),
		menu_opts_on(MENU *, OPTIONS),
		menu_pad(MENU *),
		pos_menu_cursor(MENU *),
		post_menu(MENU *),
		scale_menu(MENU *, int *, int *),
		set_current_item(MENU *, ITEM *),
		set_item_init(MENU *, PTF_void),
		set_item_opts(ITEM *, OPTIONS),
		set_item_term(MENU *, PTF_void),
		set_item_userptr(ITEM *, char *),
		set_item_value(ITEM *, int),
		set_menu_back(MENU *, chtype),
		set_menu_fore(MENU *, chtype),
		set_menu_format(MENU *, int, int),
		set_menu_grey(MENU *, chtype),
		set_menu_init(MENU *, PTF_void),
		set_menu_items(MENU *, ITEM **),
		set_menu_mark(MENU *, char *),
		set_menu_opts(MENU *, OPTIONS),
		set_menu_pad(MENU *, int),
		set_menu_pattern(MENU *, char *),
		set_menu_sub(MENU *, WINDOW *),
		set_menu_term(MENU *, PTF_void),
		set_menu_userptr(MENU *, char *),
		set_menu_win(MENU *, WINDOW *),
		set_top_row(MENU *, int),
		top_row(MENU *),
		unpost_menu(MENU *);
void		menu_format(MENU *, int *, int *);

#else	/* old style extern's */

extern ITEM	**menu_items(),
		*current_item(),
		*new_item();
extern MENU	*new_menu();
extern OPTIONS	item_opts(),
		menu_opts();
extern PTF_void	item_init(),
		item_term(),
		menu_init(),
		menu_term();
extern WINDOW	*menu_sub(),
		*menu_win();
extern char	*item_description(),
		*item_name(),
		*item_userptr(),
		*menu_mark(),
		*menu_pattern(),
		*menu_userptr();
extern chtype	menu_back(),
		menu_fore(),
		menu_grey();
extern int	free_item(),
		free_menu(),
		item_count(),
		item_index(),
		item_opts_off(),
		item_opts_on(),
		item_value(),
		item_visible(),
		menu_driver(),
		menu_opts_off(),
		menu_opts_on(),
		menu_pad(),
		pos_menu_cursor(),
		post_menu(),
		scale_menu(),
		set_current_item(),
		set_item_init(),
		set_item_opts(),
		set_item_term(),
		set_item_userptr(),
		set_item_value(),
		set_menu_back(),
		set_menu_fore(),
		set_menu_format(),
		set_menu_grey(),
		set_menu_init(),
		set_menu_items(),
		set_menu_mark(),
		set_menu_opts(),
		set_menu_pad(),
		set_menu_pattern(),
		set_menu_sub(),
		set_menu_term(),
		set_menu_userptr(),
		set_menu_win(),
		set_top_row(),
		top_row(),
		unpost_menu();
void		menu_format();

#endif	/* __STDC__ */

#ifdef	__cplusplus
}
#endif

#endif	/* _MENU_H */