annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/ncursesw/menu.h @ 69:33d812a61356

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