1*c7ef0cfcSnicm /* $OpenBSD: menu.priv.h,v 1.9 2023/10/17 09:52:10 nicm Exp $ */ 29f1aa62bSmillert 3457960bfSmillert /**************************************************************************** 4*c7ef0cfcSnicm * Copyright 2020 Thomas E. Dickey * 5*c7ef0cfcSnicm * Copyright 1998-2016,2017 Free Software Foundation, Inc. * 6457960bfSmillert * * 7457960bfSmillert * Permission is hereby granted, free of charge, to any person obtaining a * 8457960bfSmillert * copy of this software and associated documentation files (the * 9457960bfSmillert * "Software"), to deal in the Software without restriction, including * 10457960bfSmillert * without limitation the rights to use, copy, modify, merge, publish, * 11457960bfSmillert * distribute, distribute with modifications, sublicense, and/or sell * 12457960bfSmillert * copies of the Software, and to permit persons to whom the Software is * 13457960bfSmillert * furnished to do so, subject to the following conditions: * 14457960bfSmillert * * 15457960bfSmillert * The above copyright notice and this permission notice shall be included * 16457960bfSmillert * in all copies or substantial portions of the Software. * 17457960bfSmillert * * 18457960bfSmillert * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 19457960bfSmillert * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 20457960bfSmillert * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 21457960bfSmillert * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 22457960bfSmillert * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 23457960bfSmillert * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 24457960bfSmillert * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 25457960bfSmillert * * 26457960bfSmillert * Except as contained in this notice, the name(s) of the above copyright * 27457960bfSmillert * holders shall not be used in advertising or otherwise to promote the * 28457960bfSmillert * sale, use or other dealings in this Software without prior written * 29457960bfSmillert * authorization. * 30457960bfSmillert ****************************************************************************/ 31457960bfSmillert 32457960bfSmillert /**************************************************************************** 3381d8c4e1Snicm * Author: Juergen Pfeifer, 1995,1997 * 34457960bfSmillert ****************************************************************************/ 35c166cd22Stholo 36*c7ef0cfcSnicm /* $Id: menu.priv.h,v 1.9 2023/10/17 09:52:10 nicm Exp $ */ 3781d8c4e1Snicm 38c166cd22Stholo /*************************************************************************** 39c166cd22Stholo * Module menu.priv.h * 40c166cd22Stholo * Top level private header file for all libnmenu modules * 41c166cd22Stholo ***************************************************************************/ 42c166cd22Stholo 4381d8c4e1Snicm #ifndef MENU_PRIV_H_incl 4481d8c4e1Snicm #define MENU_PRIV_H_incl 1 45*c7ef0cfcSnicm /* *INDENT-OFF* */ 4681d8c4e1Snicm 4781d8c4e1Snicm #include "curses.priv.h" 48*c7ef0cfcSnicm 49*c7ef0cfcSnicm #define NCURSES_OPAQUE_MENU 0 50*c7ef0cfcSnicm 51c166cd22Stholo #include "mf_common.h" 52c166cd22Stholo #include "menu.h" 53c166cd22Stholo 54c166cd22Stholo /* Backspace code */ 55c166cd22Stholo #define BS (8) 56c166cd22Stholo 57*c7ef0cfcSnicm extern MENU_EXPORT_VAR(ITEM) _nc_Default_Item; 58*c7ef0cfcSnicm extern MENU_EXPORT_VAR(MENU) _nc_Default_Menu; 59c166cd22Stholo 60c166cd22Stholo /* Normalize item to default if none was given */ 61c166cd22Stholo #define Normalize_Item( item ) ((item)=(item)?(item):&_nc_Default_Item) 62c166cd22Stholo 63c166cd22Stholo /* Normalize menu to default if none was given */ 64c166cd22Stholo #define Normalize_Menu( menu ) ((menu)=(menu)?(menu):&_nc_Default_Menu) 65c166cd22Stholo 66*c7ef0cfcSnicm #define Get_Menu_Screen( menu ) (menu->userwin ? \ 67*c7ef0cfcSnicm _nc_screen_of(menu->userwin) : CURRENT_SCREEN) 68*c7ef0cfcSnicm 695be68eb8Smillert /* Get the user defined (framing) window of the menu */ 70*c7ef0cfcSnicm #define Get_Menu_UserWin(menu) ((menu)->userwin ? \ 71*c7ef0cfcSnicm (menu)->userwin : CURRENT_SCREEN->_stdscr) 725be68eb8Smillert 73c166cd22Stholo /* Normalize menu window */ 74c166cd22Stholo #define Get_Menu_Window( menu ) \ 755be68eb8Smillert ((menu)->usersub ? (menu)->usersub : Get_Menu_UserWin(menu)) 76c166cd22Stholo 77c166cd22Stholo /* menu specific status flags */ 78c166cd22Stholo #define _LINK_NEEDED (0x04) 790107aba4Smillert #define _MARK_ALLOCATED (0x08) 80c166cd22Stholo 81c166cd22Stholo #define ALL_MENU_OPTS ( \ 82c166cd22Stholo O_ONEVALUE | \ 83c166cd22Stholo O_SHOWDESC | \ 84c166cd22Stholo O_ROWMAJOR | \ 85c166cd22Stholo O_IGNORECASE | \ 86c166cd22Stholo O_SHOWMATCH | \ 87*c7ef0cfcSnicm O_NONCYCLIC | \ 88*c7ef0cfcSnicm O_MOUSE_MENU ) 89c166cd22Stholo 90c166cd22Stholo #define ALL_ITEM_OPTS (O_SELECTABLE) 91c166cd22Stholo 92c166cd22Stholo /* Move to the window position of an item and draw it */ 93c166cd22Stholo #define Move_And_Post_Item(menu,item) \ 940107aba4Smillert {wmove((menu)->win,(menu)->spc_rows*(item)->y,((menu)->itemlen+(menu)->spc_cols)*(item)->x);\ 95c166cd22Stholo _nc_Post_Item((menu),(item));} 96c166cd22Stholo 97c166cd22Stholo #define Move_To_Current_Item(menu,item) \ 98c166cd22Stholo if ( (item) != (menu)->curitem)\ 99c166cd22Stholo {\ 100c166cd22Stholo Move_And_Post_Item(menu,item);\ 101c166cd22Stholo Move_And_Post_Item(menu,(menu)->curitem);\ 102c166cd22Stholo } 103c166cd22Stholo 104c166cd22Stholo /* This macro ensures, that the item becomes visible, if possible with the 105c166cd22Stholo specified row as the top row of the window. If this is not possible, 106c166cd22Stholo the top row will be adjusted and the value is stored in the row argument. 107c166cd22Stholo */ 108c166cd22Stholo #define Adjust_Current_Item(menu,row,item) \ 109c166cd22Stholo { if ((item)->y < row) \ 110*c7ef0cfcSnicm row = (short) (item)->y; \ 1110107aba4Smillert if ( (item)->y >= (row + (menu)->arows) ) \ 112*c7ef0cfcSnicm row = (short) (( (item)->y < ((menu)->rows - row) ) \ 113*c7ef0cfcSnicm ? (item)->y \ 114*c7ef0cfcSnicm : (menu)->rows - (menu)->arows); \ 115c166cd22Stholo _nc_New_TopRow_and_CurrentItem(menu,row,item); } 116c166cd22Stholo 117c166cd22Stholo /* Reset the match pattern buffer */ 118c166cd22Stholo #define Reset_Pattern(menu) \ 119c166cd22Stholo { (menu)->pindex = 0; \ 120c166cd22Stholo (menu)->pattern[0] = '\0'; } 121c166cd22Stholo 12281d8c4e1Snicm #define UChar(c) ((unsigned char)(c)) 12381d8c4e1Snicm 124c166cd22Stholo /* Internal functions. */ 125*c7ef0cfcSnicm extern MENU_EXPORT(void) _nc_Draw_Menu (const MENU *); 126*c7ef0cfcSnicm extern MENU_EXPORT(void) _nc_Show_Menu (const MENU *); 127*c7ef0cfcSnicm extern MENU_EXPORT(void) _nc_Calculate_Item_Length_and_Width (MENU *); 128*c7ef0cfcSnicm extern MENU_EXPORT(int) _nc_Calculate_Text_Width(const TEXT *); 129*c7ef0cfcSnicm extern MENU_EXPORT(void) _nc_Post_Item (const MENU *, const ITEM *); 130*c7ef0cfcSnicm extern MENU_EXPORT(bool) _nc_Connect_Items (MENU *, ITEM **); 131*c7ef0cfcSnicm extern MENU_EXPORT(void) _nc_Disconnect_Items (MENU *); 132*c7ef0cfcSnicm extern MENU_EXPORT(void) _nc_New_TopRow_and_CurrentItem (MENU *,int, ITEM *); 133*c7ef0cfcSnicm extern MENU_EXPORT(void) _nc_Link_Items (MENU *); 134*c7ef0cfcSnicm extern MENU_EXPORT(int) _nc_Match_Next_Character_In_Item_Name (MENU*,int,ITEM**); 135*c7ef0cfcSnicm extern MENU_EXPORT(int) _nc_menu_cursor_pos (const MENU* menu, const ITEM* item, 1365be68eb8Smillert int* pY, int* pX); 13781d8c4e1Snicm 13881d8c4e1Snicm #ifdef TRACE 13981d8c4e1Snicm 140*c7ef0cfcSnicm #define returnItem(code) TRACE_RETURN1(code,item) 141*c7ef0cfcSnicm #define returnItemPtr(code) TRACE_RETURN1(code,item_ptr) 142*c7ef0cfcSnicm #define returnItemOpts(code) TRACE_RETURN1(code,item_opts) 143*c7ef0cfcSnicm #define returnMenu(code) TRACE_RETURN1(code,menu) 144*c7ef0cfcSnicm #define returnMenuHook(code) TRACE_RETURN1(code,menu_hook) 145*c7ef0cfcSnicm #define returnMenuOpts(code) TRACE_RETURN1(code,menu_opts) 14681d8c4e1Snicm 147*c7ef0cfcSnicm extern MENU_EXPORT(ITEM *) _nc_retrace_item (ITEM *); 148*c7ef0cfcSnicm extern MENU_EXPORT(ITEM **) _nc_retrace_item_ptr (ITEM **); 149*c7ef0cfcSnicm extern MENU_EXPORT(Item_Options) _nc_retrace_item_opts (Item_Options); 150*c7ef0cfcSnicm extern MENU_EXPORT(MENU *) _nc_retrace_menu (MENU *); 151*c7ef0cfcSnicm extern MENU_EXPORT(Menu_Hook) _nc_retrace_menu_hook (Menu_Hook); 152*c7ef0cfcSnicm extern MENU_EXPORT(Menu_Options) _nc_retrace_menu_opts (Menu_Options); 15381d8c4e1Snicm 15481d8c4e1Snicm #else /* !TRACE */ 15581d8c4e1Snicm 15681d8c4e1Snicm #define returnItem(code) return code 15781d8c4e1Snicm #define returnItemPtr(code) return code 15881d8c4e1Snicm #define returnItemOpts(code) return code 15981d8c4e1Snicm #define returnMenu(code) return code 16081d8c4e1Snicm #define returnMenuHook(code) return code 16181d8c4e1Snicm #define returnMenuOpts(code) return code 16281d8c4e1Snicm 16381d8c4e1Snicm #endif /* TRACE/!TRACE */ 164*c7ef0cfcSnicm /* *INDENT-ON* */ 16581d8c4e1Snicm 16681d8c4e1Snicm #endif /* MENU_PRIV_H_incl */ 167