jpayne@69: /**************************************************************************** jpayne@69: * Copyright 2020 Thomas E. Dickey * jpayne@69: * Copyright 1998-2016,2017 Free Software Foundation, Inc. * jpayne@69: * * jpayne@69: * Permission is hereby granted, free of charge, to any person obtaining a * jpayne@69: * copy of this software and associated documentation files (the * jpayne@69: * "Software"), to deal in the Software without restriction, including * jpayne@69: * without limitation the rights to use, copy, modify, merge, publish, * jpayne@69: * distribute, distribute with modifications, sublicense, and/or sell * jpayne@69: * copies of the Software, and to permit persons to whom the Software is * jpayne@69: * furnished to do so, subject to the following conditions: * jpayne@69: * * jpayne@69: * The above copyright notice and this permission notice shall be included * jpayne@69: * in all copies or substantial portions of the Software. * jpayne@69: * * jpayne@69: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * jpayne@69: * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * jpayne@69: * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * jpayne@69: * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * jpayne@69: * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * jpayne@69: * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * jpayne@69: * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * jpayne@69: * * jpayne@69: * Except as contained in this notice, the name(s) of the above copyright * jpayne@69: * holders shall not be used in advertising or otherwise to promote the * jpayne@69: * sale, use or other dealings in this Software without prior written * jpayne@69: * authorization. * jpayne@69: ****************************************************************************/ jpayne@69: jpayne@69: /**************************************************************************** jpayne@69: * Author: Juergen Pfeifer, 1995,1997 * jpayne@69: ****************************************************************************/ jpayne@69: jpayne@69: /* $Id: menu.h,v 1.26 2020/12/12 00:38:02 tom Exp $ */ jpayne@69: jpayne@69: #ifndef ETI_MENU jpayne@69: #define ETI_MENU jpayne@69: jpayne@69: #ifdef AMIGA jpayne@69: #define TEXT TEXT_ncurses jpayne@69: #endif jpayne@69: jpayne@69: #include jpayne@69: #include jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" jpayne@69: { jpayne@69: #endif jpayne@69: jpayne@69: #if defined(BUILDING_MENU) jpayne@69: # define MENU_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT jpayne@69: #else jpayne@69: # define MENU_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT jpayne@69: #endif jpayne@69: jpayne@69: #define MENU_WRAPPED_VAR(type,name) extern MENU_IMPEXP type NCURSES_PUBLIC_VAR(name)(void) jpayne@69: jpayne@69: #define MENU_EXPORT(type) MENU_IMPEXP type NCURSES_API jpayne@69: #define MENU_EXPORT_VAR(type) MENU_IMPEXP type jpayne@69: jpayne@69: typedef int Menu_Options; jpayne@69: typedef int Item_Options; jpayne@69: jpayne@69: /* Menu options: */ jpayne@69: #define O_ONEVALUE (0x01) jpayne@69: #define O_SHOWDESC (0x02) jpayne@69: #define O_ROWMAJOR (0x04) jpayne@69: #define O_IGNORECASE (0x08) jpayne@69: #define O_SHOWMATCH (0x10) jpayne@69: #define O_NONCYCLIC (0x20) jpayne@69: #define O_MOUSE_MENU (0x40) jpayne@69: jpayne@69: /* Item options: */ jpayne@69: #define O_SELECTABLE (0x01) jpayne@69: jpayne@69: #if !NCURSES_OPAQUE_MENU jpayne@69: typedef struct jpayne@69: { jpayne@69: const char *str; jpayne@69: unsigned short length; jpayne@69: } jpayne@69: TEXT; jpayne@69: #endif /* !NCURSES_OPAQUE_MENU */ jpayne@69: jpayne@69: struct tagMENU; jpayne@69: jpayne@69: typedef struct tagITEM jpayne@69: #if !NCURSES_OPAQUE_MENU jpayne@69: { jpayne@69: TEXT name; /* name of menu item */ jpayne@69: TEXT description; /* description of item, optional in display */ jpayne@69: struct tagMENU *imenu; /* Pointer to parent menu */ jpayne@69: void *userptr; /* Pointer to user defined per item data */ jpayne@69: Item_Options opt; /* Item options */ jpayne@69: short index; /* Item number if connected to a menu */ jpayne@69: short y; /* y and x location of item in menu */ jpayne@69: short x; jpayne@69: bool value; /* Selection value */ jpayne@69: jpayne@69: struct tagITEM *left; /* neighbor items */ jpayne@69: struct tagITEM *right; jpayne@69: struct tagITEM *up; jpayne@69: struct tagITEM *down; jpayne@69: jpayne@69: } jpayne@69: #endif /* !NCURSES_OPAQUE_MENU */ jpayne@69: ITEM; jpayne@69: jpayne@69: typedef void (*Menu_Hook) (struct tagMENU *); jpayne@69: jpayne@69: typedef struct tagMENU jpayne@69: #if 1 /* not yet: !NCURSES_OPAQUE_MENU */ jpayne@69: { jpayne@69: short height; /* Nr. of chars high */ jpayne@69: short width; /* Nr. of chars wide */ jpayne@69: short rows; /* Nr. of items high */ jpayne@69: short cols; /* Nr. of items wide */ jpayne@69: short frows; /* Nr. of formatted items high */ jpayne@69: short fcols; /* Nr. of formatted items wide */ jpayne@69: short arows; /* Nr. of items high (actual) */ jpayne@69: short namelen; /* Max. name length */ jpayne@69: short desclen; /* Max. description length */ jpayne@69: short marklen; /* Length of mark, if any */ jpayne@69: short itemlen; /* Length of one item */ jpayne@69: short spc_desc; /* Spacing for descriptor */ jpayne@69: short spc_cols; /* Spacing for columns */ jpayne@69: short spc_rows; /* Spacing for rows */ jpayne@69: char *pattern; /* Buffer to store match chars */ jpayne@69: short pindex; /* Index into pattern buffer */ jpayne@69: WINDOW *win; /* Window containing menu */ jpayne@69: WINDOW *sub; /* Subwindow for menu display */ jpayne@69: WINDOW *userwin; /* User's window */ jpayne@69: WINDOW *usersub; /* User's subwindow */ jpayne@69: ITEM **items; /* array of items */ jpayne@69: short nitems; /* Nr. of items in menu */ jpayne@69: ITEM *curitem; /* Current item */ jpayne@69: short toprow; /* Top row of menu */ jpayne@69: chtype fore; /* Selection attribute */ jpayne@69: chtype back; /* Nonselection attribute */ jpayne@69: chtype grey; /* Inactive attribute */ jpayne@69: unsigned char pad; /* Pad character */ jpayne@69: jpayne@69: Menu_Hook menuinit; /* User hooks */ jpayne@69: Menu_Hook menuterm; jpayne@69: Menu_Hook iteminit; jpayne@69: Menu_Hook itemterm; jpayne@69: jpayne@69: void *userptr; /* Pointer to menus user data */ jpayne@69: char *mark; /* Pointer to marker string */ jpayne@69: jpayne@69: Menu_Options opt; /* Menu options */ jpayne@69: unsigned short status; /* Internal state of menu */ jpayne@69: } jpayne@69: #endif /* !NCURSES_OPAQUE_MENU */ jpayne@69: MENU; jpayne@69: jpayne@69: /* Define keys */ jpayne@69: jpayne@69: #define REQ_LEFT_ITEM (KEY_MAX + 1) jpayne@69: #define REQ_RIGHT_ITEM (KEY_MAX + 2) jpayne@69: #define REQ_UP_ITEM (KEY_MAX + 3) jpayne@69: #define REQ_DOWN_ITEM (KEY_MAX + 4) jpayne@69: #define REQ_SCR_ULINE (KEY_MAX + 5) jpayne@69: #define REQ_SCR_DLINE (KEY_MAX + 6) jpayne@69: #define REQ_SCR_DPAGE (KEY_MAX + 7) jpayne@69: #define REQ_SCR_UPAGE (KEY_MAX + 8) jpayne@69: #define REQ_FIRST_ITEM (KEY_MAX + 9) jpayne@69: #define REQ_LAST_ITEM (KEY_MAX + 10) jpayne@69: #define REQ_NEXT_ITEM (KEY_MAX + 11) jpayne@69: #define REQ_PREV_ITEM (KEY_MAX + 12) jpayne@69: #define REQ_TOGGLE_ITEM (KEY_MAX + 13) jpayne@69: #define REQ_CLEAR_PATTERN (KEY_MAX + 14) jpayne@69: #define REQ_BACK_PATTERN (KEY_MAX + 15) jpayne@69: #define REQ_NEXT_MATCH (KEY_MAX + 16) jpayne@69: #define REQ_PREV_MATCH (KEY_MAX + 17) jpayne@69: jpayne@69: #define MIN_MENU_COMMAND (KEY_MAX + 1) jpayne@69: #define MAX_MENU_COMMAND (KEY_MAX + 17) jpayne@69: jpayne@69: /* jpayne@69: * Some AT&T code expects MAX_COMMAND to be out-of-band not jpayne@69: * just for menu commands but for forms ones as well. jpayne@69: */ jpayne@69: #if defined(MAX_COMMAND) jpayne@69: # if (MAX_MENU_COMMAND > MAX_COMMAND) jpayne@69: # error Something is wrong -- MAX_MENU_COMMAND is greater than MAX_COMMAND jpayne@69: # elif (MAX_COMMAND != (KEY_MAX + 128)) jpayne@69: # error Something is wrong -- MAX_COMMAND is already inconsistently defined. jpayne@69: # endif jpayne@69: #else jpayne@69: # define MAX_COMMAND (KEY_MAX + 128) jpayne@69: #endif jpayne@69: jpayne@69: /* --------- prototypes for libmenu functions ----------------------------- */ jpayne@69: jpayne@69: extern MENU_EXPORT(ITEM **) menu_items(const MENU *); jpayne@69: extern MENU_EXPORT(ITEM *) current_item(const MENU *); jpayne@69: extern MENU_EXPORT(ITEM *) new_item(const char *, const char *); jpayne@69: jpayne@69: extern MENU_EXPORT(MENU *) new_menu(ITEM **); jpayne@69: jpayne@69: extern MENU_EXPORT(Item_Options) item_opts(const ITEM *); jpayne@69: extern MENU_EXPORT(Menu_Options) menu_opts(const MENU *); jpayne@69: jpayne@69: extern MENU_EXPORT(Menu_Hook) item_init(const MENU *); jpayne@69: extern MENU_EXPORT(Menu_Hook) item_term(const MENU *); jpayne@69: extern MENU_EXPORT(Menu_Hook) menu_init(const MENU *); jpayne@69: extern MENU_EXPORT(Menu_Hook) menu_term(const MENU *); jpayne@69: jpayne@69: extern MENU_EXPORT(WINDOW *) menu_sub(const MENU *); jpayne@69: extern MENU_EXPORT(WINDOW *) menu_win(const MENU *); jpayne@69: jpayne@69: extern MENU_EXPORT(const char *) item_description(const ITEM *); jpayne@69: extern MENU_EXPORT(const char *) item_name(const ITEM *); jpayne@69: extern MENU_EXPORT(const char *) menu_mark(const MENU *); jpayne@69: extern MENU_EXPORT(const char *) menu_request_name(int); jpayne@69: jpayne@69: extern MENU_EXPORT(char *) menu_pattern(const MENU *); jpayne@69: jpayne@69: extern MENU_EXPORT(void *) menu_userptr(const MENU *); jpayne@69: extern MENU_EXPORT(void *) item_userptr(const ITEM *); jpayne@69: jpayne@69: extern MENU_EXPORT(chtype) menu_back(const MENU *); jpayne@69: extern MENU_EXPORT(chtype) menu_fore(const MENU *); jpayne@69: extern MENU_EXPORT(chtype) menu_grey(const MENU *); jpayne@69: jpayne@69: extern MENU_EXPORT(int) free_item(ITEM *); jpayne@69: extern MENU_EXPORT(int) free_menu(MENU *); jpayne@69: extern MENU_EXPORT(int) item_count(const MENU *); jpayne@69: extern MENU_EXPORT(int) item_index(const ITEM *); jpayne@69: extern MENU_EXPORT(int) item_opts_off(ITEM *, Item_Options); jpayne@69: extern MENU_EXPORT(int) item_opts_on(ITEM *, Item_Options); jpayne@69: extern MENU_EXPORT(int) menu_driver(MENU *, int); jpayne@69: extern MENU_EXPORT(int) menu_opts_off(MENU *, Menu_Options); jpayne@69: extern MENU_EXPORT(int) menu_opts_on(MENU *, Menu_Options); jpayne@69: extern MENU_EXPORT(int) menu_pad(const MENU *); jpayne@69: extern MENU_EXPORT(int) pos_menu_cursor(const MENU *); jpayne@69: extern MENU_EXPORT(int) post_menu(MENU *); jpayne@69: extern MENU_EXPORT(int) scale_menu(const MENU *, int *, int *); jpayne@69: extern MENU_EXPORT(int) set_current_item(MENU *menu, ITEM *item); jpayne@69: extern MENU_EXPORT(int) set_item_init(MENU *, Menu_Hook); jpayne@69: extern MENU_EXPORT(int) set_item_opts(ITEM *, Item_Options); jpayne@69: extern MENU_EXPORT(int) set_item_term(MENU *, Menu_Hook); jpayne@69: extern MENU_EXPORT(int) set_item_userptr(ITEM *, void *); jpayne@69: extern MENU_EXPORT(int) set_item_value(ITEM *, bool); jpayne@69: extern MENU_EXPORT(int) set_menu_back(MENU *, chtype); jpayne@69: extern MENU_EXPORT(int) set_menu_fore(MENU *, chtype); jpayne@69: extern MENU_EXPORT(int) set_menu_format(MENU *, int, int); jpayne@69: extern MENU_EXPORT(int) set_menu_grey(MENU *, chtype); jpayne@69: extern MENU_EXPORT(int) set_menu_init(MENU *, Menu_Hook); jpayne@69: extern MENU_EXPORT(int) set_menu_items(MENU *, ITEM **); jpayne@69: extern MENU_EXPORT(int) set_menu_mark(MENU *, const char *); jpayne@69: extern MENU_EXPORT(int) set_menu_opts(MENU *, Menu_Options); jpayne@69: extern MENU_EXPORT(int) set_menu_pad(MENU *, int); jpayne@69: extern MENU_EXPORT(int) set_menu_pattern(MENU *, const char *); jpayne@69: extern MENU_EXPORT(int) set_menu_sub(MENU *, WINDOW *); jpayne@69: extern MENU_EXPORT(int) set_menu_term(MENU *, Menu_Hook); jpayne@69: extern MENU_EXPORT(int) set_menu_userptr(MENU *, void *); jpayne@69: extern MENU_EXPORT(int) set_menu_win(MENU *, WINDOW *); jpayne@69: extern MENU_EXPORT(int) set_top_row(MENU *, int); jpayne@69: extern MENU_EXPORT(int) top_row(const MENU *); jpayne@69: extern MENU_EXPORT(int) unpost_menu(MENU *); jpayne@69: extern MENU_EXPORT(int) menu_request_by_name(const char *); jpayne@69: extern MENU_EXPORT(int) set_menu_spacing(MENU *, int, int, int); jpayne@69: extern MENU_EXPORT(int) menu_spacing(const MENU *, int *, int *, int *); jpayne@69: jpayne@69: extern MENU_EXPORT(bool) item_value(const ITEM *); jpayne@69: extern MENU_EXPORT(bool) item_visible(const ITEM *); jpayne@69: jpayne@69: extern MENU_EXPORT(void) menu_format(const MENU *, int *, int *); jpayne@69: jpayne@69: #if NCURSES_SP_FUNCS jpayne@69: extern MENU_EXPORT(MENU *) NCURSES_SP_NAME(new_menu) (SCREEN *, ITEM **); jpayne@69: #endif jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: #endif /* ETI_MENU */