Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-05-18 08:30:07

0001 /****************************************************************************
0002  * Copyright 2020 Thomas E. Dickey                                          *
0003  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
0004  *                                                                          *
0005  * Permission is hereby granted, free of charge, to any person obtaining a  *
0006  * copy of this software and associated documentation files (the            *
0007  * "Software"), to deal in the Software without restriction, including      *
0008  * without limitation the rights to use, copy, modify, merge, publish,      *
0009  * distribute, distribute with modifications, sublicense, and/or sell       *
0010  * copies of the Software, and to permit persons to whom the Software is    *
0011  * furnished to do so, subject to the following conditions:                 *
0012  *                                                                          *
0013  * The above copyright notice and this permission notice shall be included  *
0014  * in all copies or substantial portions of the Software.                   *
0015  *                                                                          *
0016  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
0017  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
0018  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
0019  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
0020  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
0021  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
0022  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
0023  *                                                                          *
0024  * Except as contained in this notice, the name(s) of the above copyright   *
0025  * holders shall not be used in advertising or otherwise to promote the     *
0026  * sale, use or other dealings in this Software without prior written       *
0027  * authorization.                                                           *
0028  ****************************************************************************/
0029 
0030 /****************************************************************************
0031  *   Author:  Juergen Pfeifer, 1995,1997                                    *
0032  ****************************************************************************/
0033 
0034 /* $Id: menu.h,v 1.26 2020/12/12 00:38:02 tom Exp $ */
0035 
0036 #ifndef ETI_MENU
0037 #define ETI_MENU
0038 
0039 #ifdef AMIGA
0040 #define TEXT TEXT_ncurses
0041 #endif
0042 
0043 #include <ncursesw/curses.h>
0044 #include <ncursesw/eti.h>
0045 
0046 #ifdef __cplusplus
0047 extern "C"
0048 {
0049 #endif
0050 
0051 #if defined(BUILDING_MENU)
0052 # define MENU_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT
0053 #else
0054 # define MENU_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT
0055 #endif
0056 
0057 #define MENU_WRAPPED_VAR(type,name) extern MENU_IMPEXP type NCURSES_PUBLIC_VAR(name)(void)
0058 
0059 #define MENU_EXPORT(type) MENU_IMPEXP type NCURSES_API
0060 #define MENU_EXPORT_VAR(type) MENU_IMPEXP type
0061 
0062   typedef int Menu_Options;
0063   typedef int Item_Options;
0064 
0065 /* Menu options: */
0066 #define O_ONEVALUE      (0x01)
0067 #define O_SHOWDESC      (0x02)
0068 #define O_ROWMAJOR      (0x04)
0069 #define O_IGNORECASE    (0x08)
0070 #define O_SHOWMATCH     (0x10)
0071 #define O_NONCYCLIC     (0x20)
0072 #define O_MOUSE_MENU    (0x40)
0073 
0074 /* Item options: */
0075 #define O_SELECTABLE    (0x01)
0076 
0077 #if !NCURSES_OPAQUE_MENU
0078   typedef struct
0079     {
0080       const char *str;
0081       unsigned short length;
0082     }
0083   TEXT;
0084 #endif              /* !NCURSES_OPAQUE_MENU */
0085 
0086   struct tagMENU;
0087 
0088   typedef struct tagITEM
0089 #if !NCURSES_OPAQUE_MENU
0090     {
0091       TEXT name;        /* name of menu item                         */
0092       TEXT description;     /* description of item, optional in display  */
0093       struct tagMENU *imenu;    /* Pointer to parent menu                    */
0094       void *userptr;        /* Pointer to user defined per item data     */
0095       Item_Options opt;     /* Item options                              */
0096       short index;      /* Item number if connected to a menu        */
0097       short y;          /* y and x location of item in menu          */
0098       short x;
0099       bool value;       /* Selection value                           */
0100 
0101       struct tagITEM *left; /* neighbor items                            */
0102       struct tagITEM *right;
0103       struct tagITEM *up;
0104       struct tagITEM *down;
0105 
0106     }
0107 #endif              /* !NCURSES_OPAQUE_MENU */
0108   ITEM;
0109 
0110   typedef void (*Menu_Hook) (struct tagMENU *);
0111 
0112   typedef struct tagMENU
0113 #if 1               /* not yet: !NCURSES_OPAQUE_MENU   */
0114     {
0115       short height;     /* Nr. of chars high               */
0116       short width;      /* Nr. of chars wide               */
0117       short rows;       /* Nr. of items high               */
0118       short cols;       /* Nr. of items wide               */
0119       short frows;      /* Nr. of formatted items high     */
0120       short fcols;      /* Nr. of formatted items wide     */
0121       short arows;      /* Nr. of items high (actual)      */
0122       short namelen;        /* Max. name length                */
0123       short desclen;        /* Max. description length         */
0124       short marklen;        /* Length of mark, if any          */
0125       short itemlen;        /* Length of one item              */
0126       short spc_desc;       /* Spacing for descriptor          */
0127       short spc_cols;       /* Spacing for columns             */
0128       short spc_rows;       /* Spacing for rows                */
0129       char *pattern;        /* Buffer to store match chars     */
0130       short pindex;     /* Index into pattern buffer       */
0131       WINDOW *win;      /* Window containing menu          */
0132       WINDOW *sub;      /* Subwindow for menu display      */
0133       WINDOW *userwin;      /* User's window                   */
0134       WINDOW *usersub;      /* User's subwindow                */
0135       ITEM **items;     /* array of items                  */
0136       short nitems;     /* Nr. of items in menu            */
0137       ITEM *curitem;        /* Current item                    */
0138       short toprow;     /* Top row of menu                 */
0139       chtype fore;      /* Selection attribute             */
0140       chtype back;      /* Nonselection attribute          */
0141       chtype grey;      /* Inactive attribute              */
0142       unsigned char pad;    /* Pad character                   */
0143 
0144       Menu_Hook menuinit;   /* User hooks                      */
0145       Menu_Hook menuterm;
0146       Menu_Hook iteminit;
0147       Menu_Hook itemterm;
0148 
0149       void *userptr;        /* Pointer to menus user data      */
0150       char *mark;       /* Pointer to marker string        */
0151 
0152       Menu_Options opt;     /* Menu options                    */
0153       unsigned short status;    /* Internal state of menu          */
0154     }
0155 #endif              /* !NCURSES_OPAQUE_MENU */
0156   MENU;
0157 
0158 /* Define keys */
0159 
0160 #define REQ_LEFT_ITEM           (KEY_MAX + 1)
0161 #define REQ_RIGHT_ITEM          (KEY_MAX + 2)
0162 #define REQ_UP_ITEM             (KEY_MAX + 3)
0163 #define REQ_DOWN_ITEM           (KEY_MAX + 4)
0164 #define REQ_SCR_ULINE           (KEY_MAX + 5)
0165 #define REQ_SCR_DLINE           (KEY_MAX + 6)
0166 #define REQ_SCR_DPAGE           (KEY_MAX + 7)
0167 #define REQ_SCR_UPAGE           (KEY_MAX + 8)
0168 #define REQ_FIRST_ITEM          (KEY_MAX + 9)
0169 #define REQ_LAST_ITEM           (KEY_MAX + 10)
0170 #define REQ_NEXT_ITEM           (KEY_MAX + 11)
0171 #define REQ_PREV_ITEM           (KEY_MAX + 12)
0172 #define REQ_TOGGLE_ITEM         (KEY_MAX + 13)
0173 #define REQ_CLEAR_PATTERN       (KEY_MAX + 14)
0174 #define REQ_BACK_PATTERN        (KEY_MAX + 15)
0175 #define REQ_NEXT_MATCH          (KEY_MAX + 16)
0176 #define REQ_PREV_MATCH          (KEY_MAX + 17)
0177 
0178 #define MIN_MENU_COMMAND        (KEY_MAX + 1)
0179 #define MAX_MENU_COMMAND        (KEY_MAX + 17)
0180 
0181 /*
0182  * Some AT&T code expects MAX_COMMAND to be out-of-band not
0183  * just for menu commands but for forms ones as well.
0184  */
0185 #if defined(MAX_COMMAND)
0186 #  if (MAX_MENU_COMMAND > MAX_COMMAND)
0187 #    error Something is wrong -- MAX_MENU_COMMAND is greater than MAX_COMMAND
0188 #  elif (MAX_COMMAND != (KEY_MAX + 128))
0189 #    error Something is wrong -- MAX_COMMAND is already inconsistently defined.
0190 #  endif
0191 #else
0192 #  define MAX_COMMAND (KEY_MAX + 128)
0193 #endif
0194 
0195 /* --------- prototypes for libmenu functions ----------------------------- */
0196 
0197   extern MENU_EXPORT(ITEM **) menu_items(const MENU *);
0198   extern MENU_EXPORT(ITEM *) current_item(const MENU *);
0199   extern MENU_EXPORT(ITEM *) new_item(const char *, const char *);
0200 
0201   extern MENU_EXPORT(MENU *) new_menu(ITEM **);
0202 
0203   extern MENU_EXPORT(Item_Options) item_opts(const ITEM *);
0204   extern MENU_EXPORT(Menu_Options) menu_opts(const MENU *);
0205 
0206   extern MENU_EXPORT(Menu_Hook) item_init(const MENU *);
0207   extern MENU_EXPORT(Menu_Hook) item_term(const MENU *);
0208   extern MENU_EXPORT(Menu_Hook) menu_init(const MENU *);
0209   extern MENU_EXPORT(Menu_Hook) menu_term(const MENU *);
0210 
0211   extern MENU_EXPORT(WINDOW *) menu_sub(const MENU *);
0212   extern MENU_EXPORT(WINDOW *) menu_win(const MENU *);
0213 
0214   extern MENU_EXPORT(const char *) item_description(const ITEM *);
0215   extern MENU_EXPORT(const char *) item_name(const ITEM *);
0216   extern MENU_EXPORT(const char *) menu_mark(const MENU *);
0217   extern MENU_EXPORT(const char *) menu_request_name(int);
0218 
0219   extern MENU_EXPORT(char *) menu_pattern(const MENU *);
0220 
0221   extern MENU_EXPORT(void *) menu_userptr(const MENU *);
0222   extern MENU_EXPORT(void *) item_userptr(const ITEM *);
0223 
0224   extern MENU_EXPORT(chtype) menu_back(const MENU *);
0225   extern MENU_EXPORT(chtype) menu_fore(const MENU *);
0226   extern MENU_EXPORT(chtype) menu_grey(const MENU *);
0227 
0228   extern MENU_EXPORT(int) free_item(ITEM *);
0229   extern MENU_EXPORT(int) free_menu(MENU *);
0230   extern MENU_EXPORT(int) item_count(const MENU *);
0231   extern MENU_EXPORT(int) item_index(const ITEM *);
0232   extern MENU_EXPORT(int) item_opts_off(ITEM *, Item_Options);
0233   extern MENU_EXPORT(int) item_opts_on(ITEM *, Item_Options);
0234   extern MENU_EXPORT(int) menu_driver(MENU *, int);
0235   extern MENU_EXPORT(int) menu_opts_off(MENU *, Menu_Options);
0236   extern MENU_EXPORT(int) menu_opts_on(MENU *, Menu_Options);
0237   extern MENU_EXPORT(int) menu_pad(const MENU *);
0238   extern MENU_EXPORT(int) pos_menu_cursor(const MENU *);
0239   extern MENU_EXPORT(int) post_menu(MENU *);
0240   extern MENU_EXPORT(int) scale_menu(const MENU *, int *, int *);
0241   extern MENU_EXPORT(int) set_current_item(MENU *menu, ITEM *item);
0242   extern MENU_EXPORT(int) set_item_init(MENU *, Menu_Hook);
0243   extern MENU_EXPORT(int) set_item_opts(ITEM *, Item_Options);
0244   extern MENU_EXPORT(int) set_item_term(MENU *, Menu_Hook);
0245   extern MENU_EXPORT(int) set_item_userptr(ITEM *, void *);
0246   extern MENU_EXPORT(int) set_item_value(ITEM *, bool);
0247   extern MENU_EXPORT(int) set_menu_back(MENU *, chtype);
0248   extern MENU_EXPORT(int) set_menu_fore(MENU *, chtype);
0249   extern MENU_EXPORT(int) set_menu_format(MENU *, int, int);
0250   extern MENU_EXPORT(int) set_menu_grey(MENU *, chtype);
0251   extern MENU_EXPORT(int) set_menu_init(MENU *, Menu_Hook);
0252   extern MENU_EXPORT(int) set_menu_items(MENU *, ITEM **);
0253   extern MENU_EXPORT(int) set_menu_mark(MENU *, const char *);
0254   extern MENU_EXPORT(int) set_menu_opts(MENU *, Menu_Options);
0255   extern MENU_EXPORT(int) set_menu_pad(MENU *, int);
0256   extern MENU_EXPORT(int) set_menu_pattern(MENU *, const char *);
0257   extern MENU_EXPORT(int) set_menu_sub(MENU *, WINDOW *);
0258   extern MENU_EXPORT(int) set_menu_term(MENU *, Menu_Hook);
0259   extern MENU_EXPORT(int) set_menu_userptr(MENU *, void *);
0260   extern MENU_EXPORT(int) set_menu_win(MENU *, WINDOW *);
0261   extern MENU_EXPORT(int) set_top_row(MENU *, int);
0262   extern MENU_EXPORT(int) top_row(const MENU *);
0263   extern MENU_EXPORT(int) unpost_menu(MENU *);
0264   extern MENU_EXPORT(int) menu_request_by_name(const char *);
0265   extern MENU_EXPORT(int) set_menu_spacing(MENU *, int, int, int);
0266   extern MENU_EXPORT(int) menu_spacing(const MENU *, int *, int *, int *);
0267 
0268   extern MENU_EXPORT(bool) item_value(const ITEM *);
0269   extern MENU_EXPORT(bool) item_visible(const ITEM *);
0270 
0271   extern MENU_EXPORT(void) menu_format(const MENU *, int *, int *);
0272 
0273 #if NCURSES_SP_FUNCS
0274   extern MENU_EXPORT(MENU *) NCURSES_SP_NAME(new_menu) (SCREEN *, ITEM **);
0275 #endif
0276 
0277 #ifdef __cplusplus
0278 }
0279 #endif
0280 
0281 #endif              /* ETI_MENU */