diff options
Diffstat (limited to 'menu')
-rw-r--r-- | menu/Makefile.in | 46 | ||||
-rw-r--r-- | menu/READ.ME | 6 | ||||
-rw-r--r-- | menu/llib-lmenu | 98 | ||||
-rw-r--r-- | menu/llib-lmenut | 98 | ||||
-rw-r--r-- | menu/llib-lmenutw | 98 | ||||
-rw-r--r-- | menu/llib-lmenuw | 98 | ||||
-rw-r--r-- | menu/m_attribs.c | 42 | ||||
-rw-r--r-- | menu/m_cursor.c | 24 | ||||
-rw-r--r-- | menu/m_driver.c | 26 | ||||
-rw-r--r-- | menu/m_format.c | 15 | ||||
-rw-r--r-- | menu/m_global.c | 104 | ||||
-rw-r--r-- | menu/m_hook.c | 48 | ||||
-rw-r--r-- | menu/m_item_cur.c | 30 | ||||
-rw-r--r-- | menu/m_item_nam.c | 20 | ||||
-rw-r--r-- | menu/m_item_new.c | 54 | ||||
-rw-r--r-- | menu/m_item_opt.c | 44 | ||||
-rw-r--r-- | menu/m_item_top.c | 26 | ||||
-rw-r--r-- | menu/m_item_use.c | 10 | ||||
-rw-r--r-- | menu/m_item_val.c | 26 | ||||
-rw-r--r-- | menu/m_item_vis.c | 12 | ||||
-rw-r--r-- | menu/m_items.c | 32 | ||||
-rw-r--r-- | menu/m_new.c | 35 | ||||
-rw-r--r-- | menu/m_opts.c | 20 | ||||
-rw-r--r-- | menu/m_pad.c | 24 | ||||
-rw-r--r-- | menu/m_pattern.c | 20 | ||||
-rw-r--r-- | menu/m_post.c | 81 | ||||
-rw-r--r-- | menu/m_req_name.c | 19 | ||||
-rw-r--r-- | menu/m_scale.c | 14 | ||||
-rw-r--r-- | menu/m_spacing.c | 10 | ||||
-rw-r--r-- | menu/m_sub.c | 20 | ||||
-rw-r--r-- | menu/m_trace.c | 20 | ||||
-rw-r--r-- | menu/m_userptr.c | 10 | ||||
-rw-r--r-- | menu/m_win.c | 20 | ||||
-rw-r--r-- | menu/menu.h | 330 | ||||
-rw-r--r-- | menu/menu.priv.h | 40 |
35 files changed, 835 insertions, 785 deletions
diff --git a/menu/Makefile.in b/menu/Makefile.in index 495651c..b623bf0 100644 --- a/menu/Makefile.in +++ b/menu/Makefile.in @@ -1,6 +1,6 @@ -# $Id: Makefile.in,v 1.66 2020/02/02 23:34:34 tom Exp $ +# $Id: Makefile.in,v 1.71 2021/07/03 15:45:33 tom Exp $ ############################################################################## -# Copyright 2020 Thomas E. Dickey # +# Copyright 2020,2021 Thomas E. Dickey # # Copyright 1998-2015,2018 Free Software Foundation, Inc. # # # # Permission is hereby granted, free of charge, to any person obtaining a # @@ -90,16 +90,18 @@ ETAGS = @ETAGS@ CC = @CC@ CPP = @CPP@ -CFLAGS = @CFLAGS@ +CFLAGS = @CFLAGS@ @EXTRA_CFLAGS@ -CPPFLAGS = -I${top_srcdir}/ncurses -DHAVE_CONFIG_H @CPPFLAGS@ +INCDIR = $(top_srcdir)/include +BASE_DIR = $(top_srcdir)/ncurses +CPPFLAGS = -I$(BASE_DIR) -DHAVE_CONFIG_H -DBUILDING_MENU @CPPFLAGS@ CCFLAGS = $(CPPFLAGS) $(CFLAGS) CFLAGS_LIBTOOL = $(CCFLAGS) -CFLAGS_NORMAL = $(CCFLAGS) -CFLAGS_DEBUG = $(CCFLAGS) @CC_G_OPT@ -DTRACE -CFLAGS_PROFILE = $(CCFLAGS) -pg +CFLAGS_NORMAL = $(CCFLAGS) -DNCURSES_STATIC +CFLAGS_DEBUG = $(CCFLAGS) -DNCURSES_STATIC @CC_G_OPT@ -DTRACE +CFLAGS_PROFILE = $(CCFLAGS) -DNCURSES_STATIC -pg CFLAGS_SHARED = $(CCFLAGS) @CC_SHARED_OPTS@ CFLAGS_DEFAULT = $(CFLAGS_@DFT_UPR_MODEL@) @@ -134,6 +136,19 @@ AUTO_SRC = \ ../include/mf_common.h ################################################################################ + +@MAKE_PHONY@.PHONY : all +@MAKE_PHONY@.PHONY : clean +@MAKE_PHONY@.PHONY : distclean +@MAKE_PHONY@.PHONY : install +@MAKE_PHONY@.PHONY : install.libs +@MAKE_PHONY@.PHONY : libs +@MAKE_PHONY@.PHONY : mostlyclean +@MAKE_PHONY@.PHONY : realclean +@MAKE_PHONY@.PHONY : sources +@MAKE_PHONY@.PHONY : uninstall +@MAKE_PHONY@.PHONY : uninstall.libs + all \ libs \ install :: $(AUTO_SRC) $(LIBRARIES) @@ -157,9 +172,22 @@ $(DESTDIR)$(libdir) : cp $(srcdir)/mf_common.h $@ HEADER_DEPS = \ + ../include/curses.h \ + ../include/ncurses_cfg.h \ + ../include/ncurses_def.h \ + ../include/ncurses_dll.h \ + ../include/term.h \ + ../include/unctrl.h \ + $(BASE_DIR)/curses.priv.h \ + $(BASE_DIR)/new_pair.h \ + $(INCDIR)/nc_alloc.h \ + $(INCDIR)/nc_panel.h \ + $(INCDIR)/nc_string.h \ + $(INCDIR)/nc_termios.h \ + $(INCDIR)/nc_tparm.h \ + $(INCDIR)/term_entry.h \ $(srcdir)/menu.priv.h \ - $(AUTO_SRC) \ - ../include/curses.h + $(AUTO_SRC) tags: $(CTAGS) *.[ch] diff --git a/menu/READ.ME b/menu/READ.ME index e790f43..8c78037 100644 --- a/menu/READ.ME +++ b/menu/READ.ME @@ -1,5 +1,5 @@ ------------------------------------------------------------------------------- --- Copyright 2020 Thomas E. Dickey -- +-- Copyright 2020,2021 Thomas E. Dickey -- -- Copyright 1998-2003,2006 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- @@ -26,7 +26,7 @@ -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------- --- $Id: READ.ME,v 1.10 2020/02/02 23:34:34 tom Exp $ +-- $Id: READ.ME,v 1.11 2021/06/17 21:20:30 tom Exp $ ------------------------------------------------------------------------------- This is a clone of the menu library that is available with typical @@ -37,7 +37,7 @@ a 386 based SVR4 implementation (ESIX). The development environment was and is an ELF based Linux system. -For things that still need doing, see the TO-DO file in the top-level +For things that still need doing, see the TO-DO file in the top-level directory. Juergen Pfeifer diff --git a/menu/llib-lmenu b/menu/llib-lmenu index 7a5a41b..67f6822 100644 --- a/menu/llib-lmenu +++ b/menu/llib-lmenu @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 1998-2010,2015 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,7 +38,7 @@ #undef set_menu_fore int set_menu_fore( - MENU *menu, + MENU *menu, chtype attr) { return(*(int *)0); } @@ -49,7 +49,7 @@ chtype menu_fore( #undef set_menu_back int set_menu_back( - MENU *menu, + MENU *menu, chtype attr) { return(*(int *)0); } @@ -60,7 +60,7 @@ chtype menu_back( #undef set_menu_grey int set_menu_grey( - MENU *menu, + MENU *menu, chtype attr) { return(*(int *)0); } @@ -73,9 +73,9 @@ chtype menu_grey( #undef _nc_menu_cursor_pos int _nc_menu_cursor_pos( - const MENU *menu, - const ITEM *item, - int *pY, + const MENU *menu, + const ITEM *item, + int *pY, int *pX) { return(*(int *)0); } @@ -88,14 +88,14 @@ int pos_menu_cursor( #undef _nc_Match_Next_Character_In_Item_Name int _nc_Match_Next_Character_In_Item_Name( - MENU *menu, - int ch, + MENU *menu, + int ch, ITEM **item) { return(*(int *)0); } #undef menu_driver int menu_driver( - MENU *menu, + MENU *menu, int c) { return(*(int *)0); } @@ -103,15 +103,15 @@ int menu_driver( #undef set_menu_format int set_menu_format( - MENU *menu, - int rows, + MENU *menu, + int rows, int cols) { return(*(int *)0); } #undef menu_format void menu_format( - const MENU *menu, - int *rows, + const MENU *menu, + int *rows, int *cols) { /* void */ } @@ -124,7 +124,7 @@ ITEM _nc_Default_Item; #undef _nc_Connect_Items NCURSES_BOOL _nc_Connect_Items( - MENU *menu, + MENU *menu, ITEM **items) { return(*(NCURSES_BOOL *)0); } @@ -155,8 +155,8 @@ void _nc_Show_Menu( #undef _nc_New_TopRow_and_CurrentItem void _nc_New_TopRow_and_CurrentItem( - MENU *menu, - int new_toprow, + MENU *menu, + int new_toprow, ITEM *new_current_item) { /* void */ } @@ -164,7 +164,7 @@ void _nc_New_TopRow_and_CurrentItem( #undef set_menu_init int set_menu_init( - MENU *menu, + MENU *menu, Menu_Hook func) { return(*(int *)0); } @@ -175,7 +175,7 @@ Menu_Hook menu_init( #undef set_menu_term int set_menu_term( - MENU *menu, + MENU *menu, Menu_Hook func) { return(*(int *)0); } @@ -186,7 +186,7 @@ Menu_Hook menu_term( #undef set_item_init int set_item_init( - MENU *menu, + MENU *menu, Menu_Hook func) { return(*(int *)0); } @@ -197,7 +197,7 @@ Menu_Hook item_init( #undef set_item_term int set_item_term( - MENU *menu, + MENU *menu, Menu_Hook func) { return(*(int *)0); } @@ -210,7 +210,7 @@ Menu_Hook item_term( #undef set_current_item int set_current_item( - MENU *menu, + MENU *menu, ITEM *item) { return(*(int *)0); } @@ -240,7 +240,7 @@ const char *item_description( #undef new_item ITEM *new_item( - const char *name, + const char *name, const char *description) { return(*(ITEM **)0); } @@ -251,7 +251,7 @@ int free_item( #undef set_menu_mark int set_menu_mark( - MENU *menu, + MENU *menu, const char *mark) { return(*(int *)0); } @@ -264,19 +264,19 @@ const char *menu_mark( #undef set_item_opts int set_item_opts( - ITEM *item, + ITEM *item, Item_Options opts) { return(*(int *)0); } #undef item_opts_off int item_opts_off( - ITEM *item, + ITEM *item, Item_Options opts) { return(*(int *)0); } #undef item_opts_on int item_opts_on( - ITEM *item, + ITEM *item, Item_Options opts) { return(*(int *)0); } @@ -289,7 +289,7 @@ Item_Options item_opts( #undef set_top_row int set_top_row( - MENU *menu, + MENU *menu, int row) { return(*(int *)0); } @@ -302,7 +302,7 @@ int top_row( #undef set_item_userptr int set_item_userptr( - ITEM *item, + ITEM *item, void *userptr) { return(*(int *)0); } @@ -315,7 +315,7 @@ void *item_userptr( #undef set_item_value int set_item_value( - ITEM *item, + ITEM *item, NCURSES_BOOL value) { return(*(int *)0); } @@ -335,7 +335,7 @@ NCURSES_BOOL item_visible( #undef set_menu_items int set_menu_items( - MENU *menu, + MENU *menu, ITEM **items) { return(*(int *)0); } @@ -353,7 +353,7 @@ int item_count( #undef new_menu_sp MENU *new_menu_sp( - SCREEN *sp, + SCREEN *sp, ITEM **items) { return(*(MENU **)0); } @@ -371,19 +371,19 @@ int free_menu( #undef set_menu_opts int set_menu_opts( - MENU *menu, + MENU *menu, Menu_Options opts) { return(*(int *)0); } #undef menu_opts_off int menu_opts_off( - MENU *menu, + MENU *menu, Menu_Options opts) { return(*(int *)0); } #undef menu_opts_on int menu_opts_on( - MENU *menu, + MENU *menu, Menu_Options opts) { return(*(int *)0); } @@ -396,7 +396,7 @@ Menu_Options menu_opts( #undef set_menu_pad int set_menu_pad( - MENU *menu, + MENU *menu, int pad) { return(*(int *)0); } @@ -414,7 +414,7 @@ char *menu_pattern( #undef set_menu_pattern int set_menu_pattern( - MENU *menu, + MENU *menu, const char *p) { return(*(int *)0); } @@ -422,7 +422,7 @@ int set_menu_pattern( #undef _nc_Post_Item void _nc_Post_Item( - const MENU *menu, + const MENU *menu, const ITEM *item) { /* void */ } @@ -457,8 +457,8 @@ int menu_request_by_name( #undef scale_menu int scale_menu( - const MENU *menu, - int *rows, + const MENU *menu, + int *rows, int *cols) { return(*(int *)0); } @@ -466,17 +466,17 @@ int scale_menu( #undef set_menu_spacing int set_menu_spacing( - MENU *menu, - int s_desc, - int s_row, + MENU *menu, + int s_desc, + int s_row, int s_col) { return(*(int *)0); } #undef menu_spacing int menu_spacing( - const MENU *menu, - int *s_desc, - int *s_row, + const MENU *menu, + int *s_desc, + int *s_row, int *s_col) { return(*(int *)0); } @@ -484,7 +484,7 @@ int menu_spacing( #undef set_menu_sub int set_menu_sub( - MENU *menu, + MENU *menu, WINDOW *win) { return(*(int *)0); } @@ -529,7 +529,7 @@ Menu_Options _nc_retrace_menu_opts( #undef set_menu_userptr int set_menu_userptr( - MENU *menu, + MENU *menu, void *userptr) { return(*(int *)0); } @@ -542,7 +542,7 @@ void *menu_userptr( #undef set_menu_win int set_menu_win( - MENU *menu, + MENU *menu, WINDOW *win) { return(*(int *)0); } diff --git a/menu/llib-lmenut b/menu/llib-lmenut index 1d348c0..0a0d059 100644 --- a/menu/llib-lmenut +++ b/menu/llib-lmenut @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 2010,2015 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,7 +38,7 @@ #undef set_menu_fore int set_menu_fore( - MENU *menu, + MENU *menu, chtype attr) { return(*(int *)0); } @@ -49,7 +49,7 @@ chtype menu_fore( #undef set_menu_back int set_menu_back( - MENU *menu, + MENU *menu, chtype attr) { return(*(int *)0); } @@ -60,7 +60,7 @@ chtype menu_back( #undef set_menu_grey int set_menu_grey( - MENU *menu, + MENU *menu, chtype attr) { return(*(int *)0); } @@ -73,9 +73,9 @@ chtype menu_grey( #undef _nc_menu_cursor_pos int _nc_menu_cursor_pos( - const MENU *menu, - const ITEM *item, - int *pY, + const MENU *menu, + const ITEM *item, + int *pY, int *pX) { return(*(int *)0); } @@ -88,14 +88,14 @@ int pos_menu_cursor( #undef _nc_Match_Next_Character_In_Item_Name int _nc_Match_Next_Character_In_Item_Name( - MENU *menu, - int ch, + MENU *menu, + int ch, ITEM **item) { return(*(int *)0); } #undef menu_driver int menu_driver( - MENU *menu, + MENU *menu, int c) { return(*(int *)0); } @@ -103,15 +103,15 @@ int menu_driver( #undef set_menu_format int set_menu_format( - MENU *menu, - int rows, + MENU *menu, + int rows, int cols) { return(*(int *)0); } #undef menu_format void menu_format( - const MENU *menu, - int *rows, + const MENU *menu, + int *rows, int *cols) { /* void */ } @@ -124,7 +124,7 @@ ITEM _nc_Default_Item; #undef _nc_Connect_Items NCURSES_BOOL _nc_Connect_Items( - MENU *menu, + MENU *menu, ITEM **items) { return(*(NCURSES_BOOL *)0); } @@ -155,8 +155,8 @@ void _nc_Show_Menu( #undef _nc_New_TopRow_and_CurrentItem void _nc_New_TopRow_and_CurrentItem( - MENU *menu, - int new_toprow, + MENU *menu, + int new_toprow, ITEM *new_current_item) { /* void */ } @@ -164,7 +164,7 @@ void _nc_New_TopRow_and_CurrentItem( #undef set_menu_init int set_menu_init( - MENU *menu, + MENU *menu, Menu_Hook func) { return(*(int *)0); } @@ -175,7 +175,7 @@ Menu_Hook menu_init( #undef set_menu_term int set_menu_term( - MENU *menu, + MENU *menu, Menu_Hook func) { return(*(int *)0); } @@ -186,7 +186,7 @@ Menu_Hook menu_term( #undef set_item_init int set_item_init( - MENU *menu, + MENU *menu, Menu_Hook func) { return(*(int *)0); } @@ -197,7 +197,7 @@ Menu_Hook item_init( #undef set_item_term int set_item_term( - MENU *menu, + MENU *menu, Menu_Hook func) { return(*(int *)0); } @@ -210,7 +210,7 @@ Menu_Hook item_term( #undef set_current_item int set_current_item( - MENU *menu, + MENU *menu, ITEM *item) { return(*(int *)0); } @@ -240,7 +240,7 @@ const char *item_description( #undef new_item ITEM *new_item( - const char *name, + const char *name, const char *description) { return(*(ITEM **)0); } @@ -251,7 +251,7 @@ int free_item( #undef set_menu_mark int set_menu_mark( - MENU *menu, + MENU *menu, const char *mark) { return(*(int *)0); } @@ -264,19 +264,19 @@ const char *menu_mark( #undef set_item_opts int set_item_opts( - ITEM *item, + ITEM *item, Item_Options opts) { return(*(int *)0); } #undef item_opts_off int item_opts_off( - ITEM *item, + ITEM *item, Item_Options opts) { return(*(int *)0); } #undef item_opts_on int item_opts_on( - ITEM *item, + ITEM *item, Item_Options opts) { return(*(int *)0); } @@ -289,7 +289,7 @@ Item_Options item_opts( #undef set_top_row int set_top_row( - MENU *menu, + MENU *menu, int row) { return(*(int *)0); } @@ -302,7 +302,7 @@ int top_row( #undef set_item_userptr int set_item_userptr( - ITEM *item, + ITEM *item, void *userptr) { return(*(int *)0); } @@ -315,7 +315,7 @@ void *item_userptr( #undef set_item_value int set_item_value( - ITEM *item, + ITEM *item, NCURSES_BOOL value) { return(*(int *)0); } @@ -335,7 +335,7 @@ NCURSES_BOOL item_visible( #undef set_menu_items int set_menu_items( - MENU *menu, + MENU *menu, ITEM **items) { return(*(int *)0); } @@ -353,7 +353,7 @@ int item_count( #undef new_menu_sp MENU *new_menu_sp( - SCREEN *sp, + SCREEN *sp, ITEM **items) { return(*(MENU **)0); } @@ -371,19 +371,19 @@ int free_menu( #undef set_menu_opts int set_menu_opts( - MENU *menu, + MENU *menu, Menu_Options opts) { return(*(int *)0); } #undef menu_opts_off int menu_opts_off( - MENU *menu, + MENU *menu, Menu_Options opts) { return(*(int *)0); } #undef menu_opts_on int menu_opts_on( - MENU *menu, + MENU *menu, Menu_Options opts) { return(*(int *)0); } @@ -396,7 +396,7 @@ Menu_Options menu_opts( #undef set_menu_pad int set_menu_pad( - MENU *menu, + MENU *menu, int pad) { return(*(int *)0); } @@ -414,7 +414,7 @@ char *menu_pattern( #undef set_menu_pattern int set_menu_pattern( - MENU *menu, + MENU *menu, const char *p) { return(*(int *)0); } @@ -422,7 +422,7 @@ int set_menu_pattern( #undef _nc_Post_Item void _nc_Post_Item( - const MENU *menu, + const MENU *menu, const ITEM *item) { /* void */ } @@ -457,8 +457,8 @@ int menu_request_by_name( #undef scale_menu int scale_menu( - const MENU *menu, - int *rows, + const MENU *menu, + int *rows, int *cols) { return(*(int *)0); } @@ -466,17 +466,17 @@ int scale_menu( #undef set_menu_spacing int set_menu_spacing( - MENU *menu, - int s_desc, - int s_row, + MENU *menu, + int s_desc, + int s_row, int s_col) { return(*(int *)0); } #undef menu_spacing int menu_spacing( - const MENU *menu, - int *s_desc, - int *s_row, + const MENU *menu, + int *s_desc, + int *s_row, int *s_col) { return(*(int *)0); } @@ -484,7 +484,7 @@ int menu_spacing( #undef set_menu_sub int set_menu_sub( - MENU *menu, + MENU *menu, WINDOW *win) { return(*(int *)0); } @@ -529,7 +529,7 @@ Menu_Options _nc_retrace_menu_opts( #undef set_menu_userptr int set_menu_userptr( - MENU *menu, + MENU *menu, void *userptr) { return(*(int *)0); } @@ -542,7 +542,7 @@ void *menu_userptr( #undef set_menu_win int set_menu_win( - MENU *menu, + MENU *menu, WINDOW *win) { return(*(int *)0); } diff --git a/menu/llib-lmenutw b/menu/llib-lmenutw index 1d348c0..0a0d059 100644 --- a/menu/llib-lmenutw +++ b/menu/llib-lmenutw @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 2010,2015 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,7 +38,7 @@ #undef set_menu_fore int set_menu_fore( - MENU *menu, + MENU *menu, chtype attr) { return(*(int *)0); } @@ -49,7 +49,7 @@ chtype menu_fore( #undef set_menu_back int set_menu_back( - MENU *menu, + MENU *menu, chtype attr) { return(*(int *)0); } @@ -60,7 +60,7 @@ chtype menu_back( #undef set_menu_grey int set_menu_grey( - MENU *menu, + MENU *menu, chtype attr) { return(*(int *)0); } @@ -73,9 +73,9 @@ chtype menu_grey( #undef _nc_menu_cursor_pos int _nc_menu_cursor_pos( - const MENU *menu, - const ITEM *item, - int *pY, + const MENU *menu, + const ITEM *item, + int *pY, int *pX) { return(*(int *)0); } @@ -88,14 +88,14 @@ int pos_menu_cursor( #undef _nc_Match_Next_Character_In_Item_Name int _nc_Match_Next_Character_In_Item_Name( - MENU *menu, - int ch, + MENU *menu, + int ch, ITEM **item) { return(*(int *)0); } #undef menu_driver int menu_driver( - MENU *menu, + MENU *menu, int c) { return(*(int *)0); } @@ -103,15 +103,15 @@ int menu_driver( #undef set_menu_format int set_menu_format( - MENU *menu, - int rows, + MENU *menu, + int rows, int cols) { return(*(int *)0); } #undef menu_format void menu_format( - const MENU *menu, - int *rows, + const MENU *menu, + int *rows, int *cols) { /* void */ } @@ -124,7 +124,7 @@ ITEM _nc_Default_Item; #undef _nc_Connect_Items NCURSES_BOOL _nc_Connect_Items( - MENU *menu, + MENU *menu, ITEM **items) { return(*(NCURSES_BOOL *)0); } @@ -155,8 +155,8 @@ void _nc_Show_Menu( #undef _nc_New_TopRow_and_CurrentItem void _nc_New_TopRow_and_CurrentItem( - MENU *menu, - int new_toprow, + MENU *menu, + int new_toprow, ITEM *new_current_item) { /* void */ } @@ -164,7 +164,7 @@ void _nc_New_TopRow_and_CurrentItem( #undef set_menu_init int set_menu_init( - MENU *menu, + MENU *menu, Menu_Hook func) { return(*(int *)0); } @@ -175,7 +175,7 @@ Menu_Hook menu_init( #undef set_menu_term int set_menu_term( - MENU *menu, + MENU *menu, Menu_Hook func) { return(*(int *)0); } @@ -186,7 +186,7 @@ Menu_Hook menu_term( #undef set_item_init int set_item_init( - MENU *menu, + MENU *menu, Menu_Hook func) { return(*(int *)0); } @@ -197,7 +197,7 @@ Menu_Hook item_init( #undef set_item_term int set_item_term( - MENU *menu, + MENU *menu, Menu_Hook func) { return(*(int *)0); } @@ -210,7 +210,7 @@ Menu_Hook item_term( #undef set_current_item int set_current_item( - MENU *menu, + MENU *menu, ITEM *item) { return(*(int *)0); } @@ -240,7 +240,7 @@ const char *item_description( #undef new_item ITEM *new_item( - const char *name, + const char *name, const char *description) { return(*(ITEM **)0); } @@ -251,7 +251,7 @@ int free_item( #undef set_menu_mark int set_menu_mark( - MENU *menu, + MENU *menu, const char *mark) { return(*(int *)0); } @@ -264,19 +264,19 @@ const char *menu_mark( #undef set_item_opts int set_item_opts( - ITEM *item, + ITEM *item, Item_Options opts) { return(*(int *)0); } #undef item_opts_off int item_opts_off( - ITEM *item, + ITEM *item, Item_Options opts) { return(*(int *)0); } #undef item_opts_on int item_opts_on( - ITEM *item, + ITEM *item, Item_Options opts) { return(*(int *)0); } @@ -289,7 +289,7 @@ Item_Options item_opts( #undef set_top_row int set_top_row( - MENU *menu, + MENU *menu, int row) { return(*(int *)0); } @@ -302,7 +302,7 @@ int top_row( #undef set_item_userptr int set_item_userptr( - ITEM *item, + ITEM *item, void *userptr) { return(*(int *)0); } @@ -315,7 +315,7 @@ void *item_userptr( #undef set_item_value int set_item_value( - ITEM *item, + ITEM *item, NCURSES_BOOL value) { return(*(int *)0); } @@ -335,7 +335,7 @@ NCURSES_BOOL item_visible( #undef set_menu_items int set_menu_items( - MENU *menu, + MENU *menu, ITEM **items) { return(*(int *)0); } @@ -353,7 +353,7 @@ int item_count( #undef new_menu_sp MENU *new_menu_sp( - SCREEN *sp, + SCREEN *sp, ITEM **items) { return(*(MENU **)0); } @@ -371,19 +371,19 @@ int free_menu( #undef set_menu_opts int set_menu_opts( - MENU *menu, + MENU *menu, Menu_Options opts) { return(*(int *)0); } #undef menu_opts_off int menu_opts_off( - MENU *menu, + MENU *menu, Menu_Options opts) { return(*(int *)0); } #undef menu_opts_on int menu_opts_on( - MENU *menu, + MENU *menu, Menu_Options opts) { return(*(int *)0); } @@ -396,7 +396,7 @@ Menu_Options menu_opts( #undef set_menu_pad int set_menu_pad( - MENU *menu, + MENU *menu, int pad) { return(*(int *)0); } @@ -414,7 +414,7 @@ char *menu_pattern( #undef set_menu_pattern int set_menu_pattern( - MENU *menu, + MENU *menu, const char *p) { return(*(int *)0); } @@ -422,7 +422,7 @@ int set_menu_pattern( #undef _nc_Post_Item void _nc_Post_Item( - const MENU *menu, + const MENU *menu, const ITEM *item) { /* void */ } @@ -457,8 +457,8 @@ int menu_request_by_name( #undef scale_menu int scale_menu( - const MENU *menu, - int *rows, + const MENU *menu, + int *rows, int *cols) { return(*(int *)0); } @@ -466,17 +466,17 @@ int scale_menu( #undef set_menu_spacing int set_menu_spacing( - MENU *menu, - int s_desc, - int s_row, + MENU *menu, + int s_desc, + int s_row, int s_col) { return(*(int *)0); } #undef menu_spacing int menu_spacing( - const MENU *menu, - int *s_desc, - int *s_row, + const MENU *menu, + int *s_desc, + int *s_row, int *s_col) { return(*(int *)0); } @@ -484,7 +484,7 @@ int menu_spacing( #undef set_menu_sub int set_menu_sub( - MENU *menu, + MENU *menu, WINDOW *win) { return(*(int *)0); } @@ -529,7 +529,7 @@ Menu_Options _nc_retrace_menu_opts( #undef set_menu_userptr int set_menu_userptr( - MENU *menu, + MENU *menu, void *userptr) { return(*(int *)0); } @@ -542,7 +542,7 @@ void *menu_userptr( #undef set_menu_win int set_menu_win( - MENU *menu, + MENU *menu, WINDOW *win) { return(*(int *)0); } diff --git a/menu/llib-lmenuw b/menu/llib-lmenuw index 6ad9614..d5566d4 100644 --- a/menu/llib-lmenuw +++ b/menu/llib-lmenuw @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 2002-2010,2015 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,7 +38,7 @@ #undef set_menu_fore int set_menu_fore( - MENU *menu, + MENU *menu, chtype attr) { return(*(int *)0); } @@ -49,7 +49,7 @@ chtype menu_fore( #undef set_menu_back int set_menu_back( - MENU *menu, + MENU *menu, chtype attr) { return(*(int *)0); } @@ -60,7 +60,7 @@ chtype menu_back( #undef set_menu_grey int set_menu_grey( - MENU *menu, + MENU *menu, chtype attr) { return(*(int *)0); } @@ -73,9 +73,9 @@ chtype menu_grey( #undef _nc_menu_cursor_pos int _nc_menu_cursor_pos( - const MENU *menu, - const ITEM *item, - int *pY, + const MENU *menu, + const ITEM *item, + int *pY, int *pX) { return(*(int *)0); } @@ -88,14 +88,14 @@ int pos_menu_cursor( #undef _nc_Match_Next_Character_In_Item_Name int _nc_Match_Next_Character_In_Item_Name( - MENU *menu, - int ch, + MENU *menu, + int ch, ITEM **item) { return(*(int *)0); } #undef menu_driver int menu_driver( - MENU *menu, + MENU *menu, int c) { return(*(int *)0); } @@ -103,15 +103,15 @@ int menu_driver( #undef set_menu_format int set_menu_format( - MENU *menu, - int rows, + MENU *menu, + int rows, int cols) { return(*(int *)0); } #undef menu_format void menu_format( - const MENU *menu, - int *rows, + const MENU *menu, + int *rows, int *cols) { /* void */ } @@ -124,7 +124,7 @@ ITEM _nc_Default_Item; #undef _nc_Connect_Items NCURSES_BOOL _nc_Connect_Items( - MENU *menu, + MENU *menu, ITEM **items) { return(*(NCURSES_BOOL *)0); } @@ -155,8 +155,8 @@ void _nc_Show_Menu( #undef _nc_New_TopRow_and_CurrentItem void _nc_New_TopRow_and_CurrentItem( - MENU *menu, - int new_toprow, + MENU *menu, + int new_toprow, ITEM *new_current_item) { /* void */ } @@ -164,7 +164,7 @@ void _nc_New_TopRow_and_CurrentItem( #undef set_menu_init int set_menu_init( - MENU *menu, + MENU *menu, Menu_Hook func) { return(*(int *)0); } @@ -175,7 +175,7 @@ Menu_Hook menu_init( #undef set_menu_term int set_menu_term( - MENU *menu, + MENU *menu, Menu_Hook func) { return(*(int *)0); } @@ -186,7 +186,7 @@ Menu_Hook menu_term( #undef set_item_init int set_item_init( - MENU *menu, + MENU *menu, Menu_Hook func) { return(*(int *)0); } @@ -197,7 +197,7 @@ Menu_Hook item_init( #undef set_item_term int set_item_term( - MENU *menu, + MENU *menu, Menu_Hook func) { return(*(int *)0); } @@ -210,7 +210,7 @@ Menu_Hook item_term( #undef set_current_item int set_current_item( - MENU *menu, + MENU *menu, ITEM *item) { return(*(int *)0); } @@ -240,7 +240,7 @@ const char *item_description( #undef new_item ITEM *new_item( - const char *name, + const char *name, const char *description) { return(*(ITEM **)0); } @@ -251,7 +251,7 @@ int free_item( #undef set_menu_mark int set_menu_mark( - MENU *menu, + MENU *menu, const char *mark) { return(*(int *)0); } @@ -264,19 +264,19 @@ const char *menu_mark( #undef set_item_opts int set_item_opts( - ITEM *item, + ITEM *item, Item_Options opts) { return(*(int *)0); } #undef item_opts_off int item_opts_off( - ITEM *item, + ITEM *item, Item_Options opts) { return(*(int *)0); } #undef item_opts_on int item_opts_on( - ITEM *item, + ITEM *item, Item_Options opts) { return(*(int *)0); } @@ -289,7 +289,7 @@ Item_Options item_opts( #undef set_top_row int set_top_row( - MENU *menu, + MENU *menu, int row) { return(*(int *)0); } @@ -302,7 +302,7 @@ int top_row( #undef set_item_userptr int set_item_userptr( - ITEM *item, + ITEM *item, void *userptr) { return(*(int *)0); } @@ -315,7 +315,7 @@ void *item_userptr( #undef set_item_value int set_item_value( - ITEM *item, + ITEM *item, NCURSES_BOOL value) { return(*(int *)0); } @@ -335,7 +335,7 @@ NCURSES_BOOL item_visible( #undef set_menu_items int set_menu_items( - MENU *menu, + MENU *menu, ITEM **items) { return(*(int *)0); } @@ -353,7 +353,7 @@ int item_count( #undef new_menu_sp MENU *new_menu_sp( - SCREEN *sp, + SCREEN *sp, ITEM **items) { return(*(MENU **)0); } @@ -371,19 +371,19 @@ int free_menu( #undef set_menu_opts int set_menu_opts( - MENU *menu, + MENU *menu, Menu_Options opts) { return(*(int *)0); } #undef menu_opts_off int menu_opts_off( - MENU *menu, + MENU *menu, Menu_Options opts) { return(*(int *)0); } #undef menu_opts_on int menu_opts_on( - MENU *menu, + MENU *menu, Menu_Options opts) { return(*(int *)0); } @@ -396,7 +396,7 @@ Menu_Options menu_opts( #undef set_menu_pad int set_menu_pad( - MENU *menu, + MENU *menu, int pad) { return(*(int *)0); } @@ -414,7 +414,7 @@ char *menu_pattern( #undef set_menu_pattern int set_menu_pattern( - MENU *menu, + MENU *menu, const char *p) { return(*(int *)0); } @@ -422,7 +422,7 @@ int set_menu_pattern( #undef _nc_Post_Item void _nc_Post_Item( - const MENU *menu, + const MENU *menu, const ITEM *item) { /* void */ } @@ -457,8 +457,8 @@ int menu_request_by_name( #undef scale_menu int scale_menu( - const MENU *menu, - int *rows, + const MENU *menu, + int *rows, int *cols) { return(*(int *)0); } @@ -466,17 +466,17 @@ int scale_menu( #undef set_menu_spacing int set_menu_spacing( - MENU *menu, - int s_desc, - int s_row, + MENU *menu, + int s_desc, + int s_row, int s_col) { return(*(int *)0); } #undef menu_spacing int menu_spacing( - const MENU *menu, - int *s_desc, - int *s_row, + const MENU *menu, + int *s_desc, + int *s_row, int *s_col) { return(*(int *)0); } @@ -484,7 +484,7 @@ int menu_spacing( #undef set_menu_sub int set_menu_sub( - MENU *menu, + MENU *menu, WINDOW *win) { return(*(int *)0); } @@ -529,7 +529,7 @@ Menu_Options _nc_retrace_menu_opts( #undef set_menu_userptr int set_menu_userptr( - MENU *menu, + MENU *menu, void *userptr) { return(*(int *)0); } @@ -542,7 +542,7 @@ void *menu_userptr( #undef set_menu_win int set_menu_win( - MENU *menu, + MENU *menu, WINDOW *win) { return(*(int *)0); } diff --git a/menu/m_attribs.c b/menu/m_attribs.c index e3c88ac..a9275d0 100644 --- a/menu/m_attribs.c +++ b/menu/m_attribs.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 1998-2010,2012 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,7 +38,7 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_attribs.c,v 1.18 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_attribs.c,v 1.20 2021/06/17 21:20:30 tom Exp $") /* Macro to redraw menu if it is posted and changed */ #define Refresh_Menu(menu) \ @@ -50,7 +50,7 @@ MODULE_ID("$Id: m_attribs.c,v 1.18 2020/02/02 23:34:34 tom Exp $") /* "Template" macro to generate a function to set a menus attribute */ #define GEN_MENU_ATTR_SET_FCT( name ) \ -NCURSES_IMPEXP int NCURSES_API set_menu_ ## name (MENU* menu, chtype attr) \ +MENU_EXPORT(int) NCURSES_API set_menu_ ## name (MENU* menu, chtype attr) \ {\ T((T_CALLED("set_menu_" #name "(%p,%s)"), (void *) menu, _traceattr(attr))); \ if (!(attr==A_NORMAL || (attr & A_ATTRIBUTES)==attr))\ @@ -66,76 +66,76 @@ NCURSES_IMPEXP int NCURSES_API set_menu_ ## name (MENU* menu, chtype attr) \ /* "Template" macro to generate a function to get a menu's attribute */ #define GEN_MENU_ATTR_GET_FCT( name ) \ -NCURSES_IMPEXP chtype NCURSES_API menu_ ## name (const MENU * menu)\ +MENU_EXPORT(chtype) NCURSES_API menu_ ## name (const MENU * menu)\ {\ T((T_CALLED("menu_" #name "(%p)"), (const void *) menu));\ returnAttr(Normalize_Menu( menu ) -> name);\ } /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : int set_menu_fore(MENU *menu, chtype attr) -| +| | Description : Set the attribute for selectable items. In single- | valued menus this is used to highlight the current | item ((i.e. where the cursor is), in multi-valued | menus this is used to highlight the selected items. | | Return Values : E_OK - success -| E_BAD_ARGUMENT - an invalid value has been passed +| E_BAD_ARGUMENT - an invalid value has been passed +--------------------------------------------------------------------------*/ GEN_MENU_ATTR_SET_FCT(fore) /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : chtype menu_fore(const MENU* menu) -| +| | Description : Return the attribute used for selectable items that | are current (single-valued menu) or selected (multi- -| valued menu). +| valued menu). | | Return Values : Attribute value +--------------------------------------------------------------------------*/ GEN_MENU_ATTR_GET_FCT(fore) /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : int set_menu_back(MENU *menu, chtype attr) -| +| | Description : Set the attribute for selectable but not yet selected | items. | -| Return Values : E_OK - success +| Return Values : E_OK - success | E_BAD_ARGUMENT - an invalid value has been passed +--------------------------------------------------------------------------*/ GEN_MENU_ATTR_SET_FCT(back) /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : chtype menu_back(const MENU *menu) -| +| | Description : Return the attribute used for selectable but not yet -| selected items. +| selected items. | | Return Values : Attribute value +--------------------------------------------------------------------------*/ GEN_MENU_ATTR_GET_FCT(back) /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : int set_menu_grey(MENU *menu, chtype attr) -| +| | Description : Set the attribute for unselectable items. | | Return Values : E_OK - success -| E_BAD_ARGUMENT - an invalid value has been passed +| E_BAD_ARGUMENT - an invalid value has been passed +--------------------------------------------------------------------------*/ GEN_MENU_ATTR_SET_FCT(grey) /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : chtype menu_grey(const MENU *menu) -| +| | Description : Return the attribute used for non-selectable items | | Return Values : Attribute value diff --git a/menu/m_cursor.c b/menu/m_cursor.c index 3f8e548..b9b301d 100644 --- a/menu/m_cursor.c +++ b/menu/m_cursor.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 1998-2009,2010 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,7 +38,7 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_cursor.c,v 1.23 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_cursor.c,v 1.26 2021/03/27 23:46:29 tom Exp $") /*--------------------------------------------------------------------------- | Facility : libnmenu @@ -50,16 +50,16 @@ MODULE_ID("$Id: m_cursor.c,v 1.23 2020/02/02 23:34:34 tom Exp $") | E_BAD_ARGUMENT - invalid menu | E_NOT_POSTED - Menu is not posted +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -_nc_menu_cursor_pos(const MENU * menu, const ITEM * item, int *pY, int *pX) +MENU_EXPORT(int) +_nc_menu_cursor_pos(const MENU *menu, const ITEM *item, int *pY, int *pX) { if (!menu || !pX || !pY) return (E_BAD_ARGUMENT); else { - if ((ITEM *) 0 == item) + if ((ITEM *)0 == item) item = menu->curitem; - assert(item != (ITEM *) 0); + assert(item != (ITEM *)0); if (!(menu->status & _POSTED)) return (E_NOT_POSTED); @@ -80,19 +80,19 @@ _nc_menu_cursor_pos(const MENU * menu, const ITEM * item, int *pY, int *pX) | E_BAD_ARGUMENT - invalid menu | E_NOT_POSTED - Menu is not posted +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -pos_menu_cursor(const MENU * menu) +MENU_EXPORT(int) +pos_menu_cursor(const MENU *menu) { - WINDOW *win, *sub; int x = 0, y = 0; - int err = _nc_menu_cursor_pos(menu, (ITEM *) 0, &y, &x); + int err = _nc_menu_cursor_pos(menu, (ITEM *)0, &y, &x); T((T_CALLED("pos_menu_cursor(%p)"), (const void *)menu)); if (E_OK == err) { - win = Get_Menu_UserWin(menu); - sub = menu->usersub ? menu->usersub : win; + WINDOW *win = Get_Menu_UserWin(menu); + WINDOW *sub = menu->usersub ? menu->usersub : win; + assert(win && sub); if ((menu->opt & O_SHOWMATCH) && (menu->pindex > 0)) diff --git a/menu/m_driver.c b/menu/m_driver.c index e592bab..cf2ef2f 100644 --- a/menu/m_driver.c +++ b/menu/m_driver.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 1998-2012,2016 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,7 +38,7 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_driver.c,v 1.34 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_driver.c,v 1.37 2021/03/27 23:46:29 tom Exp $") /* Macros */ @@ -115,9 +115,9 @@ Is_Sub_String( | Return Values : E_OK - an item matching the pattern was found | E_NO_MATCH - nothing found +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) +MENU_EXPORT(int) _nc_Match_Next_Character_In_Item_Name -(MENU * menu, int ch, ITEM ** item) +(MENU *menu, int ch, ITEM **item) { bool found = FALSE, passed = FALSE; int idx, last; @@ -209,8 +209,8 @@ _nc_Match_Next_Character_In_Item_Name | E_BAD_STATE - menu is in user hook routine | E_NOT_POSTED - menu is not posted +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -menu_driver(MENU * menu, int c) +MENU_EXPORT(int) +menu_driver(MENU *menu, int c) { #define NAVIGATE(dir) \ if (!item->dir)\ @@ -220,7 +220,7 @@ menu_driver(MENU * menu, int c) int result = E_OK; ITEM *item; - int my_top_row, rdiff; + int my_top_row; T((T_CALLED("menu_driver(%p,%d)"), (void *)menu, c)); @@ -239,6 +239,8 @@ menu_driver(MENU * menu, int c) if ((c > KEY_MAX) && (c <= MAX_MENU_COMMAND)) { + int rdiff; + if (!((c == REQ_BACK_PATTERN) || (c == REQ_NEXT_MATCH) || (c == REQ_PREV_MATCH))) { @@ -489,16 +491,20 @@ menu_driver(MENU * menu, int c) } else if (wenclose(sub, event.y, event.x)) { /* Inside the area we try to find the hit item */ - int i, x, y, err; + int x, y; ry = event.y; rx = event.x; if (wmouse_trafo(sub, &ry, &rx, FALSE)) { + int i; + for (i = 0; i < menu->nitems; i++) { - err = _nc_menu_cursor_pos(menu, menu->items[i], - &y, &x); + int err = _nc_menu_cursor_pos(menu, + menu->items[i], + &y, &x); + if (E_OK == err) { if ((ry == y) && diff --git a/menu/m_format.c b/menu/m_format.c index 9738dbf..65adfc6 100644 --- a/menu/m_format.c +++ b/menu/m_format.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 1998-2010,2012 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,7 +38,7 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_format.c,v 1.19 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_format.c,v 1.22 2021/03/27 23:46:29 tom Exp $") #define minimum(a,b) ((a)<(b) ? (a): (b)) @@ -56,10 +56,9 @@ MODULE_ID("$Id: m_format.c,v 1.19 2020/02/02 23:34:34 tom Exp $") | E_NOT_CONNECTED - there are no items connected | E_POSTED - the menu is already posted +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -set_menu_format(MENU * menu, int rows, int cols) +MENU_EXPORT(int) +set_menu_format(MENU *menu, int rows, int cols) { - int total_rows, total_cols; T((T_CALLED("set_menu_format(%p,%d,%d)"), (void *)menu, rows, cols)); @@ -68,6 +67,8 @@ set_menu_format(MENU * menu, int rows, int cols) if (menu) { + int total_rows, total_cols; + if (menu->status & _POSTED) RETURN(E_POSTED); @@ -120,8 +121,8 @@ set_menu_format(MENU * menu, int rows, int cols) | | Return Values : - +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(void) -menu_format(const MENU * menu, int *rows, int *cols) +MENU_EXPORT(void) +menu_format(const MENU *menu, int *rows, int *cols) { if (rows) *rows = Normalize_Menu(menu)->frows; diff --git a/menu/m_global.c b/menu/m_global.c index 489987f..4ec08c5 100644 --- a/menu/m_global.c +++ b/menu/m_global.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 1998-2012,2014 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,11 +38,11 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_global.c,v 1.30 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_global.c,v 1.33 2021/03/27 23:46:29 tom Exp $") static char mark[] = "-"; /* *INDENT-OFF* */ -NCURSES_EXPORT_VAR(MENU) _nc_Default_Menu = { +MENU_EXPORT_VAR(MENU) _nc_Default_Menu = { 16, /* Nr. of chars high */ 1, /* Nr. of chars wide */ 16, /* Nr. of items high */ @@ -81,7 +81,7 @@ NCURSES_EXPORT_VAR(MENU) _nc_Default_Menu = { 0 /* status */ }; -NCURSES_EXPORT_VAR(ITEM) _nc_Default_Item = { +MENU_EXPORT_VAR(ITEM) _nc_Default_Item = { { (char *)0, 0 }, /* name */ { (char *)0, 0 }, /* description */ (MENU *)0, /* Pointer to parent menu */ @@ -108,17 +108,17 @@ NCURSES_EXPORT_VAR(ITEM) _nc_Default_Item = { | Return Values : - +--------------------------------------------------------------------------*/ NCURSES_INLINE static void -ComputeMaximum_NameDesc_Lengths(MENU * menu) +ComputeMaximum_NameDesc_Lengths(MENU *menu) { unsigned MaximumNameLength = 0; unsigned MaximumDescriptionLength = 0; ITEM **items; - unsigned check; assert(menu && menu->items); for (items = menu->items; *items; items++) { - check = (unsigned)_nc_Calculate_Text_Width(&((*items)->name)); + unsigned check = (unsigned)_nc_Calculate_Text_Width(&((*items)->name)); + if (check > MaximumNameLength) MaximumNameLength = check; @@ -142,7 +142,7 @@ ComputeMaximum_NameDesc_Lengths(MENU * menu) | Return Values : - +--------------------------------------------------------------------------*/ NCURSES_INLINE static void -ResetConnectionInfo(MENU * menu, ITEM ** items) +ResetConnectionInfo(MENU *menu, ITEM **items) { ITEM **item; @@ -150,13 +150,13 @@ ResetConnectionInfo(MENU * menu, ITEM ** items) for (item = items; *item; item++) { (*item)->index = 0; - (*item)->imenu = (MENU *) 0; + (*item)->imenu = (MENU *)0; } if (menu->pattern) free(menu->pattern); menu->pattern = (char *)0; menu->pindex = 0; - menu->items = (ITEM **) 0; + menu->items = (ITEM **)0; menu->nitems = 0; } @@ -171,14 +171,15 @@ ResetConnectionInfo(MENU * menu, ITEM ** items) | Return Values : TRUE - successful connection | FALSE - connection failed +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(bool) -_nc_Connect_Items(MENU * menu, ITEM ** items) +MENU_EXPORT(bool) +_nc_Connect_Items(MENU *menu, ITEM **items) { - ITEM **item; unsigned int ItemCount = 0; if (menu && items) { + ITEM **item; + for (item = items; *item; item++) { if ((*item)->imenu) @@ -233,8 +234,8 @@ _nc_Connect_Items(MENU * menu, ITEM ** items) | | Return Values : - +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(void) -_nc_Disconnect_Items(MENU * menu) +MENU_EXPORT(void) +_nc_Disconnect_Items(MENU *menu) { if (menu && menu->items) ResetConnectionInfo(menu, menu->items); @@ -248,8 +249,8 @@ _nc_Disconnect_Items(MENU * menu) | | Return Values : the width +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -_nc_Calculate_Text_Width(const TEXT * item /*FIXME: limit length */ ) +MENU_EXPORT(int) +_nc_Calculate_Text_Width(const TEXT *item /*FIXME: limit length */ ) { #if USE_WIDEC_SUPPORT int result = item->length; @@ -289,26 +290,22 @@ _nc_Calculate_Text_Width(const TEXT * item /*FIXME: limit length */ ) */ #if USE_WIDEC_SUPPORT static int -calculate_actual_width(MENU * menu, bool name) +calculate_actual_width(MENU *menu, bool name) { int width = 0; - int check = 0; - ITEM **items; assert(menu && menu->items); if (menu->items != 0) { + ITEM **items; + for (items = menu->items; *items; items++) { - if (name) - { - check = _nc_Calculate_Text_Width(&((*items)->name)); - } - else - { - check = _nc_Calculate_Text_Width(&((*items)->description)); - } + int check = (name + ? _nc_Calculate_Text_Width(&((*items)->name)) + : _nc_Calculate_Text_Width(&((*items)->description))); + if (check > width) width = check; } @@ -337,8 +334,8 @@ calculate_actual_width(MENU * menu, bool name) | | Return Values : - +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(void) -_nc_Calculate_Item_Length_and_Width(MENU * menu) +MENU_EXPORT(void) +_nc_Calculate_Item_Length_and_Width(MENU *menu) { int l; @@ -376,12 +373,12 @@ _nc_Calculate_Item_Length_and_Width(MENU * menu) | | Return Values : - +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(void) -_nc_Link_Items(MENU * menu) +MENU_EXPORT(void) +_nc_Link_Items(MENU *menu) { if (menu && menu->items && *(menu->items)) { - int i, j; + int i; ITEM *item; int Number_Of_Items = menu->nitems; int col = 0, row = 0; @@ -408,14 +405,14 @@ _nc_Link_Items(MENU * menu) (cycle ? menu->items[(Last_in_Row >= Number_Of_Items) ? Number_Of_Items - 1 : Last_in_Row] : - (ITEM *) 0); + (ITEM *)0); item->right = ((col < (Number_Of_Columns - 1)) && ((i + 1) < Number_Of_Items) )? menu->items[i + 1] : (cycle ? menu->items[row * Number_Of_Columns] : - (ITEM *) 0 + (ITEM *)0 ); Last_in_Column = (menu->rows - 1) * Number_Of_Columns + col; @@ -424,14 +421,14 @@ _nc_Link_Items(MENU * menu) (cycle ? menu->items[(Last_in_Column >= Number_Of_Items) ? Number_Of_Items - 1 : Last_in_Column] : - (ITEM *) 0); + (ITEM *)0); item->down = ((i + Number_Of_Columns) < Number_Of_Items) ? menu->items[i + Number_Of_Columns] : (cycle ? menu->items[(row + 1) < menu->rows ? Number_Of_Items - 1 : col] : - (ITEM *) 0); + (ITEM *)0); item->x = (short)col; item->y = (short)row; if (++col == Number_Of_Columns) @@ -444,6 +441,7 @@ _nc_Link_Items(MENU * menu) else { int Number_Of_Rows = menu->rows; + int j; for (j = 0; j < Number_Of_Items; j++) { @@ -456,12 +454,12 @@ _nc_Link_Items(MENU * menu) (cycle ? (Last_in_Column >= Number_Of_Items) ? menu->items[Last_in_Column - Number_Of_Rows] : menu->items[Last_in_Column] : - (ITEM *) 0); + (ITEM *)0); item->right = ((i + Number_Of_Rows) < Number_Of_Items) ? menu->items[i + Number_Of_Rows] : - (cycle ? menu->items[row] : (ITEM *) 0); + (cycle ? menu->items[row] : (ITEM *)0); Last_in_Row = col * Number_Of_Rows + (Number_Of_Rows - 1); @@ -471,7 +469,7 @@ _nc_Link_Items(MENU * menu) menu->items[(Last_in_Row >= Number_Of_Items) ? Number_Of_Items - 1 : Last_in_Row] : - (ITEM *) 0); + (ITEM *)0); item->down = (row < (Number_Of_Rows - 1)) ? @@ -480,7 +478,7 @@ _nc_Link_Items(MENU * menu) (col - 1) * Number_Of_Rows + row + 1]) : (cycle ? menu->items[col * Number_Of_Rows] : - (ITEM *) 0 + (ITEM *)0 ); item->x = (short)col; @@ -503,15 +501,15 @@ _nc_Link_Items(MENU * menu) | | Return Values : - +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(void) -_nc_Show_Menu(const MENU * menu) +MENU_EXPORT(void) +_nc_Show_Menu(const MENU *menu) { - WINDOW *win; - int maxy, maxx; - assert(menu); if ((menu->status & _POSTED) && !(menu->status & _IN_DRIVER)) { + WINDOW *win; + int maxy, maxx; + /* adjust the internal subwindow to start on the current top */ assert(menu->sub); mvderwin(menu->sub, menu->spc_rows * menu->toprow, 0); @@ -543,19 +541,19 @@ _nc_Show_Menu(const MENU * menu) | | Return Values : - +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(void) +MENU_EXPORT(void) _nc_New_TopRow_and_CurrentItem( - MENU * menu, + MENU *menu, int new_toprow, - ITEM * new_current_item) + ITEM *new_current_item) { - ITEM *cur_item; - bool mterm_called = FALSE; - bool iterm_called = FALSE; - assert(menu); if (menu->status & _POSTED) { + ITEM *cur_item; + bool mterm_called = FALSE; + bool iterm_called = FALSE; + if (new_current_item != menu->curitem) { Call_Hook(menu, itemterm); diff --git a/menu/m_hook.c b/menu/m_hook.c index c98aede..c7d9fe9 100644 --- a/menu/m_hook.c +++ b/menu/m_hook.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018,2020 Thomas E. Dickey * + * Copyright 2018-2020,2021 Thomas E. Dickey * * Copyright 1998-2012,2016 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,11 +38,11 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_hook.c,v 1.19 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_hook.c,v 1.21 2021/06/17 21:26:02 tom Exp $") /* "Template" macro to generate function to set application specific hook */ #define GEN_HOOK_SET_FUNCTION( typ, name ) \ -NCURSES_IMPEXP int NCURSES_API set_ ## typ ## _ ## name (MENU *menu, Menu_Hook func )\ +MENU_EXPORT(int) NCURSES_API set_ ## typ ## _ ## name (MENU *menu, Menu_Hook func )\ {\ TR_FUNC_BFR(1);\ T((T_CALLED("set_" #typ "_" #name "(%p,%s)"), (void *) menu, TR_FUNC_ARG(0, func)));\ @@ -52,16 +52,16 @@ NCURSES_IMPEXP int NCURSES_API set_ ## typ ## _ ## name (MENU *menu, Menu_Hook f /* "Template" macro to generate function to get application specific hook */ #define GEN_HOOK_GET_FUNCTION( typ, name ) \ -NCURSES_IMPEXP Menu_Hook NCURSES_API typ ## _ ## name ( const MENU *menu )\ +MENU_EXPORT(Menu_Hook) NCURSES_API typ ## _ ## name ( const MENU *menu )\ {\ T((T_CALLED(#typ "_" #name "(%p)"), (const void *) menu));\ returnMenuHook(Normalize_Menu(menu) -> typ ## name);\ } /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : int set_menu_init(MENU *menu, void (*f)(MENU *)) -| +| | Description : Set user-exit which is called when menu is posted | or just after the top row changes. | @@ -70,11 +70,11 @@ NCURSES_IMPEXP Menu_Hook NCURSES_API typ ## _ ## name ( const MENU *menu )\ GEN_HOOK_SET_FUNCTION(menu, init) /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : void (*)(MENU *) menu_init(const MENU *menu) -| +| | Description : Return address of user-exit function which is called -| when a menu is posted or just after the top row +| when a menu is posted or just after the top row | changes. | | Return Values : Menu init function address or NULL @@ -82,9 +82,9 @@ GEN_HOOK_SET_FUNCTION(menu, init) GEN_HOOK_GET_FUNCTION(menu, init) /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : int set_menu_term (MENU *menu, void (*f)(MENU *)) -| +| | Description : Set user-exit which is called when menu is unposted | or just before the top row changes. | @@ -93,11 +93,11 @@ GEN_HOOK_GET_FUNCTION(menu, init) GEN_HOOK_SET_FUNCTION(menu, term) /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : void (*)(MENU *) menu_term(const MENU *menu) -| +| | Description : Return address of user-exit function which is called -| when a menu is unposted or just before the top row +| when a menu is unposted or just before the top row | changes. | | Return Values : Menu finalization function address or NULL @@ -105,9 +105,9 @@ GEN_HOOK_SET_FUNCTION(menu, term) GEN_HOOK_GET_FUNCTION(menu, term) /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : int set_item_init (MENU *menu, void (*f)(MENU *)) -| +| | Description : Set user-exit which is called when menu is posted | or just after the current item changes. | @@ -116,11 +116,11 @@ GEN_HOOK_GET_FUNCTION(menu, term) GEN_HOOK_SET_FUNCTION(item, init) /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : void (*)(MENU *) item_init (const MENU *menu) -| +| | Description : Return address of user-exit function which is called -| when a menu is posted or just after the current item +| when a menu is posted or just after the current item | changes. | | Return Values : Item init function address or NULL @@ -128,9 +128,9 @@ GEN_HOOK_SET_FUNCTION(item, init) GEN_HOOK_GET_FUNCTION(item, init) /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : int set_item_term (MENU *menu, void (*f)(MENU *)) -| +| | Description : Set user-exit which is called when menu is unposted | or just before the current item changes. | @@ -139,11 +139,11 @@ GEN_HOOK_GET_FUNCTION(item, init) GEN_HOOK_SET_FUNCTION(item, term) /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : void (*)(MENU *) item_init (const MENU *menu) -| +| | Description : Return address of user-exit function which is called -| when a menu is unposted or just before the current item +| when a menu is unposted or just before the current item | changes. | | Return Values : Item finalization function address or NULL diff --git a/menu/m_item_cur.c b/menu/m_item_cur.c index c09bf31..ed76518 100644 --- a/menu/m_item_cur.c +++ b/menu/m_item_cur.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 1998-2004,2010 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,18 +38,18 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_item_cur.c,v 1.19 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_item_cur.c,v 1.22 2021/06/17 21:20:30 tom Exp $") /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : int set_current_item(MENU *menu, const ITEM *item) -| +| | Description : Make the item the current item | | Return Values : E_OK - success +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -set_current_item(MENU * menu, ITEM * item) +MENU_EXPORT(int) +set_current_item(MENU *menu, ITEM *item) { T((T_CALLED("set_current_item(%p,%p)"), (void *)menu, (void *)item)); @@ -82,30 +82,30 @@ set_current_item(MENU * menu, ITEM * item) } /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : ITEM *current_item(const MENU *menu) -| +| | Description : Return the menus current item | | Return Values : Item pointer or NULL if failure +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(ITEM *) -current_item(const MENU * menu) +MENU_EXPORT(ITEM *) +current_item(const MENU *menu) { T((T_CALLED("current_item(%p)"), (const void *)menu)); - returnItem((menu && menu->items) ? menu->curitem : (ITEM *) 0); + returnItem((menu && menu->items) ? menu->curitem : (ITEM *)0); } /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : int item_index(const ITEM *) -| +| | Description : Return the logical index of this item. | | Return Values : The index or ERR if this is an invalid item pointer +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -item_index(const ITEM * item) +MENU_EXPORT(int) +item_index(const ITEM *item) { T((T_CALLED("item_index(%p)"), (const void *)item)); returnCode((item && item->imenu) ? item->index : ERR); diff --git a/menu/m_item_nam.c b/menu/m_item_nam.c index aaf54e0..ce74531 100644 --- a/menu/m_item_nam.c +++ b/menu/m_item_nam.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 1998-2004,2010 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,33 +38,33 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_item_nam.c,v 1.16 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_item_nam.c,v 1.19 2021/06/17 21:20:30 tom Exp $") /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : char *item_name(const ITEM *item) -| +| | Description : Return name of menu item | | Return Values : See above; returns NULL if item is invalid +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(const char *) -item_name(const ITEM * item) +MENU_EXPORT(const char *) +item_name(const ITEM *item) { T((T_CALLED("item_name(%p)"), (const void *)item)); returnCPtr((item) ? item->name.str : (char *)0); } /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : char *item_description(const ITEM *item) -| +| | Description : Returns description of item | | Return Values : See above; Returns NULL if item is invalid +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(const char *) -item_description(const ITEM * item) +MENU_EXPORT(const char *) +item_description(const ITEM *item) { T((T_CALLED("item_description(%p)"), (const void *)item)); returnCPtr((item) ? item->description.str : (char *)0); diff --git a/menu/m_item_new.c b/menu/m_item_new.c index 1e7950d..28b71ca 100644 --- a/menu/m_item_new.c +++ b/menu/m_item_new.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020-2021 Thomas E. Dickey * * Copyright 1998-2010,2012 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -45,12 +45,12 @@ #endif #endif -MODULE_ID("$Id: m_item_new.c,v 1.34 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_item_new.c,v 1.38 2021/06/17 21:26:02 tom Exp $") /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : bool Is_Printable_String(const char *s) -| +| | Description : Checks whether or not the string contains only printable | characters. | @@ -75,7 +75,7 @@ Is_Printable_String(const char *s) mbstowcs(temp, s, (unsigned)count); for (n = 0; n < count; ++n) - if (!iswprint((wint_t) temp[n])) + if (!iswprint((wint_t)temp[n])) { result = FALSE; break; @@ -98,16 +98,16 @@ Is_Printable_String(const char *s) } /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : ITEM *new_item(char *name, char *description) -| +| | Description : Create a new item with name and description. Return | a pointer to this new item. | N.B.: an item must(!) have a name. | | Return Values : The item pointer or NULL if creation failed. +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(ITEM *) +MENU_EXPORT(ITEM *) new_item(const char *name, const char *description) { ITEM *item; @@ -118,14 +118,16 @@ new_item(const char *name, const char *description) if (!name || (*name == '\0') || !Is_Printable_String(name)) { - item = (ITEM *) 0; + item = (ITEM *)0; SET_ERROR(E_BAD_ARGUMENT); } else { item = typeCalloc(ITEM, 1); + if (item) { + T((T_CREATE("item %p"), (void *)item)); *item = _nc_Default_Item; /* hope we have struct assignment */ item->name.length = (unsigned short)strlen(name); @@ -150,18 +152,18 @@ new_item(const char *name, const char *description) } /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : int free_item(ITEM *item) -| -| Description : Free the allocated storage for this item. +| +| Description : Free the allocated storage for this item. | N.B.: a connected item can't be freed. | | Return Values : E_OK - success | E_BAD_ARGUMENT - invalid value has been passed -| E_CONNECTED - item is still connected to a menu +| E_CONNECTED - item is still connected to a menu +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -free_item(ITEM * item) +MENU_EXPORT(int) +free_item(ITEM *item) { T((T_CALLED("free_item(%p)"), (void *)item)); @@ -177,24 +179,24 @@ free_item(ITEM * item) } /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : int set_menu_mark( MENU *menu, const char *mark ) -| +| | Description : Set the mark string used to indicate the current | item (single-valued menu) or the selected items | (multi-valued menu). -| The mark argument may be NULL, in which case no +| The mark argument may be NULL, in which case no | marker is used. -| This might be a little bit tricky, because this may -| affect the geometry of the menu, which we don't allow +| This might be a little bit tricky, because this may +| affect the geometry of the menu, which we don't allow | if it is already posted. | | Return Values : E_OK - success | E_BAD_ARGUMENT - an invalid value has been passed | E_SYSTEM_ERROR - no memory to store mark +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -set_menu_mark(MENU * menu, const char *mark) +MENU_EXPORT(int) +set_menu_mark(MENU *menu, const char *mark) { short l; @@ -258,15 +260,15 @@ set_menu_mark(MENU * menu, const char *mark) } /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : char *menu_mark(const MENU *menu) -| +| | Description : Return a pointer to the marker string | | Return Values : The marker string pointer or NULL if no marker defined +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(const char *) -menu_mark(const MENU * menu) +MENU_EXPORT(const char *) +menu_mark(const MENU *menu) { T((T_CALLED("menu_mark(%p)"), (const void *)menu)); returnPtr(Normalize_Menu(menu)->mark); diff --git a/menu/m_item_opt.c b/menu/m_item_opt.c index f8df220..495e409 100644 --- a/menu/m_item_opt.c +++ b/menu/m_item_opt.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 1998-2004,2010 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,12 +38,12 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_item_opt.c,v 1.19 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_item_opt.c,v 1.22 2021/06/17 21:20:30 tom Exp $") /*--------------------------------------------------------------------------- -| Facility : libnmenu -| Function : int set_item_opts(ITEM *item, Item_Options opts) -| +| Facility : libnmenu +| Function : int set_item_opts(ITEM *item, Item_Options opts) +| | Description : Set the options of the item. If there are relevant | changes, the item is connected and the menu is posted, | the menu will be redisplayed. @@ -51,8 +51,8 @@ MODULE_ID("$Id: m_item_opt.c,v 1.19 2020/02/02 23:34:34 tom Exp $") | Return Values : E_OK - success | E_BAD_ARGUMENT - invalid item options +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -set_item_opts(ITEM * item, Item_Options opts) +MENU_EXPORT(int) +set_item_opts(ITEM *item, Item_Options opts) { T((T_CALLED("set_menu_opts(%p,%d)"), (void *)item, opts)); @@ -86,16 +86,16 @@ set_item_opts(ITEM * item, Item_Options opts) } /*--------------------------------------------------------------------------- -| Facility : libnmenu -| Function : int item_opts_off(ITEM *item, Item_Options opts) -| +| Facility : libnmenu +| Function : int item_opts_off(ITEM *item, Item_Options opts) +| | Description : Switch of the options for this item. | | Return Values : E_OK - success | E_BAD_ARGUMENT - invalid options +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -item_opts_off(ITEM * item, Item_Options opts) +MENU_EXPORT(int) +item_opts_off(ITEM *item, Item_Options opts) { ITEM *citem = item; /* use a copy because set_item_opts must detect @@ -114,16 +114,16 @@ item_opts_off(ITEM * item, Item_Options opts) } /*--------------------------------------------------------------------------- -| Facility : libnmenu -| Function : int item_opts_on(ITEM *item, Item_Options opts) -| +| Facility : libnmenu +| Function : int item_opts_on(ITEM *item, Item_Options opts) +| | Description : Switch on the options for this item. | | Return Values : E_OK - success | E_BAD_ARGUMENT - invalid options +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -item_opts_on(ITEM * item, Item_Options opts) +MENU_EXPORT(int) +item_opts_on(ITEM *item, Item_Options opts) { ITEM *citem = item; /* use a copy because set_item_opts must detect @@ -143,15 +143,15 @@ item_opts_on(ITEM * item, Item_Options opts) } /*--------------------------------------------------------------------------- -| Facility : libnmenu -| Function : Item_Options item_opts(const ITEM *item) -| +| Facility : libnmenu +| Function : Item_Options item_opts(const ITEM *item) +| | Description : Switch of the options for this item. | | Return Values : Items options +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(Item_Options) -item_opts(const ITEM * item) +MENU_EXPORT(Item_Options) +item_opts(const ITEM *item) { T((T_CALLED("item_opts(%p)"), (const void *)item)); returnItemOpts(ALL_ITEM_OPTS & Normalize_Item(item)->opt); diff --git a/menu/m_item_top.c b/menu/m_item_top.c index 9417e72..68303c7 100644 --- a/menu/m_item_top.c +++ b/menu/m_item_top.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 1998-2004,2010 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,30 +38,28 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_item_top.c,v 1.12 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_item_top.c,v 1.16 2021/06/17 21:11:08 tom Exp $") /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : int set_top_row(MENU *menu, int row) -| +| | Description : Makes the specified row the top row in the menu | | Return Values : E_OK - success | E_BAD_ARGUMENT - not a menu pointer or invalid row | E_NOT_CONNECTED - there are no items for the menu +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -set_top_row(MENU * menu, int row) +MENU_EXPORT(int) +set_top_row(MENU *menu, int row) { - ITEM *item; - T((T_CALLED("set_top_row(%p,%d)"), (void *)menu, row)); if (menu) { if (menu->status & _IN_DRIVER) RETURN(E_BAD_STATE); - if (menu->items == (ITEM **) 0) + if (menu->items == (ITEM **)0) RETURN(E_NOT_CONNECTED); if ((row < 0) || (row > (menu->rows - menu->arows))) @@ -72,6 +70,8 @@ set_top_row(MENU * menu, int row) if (row != menu->toprow) { + ITEM *item; + if (menu->status & _LINK_NEEDED) _nc_Link_Items(menu); @@ -85,15 +85,15 @@ set_top_row(MENU * menu, int row) } /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : int top_row(const MENU *) -| +| | Description : Return the top row of the menu | | Return Values : The row number or ERR if there is no row +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -top_row(const MENU * menu) +MENU_EXPORT(int) +top_row(const MENU *menu) { T((T_CALLED("top_row(%p)"), (const void *)menu)); if (menu && menu->items && *(menu->items)) diff --git a/menu/m_item_use.c b/menu/m_item_use.c index 3081432..52d087e 100644 --- a/menu/m_item_use.c +++ b/menu/m_item_use.c @@ -38,7 +38,7 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_item_use.c,v 1.19 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_item_use.c,v 1.21 2020/12/12 00:38:08 tom Exp $") /*--------------------------------------------------------------------------- | Facility : libnmenu @@ -49,8 +49,8 @@ MODULE_ID("$Id: m_item_use.c,v 1.19 2020/02/02 23:34:34 tom Exp $") | | Return Values : E_OK - success +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -set_item_userptr(ITEM * item, void *userptr) +MENU_EXPORT(int) +set_item_userptr(ITEM *item, void *userptr) { T((T_CALLED("set_item_userptr(%p,%p)"), (void *)item, (void *)userptr)); Normalize_Item(item)->userptr = userptr; @@ -67,8 +67,8 @@ set_item_userptr(ITEM * item, void *userptr) | Return Values : Value of the pointer. If no such pointer has been set, | NULL is returned. +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(void *) -item_userptr(const ITEM * item) +MENU_EXPORT(void *) +item_userptr(const ITEM *item) { T((T_CALLED("item_userptr(%p)"), (const void *)item)); returnVoidPtr(Normalize_Item(item)->userptr); diff --git a/menu/m_item_val.c b/menu/m_item_val.c index d8d11f2..3163f4b 100644 --- a/menu/m_item_val.c +++ b/menu/m_item_val.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 1998-2004,2010 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,30 +38,28 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_item_val.c,v 1.16 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_item_val.c,v 1.20 2021/06/17 21:11:08 tom Exp $") /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : int set_item_value(ITEM *item, int value) -| +| | Description : Programmatically set the item's selection value. This is | only allowed if the item is selectable at all and if | it is not connected to a single-valued menu. | If the item is connected to a posted menu, the menu -| will be redisplayed. +| will be redisplayed. | | Return Values : E_OK - success | E_REQUEST_DENIED - not selectable or single valued menu +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -set_item_value(ITEM * item, bool value) +MENU_EXPORT(int) +set_item_value(ITEM *item, bool value) { - MENU *menu; - T((T_CALLED("set_item_value(%p,%d)"), (void *)item, value)); if (item) { - menu = item->imenu; + MENU *menu = item->imenu; if ((!(item->opt & O_SELECTABLE)) || (menu && (menu->opt & O_ONEVALUE))) @@ -87,16 +85,16 @@ set_item_value(ITEM * item, bool value) } /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : bool item_value(const ITEM *item) -| +| | Description : Return the selection value of the item | | Return Values : TRUE - if item is selected | FALSE - if item is not selected +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(bool) -item_value(const ITEM * item) +MENU_EXPORT(bool) +item_value(const ITEM *item) { T((T_CALLED("item_value(%p)"), (const void *)item)); returnBool((Normalize_Item(item)->value) ? TRUE : FALSE); diff --git a/menu/m_item_vis.c b/menu/m_item_vis.c index 8e99341..9ae4fdb 100644 --- a/menu/m_item_vis.c +++ b/menu/m_item_vis.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 1998-2004,2010 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,20 +38,20 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_item_vis.c,v 1.17 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_item_vis.c,v 1.20 2021/06/17 21:20:30 tom Exp $") /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : bool item_visible(const ITEM *item) -| +| | Description : A item is visible if it currently appears in the | subwindow of a posted menu. | | Return Values : TRUE if visible | FALSE if invisible +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(bool) -item_visible(const ITEM * item) +MENU_EXPORT(bool) +item_visible(const ITEM *item) { MENU *menu; diff --git a/menu/m_items.c b/menu/m_items.c index 9f46c8b..ecc5e2f 100644 --- a/menu/m_items.c +++ b/menu/m_items.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 1998-2005,2010 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,12 +38,12 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_items.c,v 1.18 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_items.c,v 1.21 2021/06/17 21:20:30 tom Exp $") /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : int set_menu_items(MENU *menu, ITEM **items) -| +| | Description : Sets the item pointer array connected to menu. | | Return Values : E_OK - success @@ -53,8 +53,8 @@ MODULE_ID("$Id: m_items.c,v 1.18 2020/02/02 23:34:34 tom Exp $") | E_BAD_ARGUMENT - An incorrect menu or item array was | passed to the function +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -set_menu_items(MENU * menu, ITEM ** items) +MENU_EXPORT(int) +set_menu_items(MENU *menu, ITEM **items) { T((T_CALLED("set_menu_items(%p,%p)"), (void *)menu, (void *)items)); @@ -78,31 +78,31 @@ set_menu_items(MENU * menu, ITEM ** items) } /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : ITEM **menu_items(const MENU *menu) -| +| | Description : Returns a pointer to the item pointer array of the menu | | Return Values : NULL on error +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(ITEM **) -menu_items(const MENU * menu) +MENU_EXPORT(ITEM **) +menu_items(const MENU *menu) { T((T_CALLED("menu_items(%p)"), (const void *)menu)); - returnItemPtr(menu ? menu->items : (ITEM **) 0); + returnItemPtr(menu ? menu->items : (ITEM **)0); } /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : int item_count(const MENU *menu) -| +| | Description : Get the number of items connected to the menu. If the -| menu pointer is NULL we return -1. +| menu pointer is NULL we return -1. | | Return Values : Number of items or -1 to indicate error. +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -item_count(const MENU * menu) +MENU_EXPORT(int) +item_count(const MENU *menu) { T((T_CALLED("item_count(%p)"), (const void *)menu)); returnCode(menu ? menu->nitems : -1); diff --git a/menu/m_new.c b/menu/m_new.c index cf89196..be17558 100644 --- a/menu/m_new.c +++ b/menu/m_new.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 1998-2009,2010 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,12 +38,12 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_new.c,v 1.22 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_new.c,v 1.27 2021/06/17 21:26:02 tom Exp $") /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : MENU* _nc_new_menu(SCREEN*, ITEM **items) -| +| | Description : Creates a new menu connected to the item pointer | array items and returns a pointer to the new menu. | The new menu is initialized with the values from the @@ -51,8 +51,8 @@ MODULE_ID("$Id: m_new.c,v 1.22 2020/02/02 23:34:34 tom Exp $") | | Return Values : NULL on error +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(MENU *) -NCURSES_SP_NAME(new_menu) (NCURSES_SP_DCLx ITEM ** items) +MENU_EXPORT(MENU *) +NCURSES_SP_NAME(new_menu) (NCURSES_SP_DCLx ITEM **items) { int err = E_SYSTEM_ERROR; MENU *menu = typeCalloc(MENU, 1); @@ -60,6 +60,7 @@ NCURSES_SP_NAME(new_menu) (NCURSES_SP_DCLx ITEM ** items) T((T_CALLED("new_menu(%p,%p)"), (void *)SP_PARM, (void *)items)); if (menu) { + T((T_CREATE("menu %p"), (void *)menu)); *menu = _nc_Default_Menu; menu->status = 0; menu->rows = menu->frows; @@ -77,7 +78,7 @@ NCURSES_SP_NAME(new_menu) (NCURSES_SP_DCLx ITEM ** items) { err = E_NOT_CONNECTED; free(menu); - menu = (MENU *) 0; + menu = (MENU *)0; } else err = E_OK; @@ -91,9 +92,9 @@ NCURSES_SP_NAME(new_menu) (NCURSES_SP_DCLx ITEM ** items) } /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : MENU *new_menu(ITEM **items) -| +| | Description : Creates a new menu connected to the item pointer | array items and returns a pointer to the new menu. | The new menu is initialized with the values from the @@ -102,26 +103,26 @@ NCURSES_SP_NAME(new_menu) (NCURSES_SP_DCLx ITEM ** items) | Return Values : NULL on error +--------------------------------------------------------------------------*/ #if NCURSES_SP_FUNCS -NCURSES_EXPORT(MENU *) -new_menu(ITEM ** items) +MENU_EXPORT(MENU *) +new_menu(ITEM **items) { return NCURSES_SP_NAME(new_menu) (CURRENT_SCREEN, items); } #endif /*--------------------------------------------------------------------------- -| Facility : libnmenu -| Function : int free_menu(MENU *menu) -| -| Description : Disconnects menu from its associated item pointer +| Facility : libnmenu +| Function : int free_menu(MENU *menu) +| +| Description : Disconnects menu from its associated item pointer | array and frees the storage allocated for the menu. | | Return Values : E_OK - success | E_BAD_ARGUMENT - Invalid menu pointer passed | E_POSTED - Menu is already posted +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -free_menu(MENU * menu) +MENU_EXPORT(int) +free_menu(MENU *menu) { T((T_CALLED("free_menu(%p)"), (void *)menu)); if (!menu) diff --git a/menu/m_opts.c b/menu/m_opts.c index 4c29f33..bbf9459 100644 --- a/menu/m_opts.c +++ b/menu/m_opts.c @@ -38,7 +38,7 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_opts.c,v 1.21 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_opts.c,v 1.23 2020/12/12 00:38:08 tom Exp $") /*--------------------------------------------------------------------------- | Facility : libnmenu @@ -53,8 +53,8 @@ MODULE_ID("$Id: m_opts.c,v 1.21 2020/02/02 23:34:34 tom Exp $") | E_BAD_ARGUMENT - invalid menu options | E_POSTED - menu is already posted +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -set_menu_opts(MENU * menu, Menu_Options opts) +MENU_EXPORT(int) +set_menu_opts(MENU *menu, Menu_Options opts) { T((T_CALLED("set_menu_opts(%p,%d)"), (void *)menu, opts)); @@ -86,7 +86,7 @@ set_menu_opts(MENU * menu, Menu_Options opts) { ITEM **item; - if (((item = menu->items) != (ITEM **) 0)) + if (((item = menu->items) != (ITEM **)0)) for (; *item; item++) (*item)->value = FALSE; } @@ -113,8 +113,8 @@ set_menu_opts(MENU * menu, Menu_Options opts) | E_BAD_ARGUMENT - invalid options | E_POSTED - menu is already posted +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -menu_opts_off(MENU * menu, Menu_Options opts) +MENU_EXPORT(int) +menu_opts_off(MENU *menu, Menu_Options opts) { MENU *cmenu = menu; /* use a copy because set_menu_opts must detect @@ -146,8 +146,8 @@ menu_opts_off(MENU * menu, Menu_Options opts) | E_BAD_ARGUMENT - invalid menu options | E_POSTED - menu is already posted +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -menu_opts_on(MENU * menu, Menu_Options opts) +MENU_EXPORT(int) +menu_opts_on(MENU *menu, Menu_Options opts) { MENU *cmenu = menu; /* use a copy because set_menu_opts must detect @@ -174,8 +174,8 @@ menu_opts_on(MENU * menu, Menu_Options opts) | | Return Values : Menu options +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(Menu_Options) -menu_opts(const MENU * menu) +MENU_EXPORT(Menu_Options) +menu_opts(const MENU *menu) { T((T_CALLED("menu_opts(%p)"), (const void *)menu)); returnMenuOpts(ALL_MENU_OPTS & Normalize_Menu(menu)->opt); diff --git a/menu/m_pad.c b/menu/m_pad.c index 3d5702a..008e19a 100644 --- a/menu/m_pad.c +++ b/menu/m_pad.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 1998-2010,2012 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,7 +38,7 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_pad.c,v 1.14 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_pad.c,v 1.17 2021/06/17 21:20:30 tom Exp $") /* Macro to redraw menu if it is posted and changed */ #define Refresh_Menu(menu) \ @@ -49,20 +49,20 @@ MODULE_ID("$Id: m_pad.c,v 1.14 2020/02/02 23:34:34 tom Exp $") } /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : int set_menu_pad(MENU* menu, int pad) -| +| | Description : Set the character to be used to separate the item name -| from its description. This must be a printable +| from its description. This must be a printable | character. | | Return Values : E_OK - success | E_BAD_ARGUMENT - an invalid value has been passed +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -set_menu_pad(MENU * menu, int pad) +MENU_EXPORT(int) +set_menu_pad(MENU *menu, int pad) { - bool do_refresh = (menu != (MENU *) 0); + bool do_refresh = (menu != (MENU *)0); T((T_CALLED("set_menu_pad(%p,%d)"), (void *)menu, pad)); @@ -79,15 +79,15 @@ set_menu_pad(MENU * menu, int pad) } /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : int menu_pad(const MENU *menu) -| +| | Description : Return the value of the padding character | | Return Values : The pad character +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -menu_pad(const MENU * menu) +MENU_EXPORT(int) +menu_pad(const MENU *menu) { T((T_CALLED("menu_pad(%p)"), (const void *)menu)); returnCode(Normalize_Menu(menu)->pad); diff --git a/menu/m_pattern.c b/menu/m_pattern.c index 9ff0230..6fbef23 100644 --- a/menu/m_pattern.c +++ b/menu/m_pattern.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 1998-2006,2010 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,12 +38,12 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_pattern.c,v 1.17 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_pattern.c,v 1.20 2021/06/17 21:20:30 tom Exp $") /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : char *menu_pattern(const MENU *menu) -| +| | Description : Return the value of the pattern buffer. | | Return Values : NULL - if there is no pattern buffer allocated @@ -51,8 +51,8 @@ MODULE_ID("$Id: m_pattern.c,v 1.17 2020/02/02 23:34:34 tom Exp $") | pattern is stored | PatternString - as expected +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(char *) -menu_pattern(const MENU * menu) +MENU_EXPORT(char *) +menu_pattern(const MENU *menu) { static char empty[] = ""; @@ -61,9 +61,9 @@ menu_pattern(const MENU * menu) } /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : int set_menu_pattern(MENU *menu, const char *p) -| +| | Description : Set the match pattern for a menu and position to the | first item that matches. | @@ -73,8 +73,8 @@ menu_pattern(const MENU * menu) | E_NOT_CONNECTED - no items connected to menu | E_NO_MATCH - no item matches pattern +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -set_menu_pattern(MENU * menu, const char *p) +MENU_EXPORT(int) +set_menu_pattern(MENU *menu, const char *p) { ITEM *matchitem; int matchpos; diff --git a/menu/m_post.c b/menu/m_post.c index 2cc0ea0..1dbd6b8 100644 --- a/menu/m_post.c +++ b/menu/m_post.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 1998-2010,2012 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,7 +38,7 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_post.c,v 1.32 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_post.c,v 1.36 2021/05/08 20:20:01 tom Exp $") /*--------------------------------------------------------------------------- | Facility : libnmenu @@ -49,8 +49,8 @@ MODULE_ID("$Id: m_post.c,v 1.32 2020/02/02 23:34:34 tom Exp $") | | Return Values : - +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(void) -_nc_Post_Item(const MENU * menu, const ITEM * item) +MENU_EXPORT(void) +_nc_Post_Item(const MENU *menu, const ITEM *item) { int i; chtype ch; @@ -58,7 +58,6 @@ _nc_Post_Item(const MENU * menu, const ITEM * item) int count = 0; bool isfore = FALSE, isback = FALSE, isgrey = FALSE; int name_len; - int desc_len; assert(menu->win); @@ -132,6 +131,7 @@ _nc_Post_Item(const MENU * menu, const ITEM * item) { int m = menu->spc_desc / 2; int cy = -1, cx = -1; + int desc_len; for (ch = ' ', i = 0; i < menu->spc_desc; i++) { @@ -197,11 +197,11 @@ _nc_Post_Item(const MENU * menu, const ITEM * item) | | Return Values : - +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(void) -_nc_Draw_Menu(const MENU * menu) +MENU_EXPORT(void) +_nc_Draw_Menu(const MENU *menu) { ITEM *item = menu->items[0]; - ITEM *lasthor, *lastvert; + ITEM *lastvert; ITEM *hitem; int y = 0; chtype s_bkgd; @@ -213,45 +213,50 @@ _nc_Draw_Menu(const MENU * menu) werase(menu->win); wbkgdset(menu->win, s_bkgd); - lastvert = (menu->opt & O_NONCYCLIC) ? (ITEM *) 0 : item; + lastvert = (menu->opt & O_NONCYCLIC) ? (ITEM *)0 : item; - do + if (item != NULL) { - wmove(menu->win, y, 0); - - hitem = item; - lasthor = (menu->opt & O_NONCYCLIC) ? (ITEM *) 0 : hitem; - do { - _nc_Post_Item(menu, hitem); + ITEM *lasthor; - wattron(menu->win, (int)menu->back); - if (((hitem = hitem->right) != lasthor) && hitem) + wmove(menu->win, y, 0); + + hitem = item; + lasthor = (menu->opt & O_NONCYCLIC) ? (ITEM *)0 : hitem; + + do { - int i, j, cy, cx; - chtype ch = ' '; + _nc_Post_Item(menu, hitem); - getyx(menu->win, cy, cx); - for (j = 0; j < menu->spc_rows; j++) + wattron(menu->win, (int)menu->back); + if (((hitem = hitem->right) != lasthor) && hitem) { - wmove(menu->win, cy + j, cx); - for (i = 0; i < menu->spc_cols; i++) + int i, j, cy, cx; + chtype ch = ' '; + + getyx(menu->win, cy, cx); + for (j = 0; j < menu->spc_rows; j++) { - waddch(menu->win, ch); + wmove(menu->win, cy + j, cx); + for (i = 0; i < menu->spc_cols; i++) + { + waddch(menu->win, ch); + } } + wmove(menu->win, cy, cx + menu->spc_cols); } - wmove(menu->win, cy, cx + menu->spc_cols); } - } - while (hitem && (hitem != lasthor)); - wattroff(menu->win, (int)menu->back); + while (hitem && (hitem != lasthor)); + wattroff(menu->win, (int)menu->back); - item = item->down; - y += menu->spc_rows; + item = item->down; + y += menu->spc_rows; + } + while (item && (item != lastvert)); } - while (item && (item != lastvert)); } /*--------------------------------------------------------------------------- @@ -267,8 +272,8 @@ _nc_Draw_Menu(const MENU * menu) | E_BAD_STATE - Menu in userexit routine | E_POSTED - Menu already posted +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -post_menu(MENU * menu) +MENU_EXPORT(int) +post_menu(MENU *menu) { T((T_CALLED("post_menu(%p)"), (void *)menu)); @@ -283,7 +288,6 @@ post_menu(MENU * menu) if (menu->items && *(menu->items)) { - int y; int h = 1 + menu->spc_rows * (menu->rows - 1); WINDOW *win = Get_Menu_Window(menu); @@ -291,7 +295,8 @@ post_menu(MENU * menu) if ((menu->win = newpad(h, menu->width))) { - y = (maxy >= h) ? h : maxy; + int y = (maxy >= h) ? h : maxy; + if (y >= menu->height) y = menu->height; if (!(menu->sub = subpad(menu->win, y, menu->width, 0, 0))) @@ -339,8 +344,8 @@ post_menu(MENU * menu) | E_BAD_STATE - menu in userexit routine | E_NOT_POSTED - menu is not posted +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -unpost_menu(MENU * menu) +MENU_EXPORT(int) +unpost_menu(MENU *menu) { WINDOW *win; diff --git a/menu/m_req_name.c b/menu/m_req_name.c index d3f04c1..c72116f 100644 --- a/menu/m_req_name.c +++ b/menu/m_req_name.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 1998-2012,2015 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,7 +38,7 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_req_name.c,v 1.24 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_req_name.c,v 1.27 2021/06/17 21:11:08 tom Exp $") #define DATA(s) { s } @@ -66,15 +66,15 @@ static const char request_names[MAX_MENU_COMMAND - MIN_MENU_COMMAND + 1][14] = #define A_SIZE (sizeof(request_names)/sizeof(request_names[0])) /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : const char * menu_request_name (int request); -| +| | Description : Get the external name of a menu request. | | Return Values : Pointer to name - on success | NULL - on invalid request code +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(const char *) +MENU_EXPORT(const char *) menu_request_name(int request) { T((T_CALLED("menu_request_name(%d)"), request)); @@ -88,27 +88,28 @@ menu_request_name(int request) } /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : int menu_request_by_name (const char *str); -| +| | Description : Search for a request with this name. | | Return Values : Request Id - on success | E_NO_MATCH - request not found +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) +MENU_EXPORT(int) menu_request_by_name(const char *str) { /* because the table is so small, it doesn't really hurt to run sequentially through it. */ size_t i = 0; - char buf[16]; T((T_CALLED("menu_request_by_name(%s)"), _nc_visbuf(str))); if (str != 0 && (i = strlen(str)) != 0) { + char buf[16]; + if (i > sizeof(buf) - 2) i = sizeof(buf) - 2; memcpy(buf, str, i); diff --git a/menu/m_scale.c b/menu/m_scale.c index e013acd..9e7f81d 100644 --- a/menu/m_scale.c +++ b/menu/m_scale.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 1998-2004,2010 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,21 +38,21 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_scale.c,v 1.11 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_scale.c,v 1.14 2021/06/17 21:20:30 tom Exp $") /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : int scale_menu(const MENU *menu) -| +| | Description : Returns the minimum window size necessary for the -| subwindow of menu. +| subwindow of menu. | | Return Values : E_OK - success | E_BAD_ARGUMENT - invalid menu pointer | E_NOT_CONNECTED - no items are connected to menu +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -scale_menu(const MENU * menu, int *rows, int *cols) +MENU_EXPORT(int) +scale_menu(const MENU *menu, int *rows, int *cols) { T((T_CALLED("scale_menu(%p,%p,%p)"), (const void *)menu, diff --git a/menu/m_spacing.c b/menu/m_spacing.c index 9bb746a..76f8d5c 100644 --- a/menu/m_spacing.c +++ b/menu/m_spacing.c @@ -38,7 +38,7 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_spacing.c,v 1.20 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_spacing.c,v 1.22 2020/12/12 00:38:14 tom Exp $") #define MAX_SPC_DESC ((TABSIZE) ? (TABSIZE) : 8) #define MAX_SPC_COLS ((TABSIZE) ? (TABSIZE) : 8) @@ -52,8 +52,8 @@ MODULE_ID("$Id: m_spacing.c,v 1.20 2020/02/02 23:34:34 tom Exp $") | | Return Values : E_OK - on success +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -set_menu_spacing(MENU * menu, int s_desc, int s_row, int s_col) +MENU_EXPORT(int) +set_menu_spacing(MENU *menu, int s_desc, int s_row, int s_col) { MENU *m; /* split for ATAC workaround */ @@ -87,8 +87,8 @@ set_menu_spacing(MENU * menu, int s_desc, int s_row, int s_col) | | Return Values : E_OK - on success +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -menu_spacing(const MENU * menu, int *s_desc, int *s_row, int *s_col) +MENU_EXPORT(int) +menu_spacing(const MENU *menu, int *s_desc, int *s_row, int *s_col) { const MENU *m; /* split for ATAC workaround */ diff --git a/menu/m_sub.c b/menu/m_sub.c index 4658e90..a055245 100644 --- a/menu/m_sub.c +++ b/menu/m_sub.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 1998-2009,2010 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,19 +38,19 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_sub.c,v 1.13 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_sub.c,v 1.16 2021/06/17 21:20:30 tom Exp $") /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : int set_menu_sub(MENU *menu, WINDOW *win) -| +| | Description : Sets the subwindow of the menu. | | Return Values : E_OK - success | E_POSTED - menu is already posted +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -set_menu_sub(MENU * menu, WINDOW *win) +MENU_EXPORT(int) +set_menu_sub(MENU *menu, WINDOW *win) { T((T_CALLED("set_menu_sub(%p,%p)"), (void *)menu, (void *)win)); @@ -82,15 +82,15 @@ set_menu_sub(MENU * menu, WINDOW *win) } /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : WINDOW* menu_sub(const MENU *menu) -| +| | Description : Returns a pointer to the subwindow of the menu | | Return Values : NULL on error, otherwise a pointer to the window +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(WINDOW *) -menu_sub(const MENU * menu) +MENU_EXPORT(WINDOW *) +menu_sub(const MENU *menu) { const MENU *m = Normalize_Menu(menu); diff --git a/menu/m_trace.c b/menu/m_trace.c index f5332b1..331236c 100644 --- a/menu/m_trace.c +++ b/menu/m_trace.c @@ -33,37 +33,37 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_trace.c,v 1.7 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_trace.c,v 1.9 2020/12/12 00:38:14 tom Exp $") -NCURSES_EXPORT(ITEM *) -_nc_retrace_item(ITEM * code) +MENU_EXPORT(ITEM *) +_nc_retrace_item(ITEM *code) { T((T_RETURN("%p"), (void *)code)); return code; } -NCURSES_EXPORT(ITEM **) -_nc_retrace_item_ptr(ITEM ** code) +MENU_EXPORT(ITEM **) +_nc_retrace_item_ptr(ITEM **code) { T((T_RETURN("%p"), (void *)code)); return code; } -NCURSES_EXPORT(Item_Options) +MENU_EXPORT(Item_Options) _nc_retrace_item_opts(Item_Options code) { T((T_RETURN("%d"), code)); return code; } -NCURSES_EXPORT(MENU *) -_nc_retrace_menu(MENU * code) +MENU_EXPORT(MENU *) +_nc_retrace_menu(MENU *code) { T((T_RETURN("%p"), (void *)code)); return code; } -NCURSES_EXPORT(Menu_Hook) +MENU_EXPORT(Menu_Hook) _nc_retrace_menu_hook(Menu_Hook code) { TR_FUNC_BFR(1); @@ -71,7 +71,7 @@ _nc_retrace_menu_hook(Menu_Hook code) return code; } -NCURSES_EXPORT(Menu_Options) +MENU_EXPORT(Menu_Options) _nc_retrace_menu_opts(Menu_Options code) { T((T_RETURN("%d"), code)); diff --git a/menu/m_userptr.c b/menu/m_userptr.c index df3a45f..72f2d4c 100644 --- a/menu/m_userptr.c +++ b/menu/m_userptr.c @@ -38,7 +38,7 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_userptr.c,v 1.19 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_userptr.c,v 1.21 2020/12/12 00:38:14 tom Exp $") /*--------------------------------------------------------------------------- | Facility : libnmenu @@ -49,8 +49,8 @@ MODULE_ID("$Id: m_userptr.c,v 1.19 2020/02/02 23:34:34 tom Exp $") | | Return Values : E_OK - success +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -set_menu_userptr(MENU * menu, void *userptr) +MENU_EXPORT(int) +set_menu_userptr(MENU *menu, void *userptr) { T((T_CALLED("set_menu_userptr(%p,%p)"), (void *)menu, (void *)userptr)); Normalize_Menu(menu)->userptr = userptr; @@ -67,8 +67,8 @@ set_menu_userptr(MENU * menu, void *userptr) | Return Values : Value of the pointer. If no such pointer has been set, | NULL is returned +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(void *) -menu_userptr(const MENU * menu) +MENU_EXPORT(void *) +menu_userptr(const MENU *menu) { T((T_CALLED("menu_userptr(%p)"), (const void *)menu)); returnVoidPtr(Normalize_Menu(menu)->userptr); diff --git a/menu/m_win.c b/menu/m_win.c index f06c580..4bb64e6 100644 --- a/menu/m_win.c +++ b/menu/m_win.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 1998-2009,2010 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -38,19 +38,19 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_win.c,v 1.18 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: m_win.c,v 1.21 2021/06/17 21:20:30 tom Exp $") /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : int set_menu_win(MENU *menu, WINDOW *win) -| +| | Description : Sets the window of the menu. | | Return Values : E_OK - success | E_POSTED - menu is already posted +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -set_menu_win(MENU * menu, WINDOW *win) +MENU_EXPORT(int) +set_menu_win(MENU *menu, WINDOW *win) { T((T_CALLED("set_menu_win(%p,%p)"), (void *)menu, (void *)win)); @@ -82,15 +82,15 @@ set_menu_win(MENU * menu, WINDOW *win) } /*--------------------------------------------------------------------------- -| Facility : libnmenu +| Facility : libnmenu | Function : WINDOW* menu_win(const MENU*) -| +| | Description : Returns pointer to the window of the menu | | Return Values : NULL on error, otherwise pointer to window +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(WINDOW *) -menu_win(const MENU * menu) +MENU_EXPORT(WINDOW *) +menu_win(const MENU *menu) { const MENU *m = Normalize_Menu(menu); diff --git a/menu/menu.h b/menu/menu.h index b2e845c..e5a5372 100644 --- a/menu/menu.h +++ b/menu/menu.h @@ -31,7 +31,7 @@ * Author: Juergen Pfeifer, 1995,1997 * ****************************************************************************/ -/* $Id: menu.h,v 1.24 2020/02/02 23:34:34 tom Exp $ */ +/* $Id: menu.h,v 1.26 2020/12/12 00:38:02 tom Exp $ */ #ifndef ETI_MENU #define ETI_MENU @@ -44,11 +44,23 @@ #include <eti.h> #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif -typedef int Menu_Options; -typedef int Item_Options; +#if defined(BUILDING_MENU) +# define MENU_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT +#else +# define MENU_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT +#endif + +#define MENU_WRAPPED_VAR(type,name) extern MENU_IMPEXP type NCURSES_PUBLIC_VAR(name)(void) + +#define MENU_EXPORT(type) MENU_IMPEXP type NCURSES_API +#define MENU_EXPORT_VAR(type) MENU_IMPEXP type + + typedef int Menu_Options; + typedef int Item_Options; /* Menu options: */ #define O_ONEVALUE (0x01) @@ -63,85 +75,85 @@ typedef int Item_Options; #define O_SELECTABLE (0x01) #if !NCURSES_OPAQUE_MENU -typedef struct -{ - const char* str; - unsigned short length; -} TEXT; -#endif /* !NCURSES_OPAQUE_MENU */ + typedef struct + { + const char *str; + unsigned short length; + } + TEXT; +#endif /* !NCURSES_OPAQUE_MENU */ -struct tagMENU; + struct tagMENU; -typedef struct tagITEM + typedef struct tagITEM #if !NCURSES_OPAQUE_MENU -{ - TEXT name; /* name of menu item */ - TEXT description; /* description of item, optional in display */ - struct tagMENU *imenu; /* Pointer to parent menu */ - void *userptr; /* Pointer to user defined per item data */ - Item_Options opt; /* Item options */ - short index; /* Item number if connected to a menu */ - short y; /* y and x location of item in menu */ - short x; - bool value; /* Selection value */ - - struct tagITEM *left; /* neighbor items */ - struct tagITEM *right; - struct tagITEM *up; - struct tagITEM *down; - -} -#endif /* !NCURSES_OPAQUE_MENU */ -ITEM; - -typedef void (*Menu_Hook)(struct tagMENU *); - -typedef struct tagMENU -#if 1 /* not yet: !NCURSES_OPAQUE_MENU */ -{ - short height; /* Nr. of chars high */ - short width; /* Nr. of chars wide */ - short rows; /* Nr. of items high */ - short cols; /* Nr. of items wide */ - short frows; /* Nr. of formatted items high */ - short fcols; /* Nr. of formatted items wide */ - short arows; /* Nr. of items high (actual) */ - short namelen; /* Max. name length */ - short desclen; /* Max. description length */ - short marklen; /* Length of mark, if any */ - short itemlen; /* Length of one item */ - short spc_desc; /* Spacing for descriptor */ - short spc_cols; /* Spacing for columns */ - short spc_rows; /* Spacing for rows */ - char *pattern; /* Buffer to store match chars */ - short pindex; /* Index into pattern buffer */ - WINDOW *win; /* Window containing menu */ - WINDOW *sub; /* Subwindow for menu display */ - WINDOW *userwin; /* User's window */ - WINDOW *usersub; /* User's subwindow */ - ITEM **items; /* array of items */ - short nitems; /* Nr. of items in menu */ - ITEM *curitem; /* Current item */ - short toprow; /* Top row of menu */ - chtype fore; /* Selection attribute */ - chtype back; /* Nonselection attribute */ - chtype grey; /* Inactive attribute */ - unsigned char pad; /* Pad character */ - - Menu_Hook menuinit; /* User hooks */ - Menu_Hook menuterm; - Menu_Hook iteminit; - Menu_Hook itemterm; - - void *userptr; /* Pointer to menus user data */ - char *mark; /* Pointer to marker string */ - - Menu_Options opt; /* Menu options */ - unsigned short status; /* Internal state of menu */ -} -#endif /* !NCURSES_OPAQUE_MENU */ -MENU; - + { + TEXT name; /* name of menu item */ + TEXT description; /* description of item, optional in display */ + struct tagMENU *imenu; /* Pointer to parent menu */ + void *userptr; /* Pointer to user defined per item data */ + Item_Options opt; /* Item options */ + short index; /* Item number if connected to a menu */ + short y; /* y and x location of item in menu */ + short x; + bool value; /* Selection value */ + + struct tagITEM *left; /* neighbor items */ + struct tagITEM *right; + struct tagITEM *up; + struct tagITEM *down; + + } +#endif /* !NCURSES_OPAQUE_MENU */ + ITEM; + + typedef void (*Menu_Hook) (struct tagMENU *); + + typedef struct tagMENU +#if 1 /* not yet: !NCURSES_OPAQUE_MENU */ + { + short height; /* Nr. of chars high */ + short width; /* Nr. of chars wide */ + short rows; /* Nr. of items high */ + short cols; /* Nr. of items wide */ + short frows; /* Nr. of formatted items high */ + short fcols; /* Nr. of formatted items wide */ + short arows; /* Nr. of items high (actual) */ + short namelen; /* Max. name length */ + short desclen; /* Max. description length */ + short marklen; /* Length of mark, if any */ + short itemlen; /* Length of one item */ + short spc_desc; /* Spacing for descriptor */ + short spc_cols; /* Spacing for columns */ + short spc_rows; /* Spacing for rows */ + char *pattern; /* Buffer to store match chars */ + short pindex; /* Index into pattern buffer */ + WINDOW *win; /* Window containing menu */ + WINDOW *sub; /* Subwindow for menu display */ + WINDOW *userwin; /* User's window */ + WINDOW *usersub; /* User's subwindow */ + ITEM **items; /* array of items */ + short nitems; /* Nr. of items in menu */ + ITEM *curitem; /* Current item */ + short toprow; /* Top row of menu */ + chtype fore; /* Selection attribute */ + chtype back; /* Nonselection attribute */ + chtype grey; /* Inactive attribute */ + unsigned char pad; /* Pad character */ + + Menu_Hook menuinit; /* User hooks */ + Menu_Hook menuterm; + Menu_Hook iteminit; + Menu_Hook itemterm; + + void *userptr; /* Pointer to menus user data */ + char *mark; /* Pointer to marker string */ + + Menu_Options opt; /* Menu options */ + unsigned short status; /* Internal state of menu */ + } +#endif /* !NCURSES_OPAQUE_MENU */ + MENU; /* Define keys */ @@ -180,92 +192,90 @@ MENU; # define MAX_COMMAND (KEY_MAX + 128) #endif - /* --------- prototypes for libmenu functions ----------------------------- */ -extern NCURSES_EXPORT(ITEM **) menu_items (const MENU *); -extern NCURSES_EXPORT(ITEM *) current_item (const MENU *); -extern NCURSES_EXPORT(ITEM *) new_item (const char *,const char *); - -extern NCURSES_EXPORT(MENU *) new_menu (ITEM **); - -extern NCURSES_EXPORT(Item_Options) item_opts (const ITEM *); -extern NCURSES_EXPORT(Menu_Options) menu_opts (const MENU *); - -extern NCURSES_EXPORT(Menu_Hook) item_init (const MENU *); -extern NCURSES_EXPORT(Menu_Hook) item_term (const MENU *); -extern NCURSES_EXPORT(Menu_Hook) menu_init (const MENU *); -extern NCURSES_EXPORT(Menu_Hook) menu_term (const MENU *); - -extern NCURSES_EXPORT(WINDOW *) menu_sub (const MENU *); -extern NCURSES_EXPORT(WINDOW *) menu_win (const MENU *); - -extern NCURSES_EXPORT(const char *) item_description (const ITEM *); -extern NCURSES_EXPORT(const char *) item_name (const ITEM *); -extern NCURSES_EXPORT(const char *) menu_mark (const MENU *); -extern NCURSES_EXPORT(const char *) menu_request_name (int); - -extern NCURSES_EXPORT(char *) menu_pattern (const MENU *); - -extern NCURSES_EXPORT(void *) menu_userptr (const MENU *); -extern NCURSES_EXPORT(void *) item_userptr (const ITEM *); - -extern NCURSES_EXPORT(chtype) menu_back (const MENU *); -extern NCURSES_EXPORT(chtype) menu_fore (const MENU *); -extern NCURSES_EXPORT(chtype) menu_grey (const MENU *); - -extern NCURSES_EXPORT(int) free_item (ITEM *); -extern NCURSES_EXPORT(int) free_menu (MENU *); -extern NCURSES_EXPORT(int) item_count (const MENU *); -extern NCURSES_EXPORT(int) item_index (const ITEM *); -extern NCURSES_EXPORT(int) item_opts_off (ITEM *,Item_Options); -extern NCURSES_EXPORT(int) item_opts_on (ITEM *,Item_Options); -extern NCURSES_EXPORT(int) menu_driver (MENU *,int); -extern NCURSES_EXPORT(int) menu_opts_off (MENU *,Menu_Options); -extern NCURSES_EXPORT(int) menu_opts_on (MENU *,Menu_Options); -extern NCURSES_EXPORT(int) menu_pad (const MENU *); -extern NCURSES_EXPORT(int) pos_menu_cursor (const MENU *); -extern NCURSES_EXPORT(int) post_menu (MENU *); -extern NCURSES_EXPORT(int) scale_menu (const MENU *,int *,int *); -extern NCURSES_EXPORT(int) set_current_item (MENU *menu,ITEM *item); -extern NCURSES_EXPORT(int) set_item_init (MENU *, Menu_Hook); -extern NCURSES_EXPORT(int) set_item_opts (ITEM *,Item_Options); -extern NCURSES_EXPORT(int) set_item_term (MENU *, Menu_Hook); -extern NCURSES_EXPORT(int) set_item_userptr (ITEM *, void *); -extern NCURSES_EXPORT(int) set_item_value (ITEM *,bool); -extern NCURSES_EXPORT(int) set_menu_back (MENU *,chtype); -extern NCURSES_EXPORT(int) set_menu_fore (MENU *,chtype); -extern NCURSES_EXPORT(int) set_menu_format (MENU *,int,int); -extern NCURSES_EXPORT(int) set_menu_grey (MENU *,chtype); -extern NCURSES_EXPORT(int) set_menu_init (MENU *, Menu_Hook); -extern NCURSES_EXPORT(int) set_menu_items (MENU *,ITEM **); -extern NCURSES_EXPORT(int) set_menu_mark (MENU *, const char *); -extern NCURSES_EXPORT(int) set_menu_opts (MENU *,Menu_Options); -extern NCURSES_EXPORT(int) set_menu_pad (MENU *,int); -extern NCURSES_EXPORT(int) set_menu_pattern (MENU *,const char *); -extern NCURSES_EXPORT(int) set_menu_sub (MENU *,WINDOW *); -extern NCURSES_EXPORT(int) set_menu_term (MENU *, Menu_Hook); -extern NCURSES_EXPORT(int) set_menu_userptr (MENU *,void *); -extern NCURSES_EXPORT(int) set_menu_win (MENU *,WINDOW *); -extern NCURSES_EXPORT(int) set_top_row (MENU *,int); -extern NCURSES_EXPORT(int) top_row (const MENU *); -extern NCURSES_EXPORT(int) unpost_menu (MENU *); -extern NCURSES_EXPORT(int) menu_request_by_name (const char *); -extern NCURSES_EXPORT(int) set_menu_spacing (MENU *,int,int,int); -extern NCURSES_EXPORT(int) menu_spacing (const MENU *,int *,int *,int *); - - -extern NCURSES_EXPORT(bool) item_value (const ITEM *); -extern NCURSES_EXPORT(bool) item_visible (const ITEM *); - -extern NCURSES_EXPORT(void) menu_format (const MENU *,int *,int *); + extern MENU_EXPORT(ITEM **) menu_items(const MENU *); + extern MENU_EXPORT(ITEM *) current_item(const MENU *); + extern MENU_EXPORT(ITEM *) new_item(const char *, const char *); + + extern MENU_EXPORT(MENU *) new_menu(ITEM **); + + extern MENU_EXPORT(Item_Options) item_opts(const ITEM *); + extern MENU_EXPORT(Menu_Options) menu_opts(const MENU *); + + extern MENU_EXPORT(Menu_Hook) item_init(const MENU *); + extern MENU_EXPORT(Menu_Hook) item_term(const MENU *); + extern MENU_EXPORT(Menu_Hook) menu_init(const MENU *); + extern MENU_EXPORT(Menu_Hook) menu_term(const MENU *); + + extern MENU_EXPORT(WINDOW *) menu_sub(const MENU *); + extern MENU_EXPORT(WINDOW *) menu_win(const MENU *); + + extern MENU_EXPORT(const char *) item_description(const ITEM *); + extern MENU_EXPORT(const char *) item_name(const ITEM *); + extern MENU_EXPORT(const char *) menu_mark(const MENU *); + extern MENU_EXPORT(const char *) menu_request_name(int); + + extern MENU_EXPORT(char *) menu_pattern(const MENU *); + + extern MENU_EXPORT(void *) menu_userptr(const MENU *); + extern MENU_EXPORT(void *) item_userptr(const ITEM *); + + extern MENU_EXPORT(chtype) menu_back(const MENU *); + extern MENU_EXPORT(chtype) menu_fore(const MENU *); + extern MENU_EXPORT(chtype) menu_grey(const MENU *); + + extern MENU_EXPORT(int) free_item(ITEM *); + extern MENU_EXPORT(int) free_menu(MENU *); + extern MENU_EXPORT(int) item_count(const MENU *); + extern MENU_EXPORT(int) item_index(const ITEM *); + extern MENU_EXPORT(int) item_opts_off(ITEM *, Item_Options); + extern MENU_EXPORT(int) item_opts_on(ITEM *, Item_Options); + extern MENU_EXPORT(int) menu_driver(MENU *, int); + extern MENU_EXPORT(int) menu_opts_off(MENU *, Menu_Options); + extern MENU_EXPORT(int) menu_opts_on(MENU *, Menu_Options); + extern MENU_EXPORT(int) menu_pad(const MENU *); + extern MENU_EXPORT(int) pos_menu_cursor(const MENU *); + extern MENU_EXPORT(int) post_menu(MENU *); + extern MENU_EXPORT(int) scale_menu(const MENU *, int *, int *); + extern MENU_EXPORT(int) set_current_item(MENU *menu, ITEM *item); + extern MENU_EXPORT(int) set_item_init(MENU *, Menu_Hook); + extern MENU_EXPORT(int) set_item_opts(ITEM *, Item_Options); + extern MENU_EXPORT(int) set_item_term(MENU *, Menu_Hook); + extern MENU_EXPORT(int) set_item_userptr(ITEM *, void *); + extern MENU_EXPORT(int) set_item_value(ITEM *, bool); + extern MENU_EXPORT(int) set_menu_back(MENU *, chtype); + extern MENU_EXPORT(int) set_menu_fore(MENU *, chtype); + extern MENU_EXPORT(int) set_menu_format(MENU *, int, int); + extern MENU_EXPORT(int) set_menu_grey(MENU *, chtype); + extern MENU_EXPORT(int) set_menu_init(MENU *, Menu_Hook); + extern MENU_EXPORT(int) set_menu_items(MENU *, ITEM **); + extern MENU_EXPORT(int) set_menu_mark(MENU *, const char *); + extern MENU_EXPORT(int) set_menu_opts(MENU *, Menu_Options); + extern MENU_EXPORT(int) set_menu_pad(MENU *, int); + extern MENU_EXPORT(int) set_menu_pattern(MENU *, const char *); + extern MENU_EXPORT(int) set_menu_sub(MENU *, WINDOW *); + extern MENU_EXPORT(int) set_menu_term(MENU *, Menu_Hook); + extern MENU_EXPORT(int) set_menu_userptr(MENU *, void *); + extern MENU_EXPORT(int) set_menu_win(MENU *, WINDOW *); + extern MENU_EXPORT(int) set_top_row(MENU *, int); + extern MENU_EXPORT(int) top_row(const MENU *); + extern MENU_EXPORT(int) unpost_menu(MENU *); + extern MENU_EXPORT(int) menu_request_by_name(const char *); + extern MENU_EXPORT(int) set_menu_spacing(MENU *, int, int, int); + extern MENU_EXPORT(int) menu_spacing(const MENU *, int *, int *, int *); + + extern MENU_EXPORT(bool) item_value(const ITEM *); + extern MENU_EXPORT(bool) item_visible(const ITEM *); + + extern MENU_EXPORT(void) menu_format(const MENU *, int *, int *); #if NCURSES_SP_FUNCS -extern NCURSES_EXPORT(MENU *) NCURSES_SP_NAME(new_menu) (SCREEN*, ITEM **); + extern MENU_EXPORT(MENU *) NCURSES_SP_NAME(new_menu) (SCREEN *, ITEM **); #endif #ifdef __cplusplus - } +} #endif -#endif /* ETI_MENU */ +#endif /* ETI_MENU */ diff --git a/menu/menu.priv.h b/menu/menu.priv.h index d084565..0bc6147 100644 --- a/menu/menu.priv.h +++ b/menu/menu.priv.h @@ -31,7 +31,7 @@ * Author: Juergen Pfeifer, 1995,1997 * ****************************************************************************/ -/* $Id: menu.priv.h,v 1.28 2020/02/02 23:34:34 tom Exp $ */ +/* $Id: menu.priv.h,v 1.29 2020/05/24 01:40:20 anonymous.maarten Exp $ */ /*************************************************************************** * Module menu.priv.h * @@ -52,8 +52,8 @@ /* Backspace code */ #define BS (8) -extern NCURSES_EXPORT_VAR(ITEM) _nc_Default_Item; -extern NCURSES_EXPORT_VAR(MENU) _nc_Default_Menu; +extern MENU_EXPORT_VAR(ITEM) _nc_Default_Item; +extern MENU_EXPORT_VAR(MENU) _nc_Default_Menu; /* Normalize item to default if none was given */ #define Normalize_Item( item ) ((item)=(item)?(item):&_nc_Default_Item) @@ -120,17 +120,17 @@ extern NCURSES_EXPORT_VAR(MENU) _nc_Default_Menu; #define UChar(c) ((unsigned char)(c)) /* Internal functions. */ -extern NCURSES_EXPORT(void) _nc_Draw_Menu (const MENU *); -extern NCURSES_EXPORT(void) _nc_Show_Menu (const MENU *); -extern NCURSES_EXPORT(void) _nc_Calculate_Item_Length_and_Width (MENU *); -extern NCURSES_EXPORT(int) _nc_Calculate_Text_Width(const TEXT *); -extern NCURSES_EXPORT(void) _nc_Post_Item (const MENU *, const ITEM *); -extern NCURSES_EXPORT(bool) _nc_Connect_Items (MENU *, ITEM **); -extern NCURSES_EXPORT(void) _nc_Disconnect_Items (MENU *); -extern NCURSES_EXPORT(void) _nc_New_TopRow_and_CurrentItem (MENU *,int, ITEM *); -extern NCURSES_EXPORT(void) _nc_Link_Items (MENU *); -extern NCURSES_EXPORT(int) _nc_Match_Next_Character_In_Item_Name (MENU*,int,ITEM**); -extern NCURSES_EXPORT(int) _nc_menu_cursor_pos (const MENU* menu, const ITEM* item, +extern MENU_EXPORT(void) _nc_Draw_Menu (const MENU *); +extern MENU_EXPORT(void) _nc_Show_Menu (const MENU *); +extern MENU_EXPORT(void) _nc_Calculate_Item_Length_and_Width (MENU *); +extern MENU_EXPORT(int) _nc_Calculate_Text_Width(const TEXT *); +extern MENU_EXPORT(void) _nc_Post_Item (const MENU *, const ITEM *); +extern MENU_EXPORT(bool) _nc_Connect_Items (MENU *, ITEM **); +extern MENU_EXPORT(void) _nc_Disconnect_Items (MENU *); +extern MENU_EXPORT(void) _nc_New_TopRow_and_CurrentItem (MENU *,int, ITEM *); +extern MENU_EXPORT(void) _nc_Link_Items (MENU *); +extern MENU_EXPORT(int) _nc_Match_Next_Character_In_Item_Name (MENU*,int,ITEM**); +extern MENU_EXPORT(int) _nc_menu_cursor_pos (const MENU* menu, const ITEM* item, int* pY, int* pX); #ifdef TRACE @@ -142,12 +142,12 @@ extern NCURSES_EXPORT(int) _nc_menu_cursor_pos (const MENU* menu, const ITEM* i #define returnMenuHook(code) TRACE_RETURN1(code,menu_hook) #define returnMenuOpts(code) TRACE_RETURN1(code,menu_opts) -extern NCURSES_EXPORT(ITEM *) _nc_retrace_item (ITEM *); -extern NCURSES_EXPORT(ITEM **) _nc_retrace_item_ptr (ITEM **); -extern NCURSES_EXPORT(Item_Options) _nc_retrace_item_opts (Item_Options); -extern NCURSES_EXPORT(MENU *) _nc_retrace_menu (MENU *); -extern NCURSES_EXPORT(Menu_Hook) _nc_retrace_menu_hook (Menu_Hook); -extern NCURSES_EXPORT(Menu_Options) _nc_retrace_menu_opts (Menu_Options); +extern MENU_EXPORT(ITEM *) _nc_retrace_item (ITEM *); +extern MENU_EXPORT(ITEM **) _nc_retrace_item_ptr (ITEM **); +extern MENU_EXPORT(Item_Options) _nc_retrace_item_opts (Item_Options); +extern MENU_EXPORT(MENU *) _nc_retrace_menu (MENU *); +extern MENU_EXPORT(Menu_Hook) _nc_retrace_menu_hook (Menu_Hook); +extern MENU_EXPORT(Menu_Options) _nc_retrace_menu_opts (Menu_Options); #else /* !TRACE */ |