1 /*-----------------------------------------------------------------------------+
2 | The ncurses menu library is Copyright (C) 1995-1997 |
3 | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> |
4 | All Rights Reserved. |
6 | Permission to use, copy, modify, and distribute this software and its |
7 | documentation for any purpose and without fee is hereby granted, provided |
8 | that the above copyright notice appear in all copies and that both that |
9 | copyright notice and this permission notice appear in supporting |
10 | documentation, and that the name of the above listed copyright holder(s) not |
11 | be used in advertising or publicity pertaining to distribution of the |
12 | software without specific, written prior permission. |
14 | THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO |
15 | THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- |
16 | NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR |
17 | ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- |
18 | SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
19 | NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH |
20 | THE USE OR PERFORMANCE OF THIS SOFTWARE. |
21 +-----------------------------------------------------------------------------*/
33 typedef int Menu_Options;
34 typedef int Item_Options;
37 #define O_ONEVALUE (0x01)
38 #define O_SHOWDESC (0x02)
39 #define O_ROWMAJOR (0x04)
40 #define O_IGNORECASE (0x08)
41 #define O_SHOWMATCH (0x10)
42 #define O_NONCYCLIC (0x20)
45 #define O_SELECTABLE (0x01)
50 unsigned short length;
53 typedef struct tagITEM
55 TEXT name; /* name of menu item */
56 TEXT description; /* description of item, optional in display */
57 struct tagMENU *imenu; /* Pointer to parent menu */
58 const void *userptr; /* Pointer to user defined per item data */
59 Item_Options opt; /* Item options */
60 short index; /* Item number if connected to a menu */
61 short y; /* y and x location of item in menu */
63 bool value; /* Selection value */
65 struct tagITEM *left; /* neighbour items */
66 struct tagITEM *right;
72 typedef void (*Menu_Hook)(struct tagMENU *);
74 typedef struct tagMENU
76 short height; /* Nr. of chars high */
77 short width; /* Nr. of chars wide */
78 short rows; /* Nr. of items high */
79 short cols; /* Nr. of items wide */
80 short frows; /* Nr. of formatted items high */
81 short fcols; /* Nr. of formatted items wide */
82 short arows; /* Nr. of items high (actual) */
83 short namelen; /* Max. name length */
84 short desclen; /* Max. description length */
85 short marklen; /* Length of mark, if any */
86 short itemlen; /* Length of one item */
87 short spc_desc; /* Spacing for descriptor */
88 short spc_cols; /* Spacing for columns */
89 short spc_rows; /* Spacing for rows */
90 char *pattern; /* Buffer to store match chars */
91 short pindex; /* Index into pattern buffer */
92 WINDOW *win; /* Window containing menu */
93 WINDOW *sub; /* Subwindow for menu display */
94 WINDOW *userwin; /* User's window */
95 WINDOW *usersub; /* User's subwindow */
96 ITEM **items; /* array of items */
97 short nitems; /* Nr. of items in menu */
98 ITEM *curitem; /* Current item */
99 short toprow; /* Top row of menu */
100 chtype fore; /* Selection attribute */
101 chtype back; /* Nonselection attribute */
102 chtype grey; /* Inactive attribute */
103 unsigned char pad; /* Pad character */
105 Menu_Hook menuinit; /* User hooks */
110 const void *userptr; /* Pointer to menus user data */
111 char *mark; /* Pointer to marker string */
113 Menu_Options opt; /* Menu options */
114 unsigned short status; /* Internal state of menu */
121 #define REQ_LEFT_ITEM (KEY_MAX + 1)
122 #define REQ_RIGHT_ITEM (KEY_MAX + 2)
123 #define REQ_UP_ITEM (KEY_MAX + 3)
124 #define REQ_DOWN_ITEM (KEY_MAX + 4)
125 #define REQ_SCR_ULINE (KEY_MAX + 5)
126 #define REQ_SCR_DLINE (KEY_MAX + 6)
127 #define REQ_SCR_DPAGE (KEY_MAX + 7)
128 #define REQ_SCR_UPAGE (KEY_MAX + 8)
129 #define REQ_FIRST_ITEM (KEY_MAX + 9)
130 #define REQ_LAST_ITEM (KEY_MAX + 10)
131 #define REQ_NEXT_ITEM (KEY_MAX + 11)
132 #define REQ_PREV_ITEM (KEY_MAX + 12)
133 #define REQ_TOGGLE_ITEM (KEY_MAX + 13)
134 #define REQ_CLEAR_PATTERN (KEY_MAX + 14)
135 #define REQ_BACK_PATTERN (KEY_MAX + 15)
136 #define REQ_NEXT_MATCH (KEY_MAX + 16)
137 #define REQ_PREV_MATCH (KEY_MAX + 17)
139 #define MIN_MENU_COMMAND (KEY_MAX + 1)
140 #define MAX_MENU_COMMAND (KEY_MAX + 17)
143 * Some AT&T code expects MAX_COMMAND to be out-of-band not
144 * just for menu commands but for forms ones as well.
146 #if defined(MAX_COMMAND)
147 # if (MAX_MENU_COMMAND > MAX_COMMAND)
148 # error Something is wrong -- MAX_MENU_COMMAND is greater than MAX_COMMAND
149 # elif (MAX_COMMAND != (KEY_MAX + 128))
150 # error Something is wrong -- MAX_COMMAND is already inconsistently defined.
153 # define MAX_COMMAND (KEY_MAX + 128)
157 /* --------- prototypes for libmenu functions ----------------------------- */
159 extern ITEM **menu_items(const MENU *),
160 *current_item(const MENU *),
161 *new_item(const char *,const char *);
163 extern MENU *new_menu(ITEM **);
165 extern Item_Options item_opts(const ITEM *);
166 extern Menu_Options menu_opts(const MENU *);
168 Menu_Hook item_init(const MENU *),
169 item_term(const MENU *),
170 menu_init(const MENU *),
171 menu_term(const MENU *);
173 extern WINDOW *menu_sub(const MENU *),
174 *menu_win(const MENU *);
176 extern const char *item_description(const ITEM *),
177 *item_name(const ITEM *),
178 *menu_mark(const MENU *),
179 *menu_request_name(int);
181 extern char *menu_pattern(const MENU *);
183 extern const void *menu_userptr(const MENU *),
184 *item_userptr(const ITEM *);
186 extern chtype menu_back(const MENU *),
187 menu_fore(const MENU *),
188 menu_grey(const MENU *);
190 extern int free_item(ITEM *),
192 item_count(const MENU *),
193 item_index(const ITEM *),
194 item_opts_off(ITEM *,Item_Options),
195 item_opts_on(ITEM *,Item_Options),
196 menu_driver(MENU *,int),
197 menu_opts_off(MENU *,Menu_Options),
198 menu_opts_on(MENU *,Menu_Options),
199 menu_pad(const MENU *),
200 pos_menu_cursor(const MENU *),
202 scale_menu(const MENU *,int *,int *),
203 set_current_item(MENU *menu,ITEM *item),
204 set_item_init(MENU *,void(*)(MENU *)),
205 set_item_opts(ITEM *,Item_Options),
206 set_item_term(MENU *,void(*)(MENU *)),
207 set_item_userptr(ITEM *, const void *),
208 set_item_value(ITEM *,bool),
209 set_menu_back(MENU *,chtype),
210 set_menu_fore(MENU *,chtype),
211 set_menu_format(MENU *,int,int),
212 set_menu_grey(MENU *,chtype),
213 set_menu_init(MENU *,void(*)(MENU *)),
214 set_menu_items(MENU *,ITEM **),
215 set_menu_mark(MENU *, const char *),
216 set_menu_opts(MENU *,Menu_Options),
217 set_menu_pad(MENU *,int),
218 set_menu_pattern(MENU *,const char *),
219 set_menu_sub(MENU *,WINDOW *),
220 set_menu_term(MENU *,void(*)(MENU *)),
221 set_menu_userptr(MENU *,const void *),
222 set_menu_win(MENU *,WINDOW *),
223 set_top_row(MENU *,int),
224 top_row(const MENU *),
226 menu_request_by_name(const char *),
227 set_menu_spacing(MENU *,int,int,int),
228 menu_spacing(const MENU *,int *,int *,int *);
231 extern bool item_value(const ITEM *),
232 item_visible(const ITEM *);
234 void menu_format(const MENU *,int *,int *);
240 #endif /* ETI_MENU */