1 | /**************************************************************************** |
2 | * Copyright 2020 Thomas E. Dickey * |
3 | * Copyright 1998-2016,2017 Free Software Foundation, Inc. * |
4 | * * |
5 | * Permission is hereby granted, free of charge, to any person obtaining a * |
6 | * copy of this software and associated documentation files (the * |
7 | * "Software"), to deal in the Software without restriction, including * |
8 | * without limitation the rights to use, copy, modify, merge, publish, * |
9 | * distribute, distribute with modifications, sublicense, and/or sell * |
10 | * copies of the Software, and to permit persons to whom the Software is * |
11 | * furnished to do so, subject to the following conditions: * |
12 | * * |
13 | * The above copyright notice and this permission notice shall be included * |
14 | * in all copies or substantial portions of the Software. * |
15 | * * |
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * |
17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * |
18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * |
19 | * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * |
20 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * |
21 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * |
22 | * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * |
23 | * * |
24 | * Except as contained in this notice, the name(s) of the above copyright * |
25 | * holders shall not be used in advertising or otherwise to promote the * |
26 | * sale, use or other dealings in this Software without prior written * |
27 | * authorization. * |
28 | ****************************************************************************/ |
29 | |
30 | /**************************************************************************** |
31 | * Author: Juergen Pfeifer, 1995,1997 * |
32 | ****************************************************************************/ |
33 | |
34 | /* $Id: menu.h,v 1.26 2020/12/12 00:38:02 tom Exp $ */ |
35 | |
36 | #ifndef ETI_MENU |
37 | #define |
38 | |
39 | #ifdef AMIGA |
40 | #define TEXT TEXT_ncurses |
41 | #endif |
42 | |
43 | #include <curses.h> |
44 | #include <eti.h> |
45 | |
46 | #ifdef __cplusplus |
47 | extern "C" |
48 | { |
49 | #endif |
50 | |
51 | #if defined(BUILDING_MENU) |
52 | # define MENU_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT |
53 | #else |
54 | # define NCURSES_EXPORT_GENERAL_IMPORT |
55 | #endif |
56 | |
57 | #define (type,name) extern MENU_IMPEXP type NCURSES_PUBLIC_VAR(name)(void) |
58 | |
59 | #define (type) MENU_IMPEXP type NCURSES_API |
60 | #define (type) MENU_IMPEXP type |
61 | |
62 | typedef int ; |
63 | typedef int Item_Options; |
64 | |
65 | /* Menu options: */ |
66 | #define O_ONEVALUE (0x01) |
67 | #define O_SHOWDESC (0x02) |
68 | #define O_ROWMAJOR (0x04) |
69 | #define O_IGNORECASE (0x08) |
70 | #define O_SHOWMATCH (0x10) |
71 | #define O_NONCYCLIC (0x20) |
72 | #define (0x40) |
73 | |
74 | /* Item options: */ |
75 | #define O_SELECTABLE (0x01) |
76 | |
77 | #if !NCURSES_OPAQUE_MENU |
78 | typedef struct |
79 | { |
80 | const char *str; |
81 | unsigned short length; |
82 | } |
83 | TEXT; |
84 | #endif /* !NCURSES_OPAQUE_MENU */ |
85 | |
86 | struct tagMENU; |
87 | |
88 | typedef struct tagITEM |
89 | #if !NCURSES_OPAQUE_MENU |
90 | { |
91 | TEXT name; /* name of menu item */ |
92 | TEXT description; /* description of item, optional in display */ |
93 | struct tagMENU *; /* Pointer to parent menu */ |
94 | void *userptr; /* Pointer to user defined per item data */ |
95 | Item_Options opt; /* Item options */ |
96 | short index; /* Item number if connected to a menu */ |
97 | short y; /* y and x location of item in menu */ |
98 | short x; |
99 | bool value; /* Selection value */ |
100 | |
101 | struct tagITEM *left; /* neighbor items */ |
102 | struct tagITEM *right; |
103 | struct tagITEM *up; |
104 | struct tagITEM *down; |
105 | |
106 | } |
107 | #endif /* !NCURSES_OPAQUE_MENU */ |
108 | ITEM; |
109 | |
110 | typedef void (*) (struct tagMENU *); |
111 | |
112 | typedef struct |
113 | #if 1 /* not yet: !NCURSES_OPAQUE_MENU */ |
114 | { |
115 | short ; /* Nr. of chars high */ |
116 | short ; /* Nr. of chars wide */ |
117 | short ; /* Nr. of items high */ |
118 | short ; /* Nr. of items wide */ |
119 | short ; /* Nr. of formatted items high */ |
120 | short ; /* Nr. of formatted items wide */ |
121 | short ; /* Nr. of items high (actual) */ |
122 | short ; /* Max. name length */ |
123 | short ; /* Max. description length */ |
124 | short ; /* Length of mark, if any */ |
125 | short ; /* Length of one item */ |
126 | short ; /* Spacing for descriptor */ |
127 | short ; /* Spacing for columns */ |
128 | short ; /* Spacing for rows */ |
129 | char *; /* Buffer to store match chars */ |
130 | short ; /* Index into pattern buffer */ |
131 | WINDOW *; /* Window containing menu */ |
132 | WINDOW *; /* Subwindow for menu display */ |
133 | WINDOW *; /* User's window */ |
134 | WINDOW *; /* User's subwindow */ |
135 | ITEM **; /* array of items */ |
136 | short ; /* Nr. of items in menu */ |
137 | ITEM *; /* Current item */ |
138 | short ; /* Top row of menu */ |
139 | chtype ; /* Selection attribute */ |
140 | chtype ; /* Nonselection attribute */ |
141 | chtype ; /* Inactive attribute */ |
142 | unsigned char ; /* Pad character */ |
143 | |
144 | Menu_Hook ; /* User hooks */ |
145 | Menu_Hook ; |
146 | Menu_Hook ; |
147 | Menu_Hook ; |
148 | |
149 | void *; /* Pointer to menus user data */ |
150 | char *; /* Pointer to marker string */ |
151 | |
152 | Menu_Options ; /* Menu options */ |
153 | unsigned short ; /* Internal state of menu */ |
154 | } |
155 | #endif /* !NCURSES_OPAQUE_MENU */ |
156 | ; |
157 | |
158 | /* Define keys */ |
159 | |
160 | #define REQ_LEFT_ITEM (KEY_MAX + 1) |
161 | #define REQ_RIGHT_ITEM (KEY_MAX + 2) |
162 | #define REQ_UP_ITEM (KEY_MAX + 3) |
163 | #define REQ_DOWN_ITEM (KEY_MAX + 4) |
164 | #define REQ_SCR_ULINE (KEY_MAX + 5) |
165 | #define REQ_SCR_DLINE (KEY_MAX + 6) |
166 | #define REQ_SCR_DPAGE (KEY_MAX + 7) |
167 | #define REQ_SCR_UPAGE (KEY_MAX + 8) |
168 | #define REQ_FIRST_ITEM (KEY_MAX + 9) |
169 | #define REQ_LAST_ITEM (KEY_MAX + 10) |
170 | #define REQ_NEXT_ITEM (KEY_MAX + 11) |
171 | #define REQ_PREV_ITEM (KEY_MAX + 12) |
172 | #define REQ_TOGGLE_ITEM (KEY_MAX + 13) |
173 | #define REQ_CLEAR_PATTERN (KEY_MAX + 14) |
174 | #define REQ_BACK_PATTERN (KEY_MAX + 15) |
175 | #define REQ_NEXT_MATCH (KEY_MAX + 16) |
176 | #define REQ_PREV_MATCH (KEY_MAX + 17) |
177 | |
178 | #define MIN_MENU_COMMAND (KEY_MAX + 1) |
179 | #define MAX_MENU_COMMAND (KEY_MAX + 17) |
180 | |
181 | /* |
182 | * Some AT&T code expects MAX_COMMAND to be out-of-band not |
183 | * just for menu commands but for forms ones as well. |
184 | */ |
185 | #if defined(MAX_COMMAND) |
186 | # if (MAX_MENU_COMMAND > MAX_COMMAND) |
187 | # error Something is wrong -- MAX_MENU_COMMAND is greater than MAX_COMMAND |
188 | # elif (MAX_COMMAND != (KEY_MAX + 128)) |
189 | # error Something is wrong -- MAX_COMMAND is already inconsistently defined. |
190 | # endif |
191 | #else |
192 | # define MAX_COMMAND (KEY_MAX + 128) |
193 | #endif |
194 | |
195 | /* --------- prototypes for libmenu functions ----------------------------- */ |
196 | |
197 | extern MENU_EXPORT(ITEM **) (const MENU *); |
198 | extern MENU_EXPORT(ITEM *) current_item(const MENU *); |
199 | extern MENU_EXPORT(ITEM *) new_item(const char *, const char *); |
200 | |
201 | extern MENU_EXPORT(MENU *) (ITEM **); |
202 | |
203 | extern MENU_EXPORT(Item_Options) item_opts(const ITEM *); |
204 | extern MENU_EXPORT(Menu_Options) (const MENU *); |
205 | |
206 | extern MENU_EXPORT(Menu_Hook) item_init(const MENU *); |
207 | extern MENU_EXPORT(Menu_Hook) item_term(const MENU *); |
208 | extern MENU_EXPORT(Menu_Hook) (const MENU *); |
209 | extern MENU_EXPORT(Menu_Hook) (const MENU *); |
210 | |
211 | extern MENU_EXPORT(WINDOW *) (const MENU *); |
212 | extern MENU_EXPORT(WINDOW *) (const MENU *); |
213 | |
214 | extern MENU_EXPORT(const char *) item_description(const ITEM *); |
215 | extern MENU_EXPORT(const char *) item_name(const ITEM *); |
216 | extern MENU_EXPORT(const char *) (const MENU *); |
217 | extern MENU_EXPORT(const char *) (int); |
218 | |
219 | extern MENU_EXPORT(char *) (const MENU *); |
220 | |
221 | extern MENU_EXPORT(void *) (const MENU *); |
222 | extern MENU_EXPORT(void *) item_userptr(const ITEM *); |
223 | |
224 | extern MENU_EXPORT(chtype) (const MENU *); |
225 | extern MENU_EXPORT(chtype) (const MENU *); |
226 | extern MENU_EXPORT(chtype) (const MENU *); |
227 | |
228 | extern MENU_EXPORT(int) free_item(ITEM *); |
229 | extern MENU_EXPORT(int) (MENU *); |
230 | extern MENU_EXPORT(int) item_count(const MENU *); |
231 | extern MENU_EXPORT(int) item_index(const ITEM *); |
232 | extern MENU_EXPORT(int) item_opts_off(ITEM *, Item_Options); |
233 | extern MENU_EXPORT(int) item_opts_on(ITEM *, Item_Options); |
234 | extern MENU_EXPORT(int) (MENU *, int); |
235 | extern MENU_EXPORT(int) (MENU *, Menu_Options); |
236 | extern MENU_EXPORT(int) (MENU *, Menu_Options); |
237 | extern MENU_EXPORT(int) (const MENU *); |
238 | extern MENU_EXPORT(int) (const MENU *); |
239 | extern MENU_EXPORT(int) (MENU *); |
240 | extern MENU_EXPORT(int) (const MENU *, int *, int *); |
241 | extern MENU_EXPORT(int) set_current_item(MENU *, ITEM *item); |
242 | extern MENU_EXPORT(int) set_item_init(MENU *, Menu_Hook); |
243 | extern MENU_EXPORT(int) set_item_opts(ITEM *, Item_Options); |
244 | extern MENU_EXPORT(int) set_item_term(MENU *, Menu_Hook); |
245 | extern MENU_EXPORT(int) set_item_userptr(ITEM *, void *); |
246 | extern MENU_EXPORT(int) set_item_value(ITEM *, bool); |
247 | extern MENU_EXPORT(int) (MENU *, chtype); |
248 | extern MENU_EXPORT(int) (MENU *, chtype); |
249 | extern MENU_EXPORT(int) (MENU *, int, int); |
250 | extern MENU_EXPORT(int) (MENU *, chtype); |
251 | extern MENU_EXPORT(int) (MENU *, Menu_Hook); |
252 | extern MENU_EXPORT(int) (MENU *, ITEM **); |
253 | extern MENU_EXPORT(int) (MENU *, const char *); |
254 | extern MENU_EXPORT(int) (MENU *, Menu_Options); |
255 | extern MENU_EXPORT(int) (MENU *, int); |
256 | extern MENU_EXPORT(int) (MENU *, const char *); |
257 | extern MENU_EXPORT(int) (MENU *, WINDOW *); |
258 | extern MENU_EXPORT(int) (MENU *, Menu_Hook); |
259 | extern MENU_EXPORT(int) (MENU *, void *); |
260 | extern MENU_EXPORT(int) (MENU *, WINDOW *); |
261 | extern MENU_EXPORT(int) set_top_row(MENU *, int); |
262 | extern MENU_EXPORT(int) top_row(const MENU *); |
263 | extern MENU_EXPORT(int) (MENU *); |
264 | extern MENU_EXPORT(int) (const char *); |
265 | extern MENU_EXPORT(int) (MENU *, int, int, int); |
266 | extern MENU_EXPORT(int) (const MENU *, int *, int *, int *); |
267 | |
268 | extern MENU_EXPORT(bool) item_value(const ITEM *); |
269 | extern MENU_EXPORT(bool) item_visible(const ITEM *); |
270 | |
271 | extern MENU_EXPORT(void) (const MENU *, int *, int *); |
272 | |
273 | #if NCURSES_SP_FUNCS |
274 | extern MENU_EXPORT(MENU *) NCURSES_SP_NAME(new_menu) (SCREEN *, ITEM **); |
275 | #endif |
276 | |
277 | #ifdef __cplusplus |
278 | } |
279 | #endif |
280 | |
281 | #endif /* ETI_MENU */ |
282 | |