diff options
33 files changed, 550 insertions, 352 deletions
diff --git a/lib/libmenu/Makefile b/lib/libmenu/Makefile index 3eb1c6b50c4..e156fd98eb4 100644 --- a/lib/libmenu/Makefile +++ b/lib/libmenu/Makefile @@ -1,8 +1,9 @@ LIB= menu SRCS= m_attribs.c m_cursor.c m_driver.c m_format.c m_global.c m_hook.c \ - m_item_cur.c m_item_nam.c m_item_new.c m_item_opt.c m_item_use.c \ - m_item_val.c m_item_vis.c m_items.c m_new.c m_opts.c m_post.c \ - m_userptr.c m_win.c + m_item_cur.c m_item_nam.c m_item_new.c m_item_opt.c m_item_top.c \ + m_item_use.c m_item_val.c m_item_vis.c m_items.c m_new.c m_opts.c \ + m_pad.c m_pattern.c m_post.c m_req_name.c m_scale.c m_spacing.c \ + m_sub.c m_userptr.c m_win.c HDRS= menu.h eti.h CFLAGS+=-I. -I${.CURDIR} -I${.CURDIR}/../libcurses -DHAVE_CONFIG_H MAN= menu.3 menu_attribs.3 menu_cursor.3 menu_driver.3 menu_format.3 \ diff --git a/lib/libmenu/READ.ME b/lib/libmenu/READ.ME index eb5a64cde4f..829cb45976e 100644 --- a/lib/libmenu/READ.ME +++ b/lib/libmenu/READ.ME @@ -2,13 +2,9 @@ This is a clone of the menu library that is available with typical System V curses implementations (ETI). It is modelled after the documentation that comes for this library with -a 386 based SVR4 implementation (ESIX). This system was used together -with an NCR3000 system to compile the clone using original curses -implementation and to run various programs to check the compatibility of -this clone with the original libmenu library. +a 386 based SVR4 implementation (ESIX). -The development environment was an ELF based Linux system, the German -Unifix distribution (aka Linux FT). +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 directory. diff --git a/lib/libmenu/eti.h b/lib/libmenu/eti.h index 63028e849bc..761874b2b3c 100644 --- a/lib/libmenu/eti.h +++ b/lib/libmenu/eti.h @@ -1,3 +1,5 @@ +/* $OpenBSD: eti.h,v 1.3 1997/12/03 05:31:16 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses Extended Terminal Interface (ETI) is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | diff --git a/lib/libmenu/m_attribs.c b/lib/libmenu/m_attribs.c index 36a7758ed1e..d5da2a433e1 100644 --- a/lib/libmenu/m_attribs.c +++ b/lib/libmenu/m_attribs.c @@ -1,3 +1,5 @@ +/* $OpenBSD: m_attribs.c,v 1.3 1997/12/03 05:31:16 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses menu library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -21,13 +23,13 @@ +-----------------------------------------------------------------------------*/ /*************************************************************************** -* Module menu_attribs * +* Module m_attribs * * Control menus display attributes * ***************************************************************************/ #include "menu.priv.h" -MODULE_ID("Id: m_attribs.c,v 1.4 1997/05/01 16:47:26 juergen Exp $") +MODULE_ID("Id: m_attribs.c,v 1.5 1997/10/21 08:44:31 juergen Exp $") /* Macro to redraw menu if it is posted and changed */ #define Refresh_Menu(menu) \ @@ -128,45 +130,4 @@ GEN_MENU_ATTR_SET_FCT( grey ) | Return Values : Attribute value +--------------------------------------------------------------------------*/ GEN_MENU_ATTR_GET_FCT( grey ) - -/*--------------------------------------------------------------------------- -| 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 -| character. -| -| Return Values : E_OK - success -| E_BAD_ARGUMENT - an invalid value has been passed -+--------------------------------------------------------------------------*/ -int set_menu_pad(MENU *menu, int pad) -{ - bool do_refresh = !(menu); - - if (!isprint((unsigned char)pad)) - RETURN(E_BAD_ARGUMENT); - - Normalize_Menu( menu ); - menu->pad = pad; - - if (do_refresh) - Refresh_Menu( menu ); - - RETURN(E_OK); -} - -/*--------------------------------------------------------------------------- -| Facility : libnmenu -| Function : int menu_pad(const MENU *menu) -| -| Description : Return the value of the padding character -| -| Return Values : The pad character -+--------------------------------------------------------------------------*/ -int menu_pad(const MENU * menu) -{ - return (Normalize_Menu( menu ) -> pad); -} - /* m_attribs.c ends here */ diff --git a/lib/libmenu/m_cursor.c b/lib/libmenu/m_cursor.c index 3d9c7f7c4ef..9f9202a0e53 100644 --- a/lib/libmenu/m_cursor.c +++ b/lib/libmenu/m_cursor.c @@ -1,3 +1,5 @@ +/* $OpenBSD: m_cursor.c,v 1.3 1997/12/03 05:31:17 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses menu library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -21,13 +23,13 @@ +-----------------------------------------------------------------------------*/ /*************************************************************************** -* Module menu_cursor * +* Module m_cursor * * Correctly position a menus cursor * ***************************************************************************/ #include "menu.priv.h" -MODULE_ID("Id: m_cursor.c,v 1.7 1997/05/01 16:47:26 juergen Exp $") +MODULE_ID("Id: m_cursor.c,v 1.8 1997/10/21 08:44:31 juergen Exp $") /*--------------------------------------------------------------------------- | Facility : libnmenu diff --git a/lib/libmenu/m_driver.c b/lib/libmenu/m_driver.c index 1194bcc78fc..6ffccc85561 100644 --- a/lib/libmenu/m_driver.c +++ b/lib/libmenu/m_driver.c @@ -1,3 +1,5 @@ +/* $OpenBSD: m_driver.c,v 1.3 1997/12/03 05:31:17 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses menu library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -21,13 +23,13 @@ +-----------------------------------------------------------------------------*/ /*************************************************************************** -* Module menu_driver and menu_pattern * -* Central dispatching routine and pattern matching handling * +* Module m_driver * +* Central dispatching routine * ***************************************************************************/ #include "menu.priv.h" -MODULE_ID("Id: m_driver.c,v 1.8 1997/05/01 16:47:26 juergen Exp $") +MODULE_ID("Id: m_driver.c,v 1.9 1997/10/21 08:44:31 juergen Exp $") /* Macros */ @@ -78,7 +80,7 @@ static bool Is_Sub_String( /*--------------------------------------------------------------------------- | Facility : libnmenu -| Function : static int Match_Next_Character_In_Item_Name( +| Function : int _nc_Match_Next_Character_In_Item_Name( | MENU *menu, | int ch, | ITEM **item) @@ -101,7 +103,7 @@ static bool Is_Sub_String( | Return Values : E_OK - an item matching the pattern was found | E_NO_MATCH - nothing found +--------------------------------------------------------------------------*/ -static int Match_Next_Character_In_Item_Name(MENU *menu, int ch, ITEM **item) +int _nc_Match_Next_Character_In_Item_Name(MENU *menu, int ch, ITEM **item) { bool found = FALSE, passed = FALSE; int idx, last; @@ -178,81 +180,6 @@ static int Match_Next_Character_In_Item_Name(MENU *menu, int ch, ITEM **item) /*--------------------------------------------------------------------------- | 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 -| EmptyString - if there is a pattern buffer but no -| pattern is stored -| PatternString - as expected -+--------------------------------------------------------------------------*/ -char *menu_pattern(const MENU * menu) -{ - return (menu ? (menu->pattern ? menu->pattern : "") : (char *)0); -} - -/*--------------------------------------------------------------------------- -| 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. -| -| Return Values : E_OK - success -| E_BAD_ARGUMENT - invalid menu or pattern pointer -| E_NOT_CONNECTED - no items connected to menu -| E_BAD_STATE - menu in user hook routine -| E_NO_MATCH - no item matches pattern -+--------------------------------------------------------------------------*/ -int set_menu_pattern(MENU *menu, const char *p) -{ - ITEM *matchitem; - int matchpos; - - if (!menu || !p) - RETURN(E_BAD_ARGUMENT); - - if (!(menu->items)) - RETURN(E_NOT_CONNECTED); - - if ( menu->status & _IN_DRIVER ) - RETURN(E_BAD_STATE); - - Reset_Pattern(menu); - - if (!(*p)) - { - pos_menu_cursor(menu); - RETURN(E_OK); - } - - if (menu->status & _LINK_NEEDED) - _nc_Link_Items(menu); - - matchpos = menu->toprow; - matchitem = menu->curitem; - assert(matchitem); - - while(*p) - { - if ( !isprint(*p) || - (Match_Next_Character_In_Item_Name(menu,*p,&matchitem) != E_OK) ) - { - Reset_Pattern(menu); - pos_menu_cursor(menu); - RETURN(E_NO_MATCH); - } - p++; - } - - /* This is reached if there was a match. So we position to the new item */ - Adjust_Current_Item(menu,matchpos,matchitem); - RETURN(E_OK); -} - -/*--------------------------------------------------------------------------- -| Facility : libnmenu | Function : int menu_driver(MENU *menu, int c) | | Description : Central dispatcher for the menu. Translates the logical @@ -449,7 +376,7 @@ int menu_driver(MENU * menu, int c) /*==================*/ assert(menu->pattern); if (menu->pattern[0]) - result = Match_Next_Character_In_Item_Name(menu,0,&item); + result = _nc_Match_Next_Character_In_Item_Name(menu,0,&item); else { if ((item->index+1)<menu->nitems) @@ -468,7 +395,7 @@ int menu_driver(MENU * menu, int c) /*==================*/ assert(menu->pattern); if (menu->pattern[0]) - result = Match_Next_Character_In_Item_Name(menu,BS,&item); + result = _nc_Match_Next_Character_In_Item_Name(menu,BS,&item); else { if (item->index) @@ -492,7 +419,7 @@ int menu_driver(MENU * menu, int c) else { /* not a command */ if ( !(c & ~((int)MAX_REGULAR_CHARACTER)) && isprint(c) ) - result = Match_Next_Character_In_Item_Name( menu, c, &item ); + result = _nc_Match_Next_Character_In_Item_Name( menu, c, &item ); else result = E_UNKNOWN_COMMAND; } diff --git a/lib/libmenu/m_format.c b/lib/libmenu/m_format.c index 351bc420410..23a93a0a9bf 100644 --- a/lib/libmenu/m_format.c +++ b/lib/libmenu/m_format.c @@ -1,3 +1,5 @@ +/* $OpenBSD: m_format.c,v 1.3 1997/12/03 05:31:18 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses menu library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -21,13 +23,13 @@ +-----------------------------------------------------------------------------*/ /*************************************************************************** -* Module menu_format * +* Module m_format * * Set and get maximum numbers of rows and columns in menus * ***************************************************************************/ #include "menu.priv.h" -MODULE_ID("Id: m_format.c,v 1.5 1997/05/01 16:47:26 juergen Exp $") +MODULE_ID("Id: m_format.c,v 1.6 1997/10/21 08:44:31 juergen Exp $") #define minimum(a,b) ((a)<(b) ? (a): (b)) diff --git a/lib/libmenu/m_global.c b/lib/libmenu/m_global.c index ea3bfcfdcab..fed28f48456 100644 --- a/lib/libmenu/m_global.c +++ b/lib/libmenu/m_global.c @@ -1,3 +1,5 @@ +/* $OpenBSD: m_global.c,v 1.3 1997/12/03 05:31:18 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses menu library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -21,13 +23,13 @@ +-----------------------------------------------------------------------------*/ /*************************************************************************** -* Module menu_global * +* Module m_global * * Globally used internal routines and the default menu and item structures * ***************************************************************************/ #include "menu.priv.h" -MODULE_ID("Id: m_global.c,v 1.7 1997/05/01 16:47:26 juergen Exp $") +MODULE_ID("Id: m_global.c,v 1.8 1997/10/21 08:44:31 juergen Exp $") MENU _nc_Default_Menu = { 16, /* Nr. of chars high */ diff --git a/lib/libmenu/m_hook.c b/lib/libmenu/m_hook.c index 65fe0e9b59a..c8787e2994c 100644 --- a/lib/libmenu/m_hook.c +++ b/lib/libmenu/m_hook.c @@ -1,3 +1,5 @@ +/* $OpenBSD: m_hook.c,v 1.3 1997/12/03 05:31:19 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses menu library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -21,13 +23,13 @@ +-----------------------------------------------------------------------------*/ /*************************************************************************** -* Module menu_hook * +* Module m_hook * * Assign application specific routines for automatic invocation by menus * ***************************************************************************/ #include "menu.priv.h" -MODULE_ID("Id: m_hook.c,v 1.4 1997/05/01 16:47:26 juergen Exp $") +MODULE_ID("Id: m_hook.c,v 1.5 1997/10/21 08:44:31 juergen Exp $") /* "Template" macro to generate function to set application specific hook */ #define GEN_HOOK_SET_FUNCTION( typ, name ) \ diff --git a/lib/libmenu/m_item_cur.c b/lib/libmenu/m_item_cur.c index 0af44e3ef80..88e93cb93b3 100644 --- a/lib/libmenu/m_item_cur.c +++ b/lib/libmenu/m_item_cur.c @@ -1,3 +1,5 @@ +/* $OpenBSD: m_item_cur.c,v 1.3 1997/12/03 05:31:19 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses menu library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -21,13 +23,13 @@ +-----------------------------------------------------------------------------*/ /*************************************************************************** -* Module menu_item_cur * +* Module m_item_cur * * Set and get current menus item * ***************************************************************************/ #include "menu.priv.h" -MODULE_ID("Id: m_item_cur.c,v 1.7 1997/05/01 16:47:26 juergen Exp $") +MODULE_ID("Id: m_item_cur.c,v 1.8 1997/10/21 08:44:31 juergen Exp $") /*--------------------------------------------------------------------------- | Facility : libnmenu @@ -93,64 +95,4 @@ int item_index(const ITEM *item) return (item && item->imenu) ? item->index : ERR; } -/*--------------------------------------------------------------------------- -| Facility : libnmenu -| Function : int set_top_row(MENU *menu, int row) -| -| Description : Makes the speified 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 -+--------------------------------------------------------------------------*/ -int set_top_row(MENU * menu, int row) -{ - ITEM *item; - - if (menu) - { - if ( menu->status & _IN_DRIVER ) - RETURN(E_BAD_STATE); - if (menu->items == (ITEM **)0) - RETURN(E_NOT_CONNECTED); - - if ((row<0) || (row > (menu->rows - menu->arows))) - RETURN(E_BAD_ARGUMENT); - } - else - RETURN(E_BAD_ARGUMENT); - - if (row != menu->toprow) - { - if (menu->status & _LINK_NEEDED) - _nc_Link_Items(menu); - - item = menu->items[ (menu->opt&O_ROWMAJOR) ? (row*menu->cols) : row ]; - assert(menu->pattern); - Reset_Pattern(menu); - _nc_New_TopRow_and_CurrentItem(menu, row, item); - } - - RETURN(E_OK); -} - -/*--------------------------------------------------------------------------- -| 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 -+--------------------------------------------------------------------------*/ -int top_row(const MENU * menu) -{ - if (menu && menu->items && *(menu->items)) - { - assert( (menu->toprow>=0) && (menu->toprow < menu->rows) ); - return menu->toprow; - } - else - return(ERR); -} - /* m_item_cur.c ends here */ diff --git a/lib/libmenu/m_item_nam.c b/lib/libmenu/m_item_nam.c index 876cf05a777..a905f3c9963 100644 --- a/lib/libmenu/m_item_nam.c +++ b/lib/libmenu/m_item_nam.c @@ -1,3 +1,5 @@ +/* $OpenBSD: m_item_nam.c,v 1.3 1997/12/03 05:31:20 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses menu library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -21,13 +23,13 @@ +-----------------------------------------------------------------------------*/ /*************************************************************************** -* Module menu_item_nam * +* Module m_item_nam * * Get menus item name and description * ***************************************************************************/ #include "menu.priv.h" -MODULE_ID("Id: m_item_nam.c,v 1.5 1997/05/01 16:47:26 juergen Exp $") +MODULE_ID("Id: m_item_nam.c,v 1.6 1997/10/21 08:44:31 juergen Exp $") /*--------------------------------------------------------------------------- | Facility : libnmenu diff --git a/lib/libmenu/m_item_new.c b/lib/libmenu/m_item_new.c index 5d06576fd08..529f4f6960b 100644 --- a/lib/libmenu/m_item_new.c +++ b/lib/libmenu/m_item_new.c @@ -1,3 +1,5 @@ +/* $OpenBSD: m_item_new.c,v 1.3 1997/12/03 05:31:20 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses menu library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -21,14 +23,14 @@ +-----------------------------------------------------------------------------*/ /*************************************************************************** -* Module menu_item_new * +* Module m_item_new * * Create and destroy menu items * -* Set and get marker string for menu +* Set and get marker string for menu * ***************************************************************************/ #include "menu.priv.h" -MODULE_ID("Id: m_item_new.c,v 1.5 1997/05/01 16:47:26 juergen Exp $") +MODULE_ID("Id: m_item_new.c,v 1.7 1997/10/21 08:44:31 juergen Exp $") /*--------------------------------------------------------------------------- | Facility : libnmenu @@ -79,35 +81,13 @@ ITEM *new_item(const char *name, const char *description) *item = _nc_Default_Item; /* hope we have struct assignment */ item->name.length = strlen(name); - item->name.str = (char *)malloc(1 + item->name.length); - if (item->name.str) - { - strcpy(item->name.str, name); - } - else - { - free(item); - SET_ERROR( E_SYSTEM_ERROR ); - return (ITEM *)0; - } - + item->name.str = name; + if (description && (*description != '\0') && Is_Printable_String(description)) { item->description.length = strlen(description); - item->description.str = - (char *)malloc(1 + item->description.length); - if (item->description.str) - { - strcpy(item->description.str, description); - } - else - { - free(item->name.str); - free(item); - SET_ERROR( E_SYSTEM_ERROR ); - return (ITEM *)0; - } + item->description.str = description; } else { @@ -140,10 +120,6 @@ int free_item(ITEM * item) if (item->imenu) RETURN( E_CONNECTED ); - if (item->name.str) - free(item->name.str); - if (item->description.str) - free (item->description.str); free(item); RETURN( E_OK ); diff --git a/lib/libmenu/m_item_opt.c b/lib/libmenu/m_item_opt.c index f3b53f37436..08fcf555b0b 100644 --- a/lib/libmenu/m_item_opt.c +++ b/lib/libmenu/m_item_opt.c @@ -1,3 +1,5 @@ +/* $OpenBSD: m_item_opt.c,v 1.3 1997/12/03 05:31:21 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses menu library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -21,13 +23,13 @@ +-----------------------------------------------------------------------------*/ /*************************************************************************** -* Module menu_item_opt * +* Module m_item_opt * * Menus item option routines * ***************************************************************************/ #include "menu.priv.h" -MODULE_ID("Id: m_item_opt.c,v 1.4 1997/05/01 16:47:26 juergen Exp $") +MODULE_ID("Id: m_item_opt.c,v 1.5 1997/10/21 08:44:31 juergen Exp $") /*--------------------------------------------------------------------------- | Facility : libnmenu diff --git a/lib/libmenu/m_item_top.c b/lib/libmenu/m_item_top.c new file mode 100644 index 00000000000..e27fbed3824 --- /dev/null +++ b/lib/libmenu/m_item_top.c @@ -0,0 +1,94 @@ +/* $OpenBSD: m_item_top.c,v 1.1 1997/12/03 05:31:21 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| The ncurses menu library is Copyright (C) 1995-1997 | +| by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | +| All Rights Reserved. | +| | +| Permission to use, copy, modify, and distribute this software and its | +| documentation for any purpose and without fee is hereby granted, provided | +| that the above copyright notice appear in all copies and that both that | +| copyright notice and this permission notice appear in supporting | +| documentation, and that the name of the above listed copyright holder(s) not | +| be used in advertising or publicity pertaining to distribution of the | +| software without specific, written prior permission. | +| | +| THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO | +| THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- | +| NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR | +| ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- | +| SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, | +| NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH | +| THE USE OR PERFORMANCE OF THIS SOFTWARE. | ++-----------------------------------------------------------------------------*/ + +/*************************************************************************** +* Module m_item_top * +* Set and get top menus item * +***************************************************************************/ + +#include "menu.priv.h" + +MODULE_ID("Id: m_item_top.c,v 1.1 1997/10/21 08:44:31 juergen Exp $") + +/*--------------------------------------------------------------------------- +| Facility : libnmenu +| Function : int set_top_row(MENU *menu, int row) +| +| Description : Makes the speified 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 ++--------------------------------------------------------------------------*/ +int set_top_row(MENU * menu, int row) +{ + ITEM *item; + + if (menu) + { + if ( menu->status & _IN_DRIVER ) + RETURN(E_BAD_STATE); + if (menu->items == (ITEM **)0) + RETURN(E_NOT_CONNECTED); + + if ((row<0) || (row > (menu->rows - menu->arows))) + RETURN(E_BAD_ARGUMENT); + } + else + RETURN(E_BAD_ARGUMENT); + + if (row != menu->toprow) + { + if (menu->status & _LINK_NEEDED) + _nc_Link_Items(menu); + + item = menu->items[ (menu->opt&O_ROWMAJOR) ? (row*menu->cols) : row ]; + assert(menu->pattern); + Reset_Pattern(menu); + _nc_New_TopRow_and_CurrentItem(menu, row, item); + } + + RETURN(E_OK); +} + +/*--------------------------------------------------------------------------- +| 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 ++--------------------------------------------------------------------------*/ +int top_row(const MENU * menu) +{ + if (menu && menu->items && *(menu->items)) + { + assert( (menu->toprow>=0) && (menu->toprow < menu->rows) ); + return menu->toprow; + } + else + return(ERR); +} + +/* m_item_top.c ends here */ diff --git a/lib/libmenu/m_item_use.c b/lib/libmenu/m_item_use.c index 9efb0601390..fe8f9e4cd2f 100644 --- a/lib/libmenu/m_item_use.c +++ b/lib/libmenu/m_item_use.c @@ -1,3 +1,5 @@ +/* $OpenBSD: m_item_use.c,v 1.3 1997/12/03 05:31:22 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses menu library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -21,24 +23,24 @@ +-----------------------------------------------------------------------------*/ /*************************************************************************** -* Module menu_item_use * +* Module m_item_use * * Associate application data with menu items * ***************************************************************************/ #include "menu.priv.h" -MODULE_ID("Id: m_item_use.c,v 1.5 1997/05/01 16:47:26 juergen Exp $") +MODULE_ID("Id: m_item_use.c,v 1.7 1997/10/21 08:44:31 juergen Exp $") /*--------------------------------------------------------------------------- | Facility : libnmenu -| Function : int set_item_userptr(ITEM *item, const void *userptr) +| Function : int set_item_userptr(ITEM *item, void *userptr) | | Description : Set the pointer that is reserved in any item to store | application relevant informations. | | Return Values : E_OK - success +--------------------------------------------------------------------------*/ -int set_item_userptr(ITEM * item, const void * userptr) +int set_item_userptr(ITEM * item, void * userptr) { Normalize_Item(item)->userptr = userptr; RETURN( E_OK ); @@ -46,7 +48,7 @@ int set_item_userptr(ITEM * item, const void * userptr) /*--------------------------------------------------------------------------- | Facility : libnmenu -| Function : const void *item_userptr(const ITEM *item) +| Function : void *item_userptr(const ITEM *item) | | Description : Return the pointer that is reserved in any item to store | application relevant informations. @@ -54,7 +56,7 @@ int set_item_userptr(ITEM * item, const void * userptr) | Return Values : Value of the pointer. If no such pointer has been set, | NULL is returned. +--------------------------------------------------------------------------*/ -const void *item_userptr(const ITEM * item) +void *item_userptr(const ITEM * item) { return Normalize_Item(item)->userptr; } diff --git a/lib/libmenu/m_item_val.c b/lib/libmenu/m_item_val.c index bc5afdcbcff..2fb0123024d 100644 --- a/lib/libmenu/m_item_val.c +++ b/lib/libmenu/m_item_val.c @@ -1,3 +1,5 @@ +/* $OpenBSD: m_item_val.c,v 1.3 1997/12/03 05:31:22 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses menu library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -21,13 +23,13 @@ +-----------------------------------------------------------------------------*/ /*************************************************************************** -* Module menu_item_val * +* Module m_item_val * * Set and get menus item values * ***************************************************************************/ #include "menu.priv.h" -MODULE_ID("Id: m_item_val.c,v 1.4 1997/05/01 16:47:26 juergen Exp $") +MODULE_ID("Id: m_item_val.c,v 1.5 1997/10/21 08:44:31 juergen Exp $") /*--------------------------------------------------------------------------- | Facility : libnmenu diff --git a/lib/libmenu/m_item_vis.c b/lib/libmenu/m_item_vis.c index 3829be4a33c..92c6cad30ab 100644 --- a/lib/libmenu/m_item_vis.c +++ b/lib/libmenu/m_item_vis.c @@ -1,3 +1,5 @@ +/* $OpenBSD: m_item_vis.c,v 1.3 1997/12/03 05:31:22 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses menu library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -21,13 +23,13 @@ +-----------------------------------------------------------------------------*/ /*************************************************************************** -* Module menu_item_vis * +* Module m_item_vis * * Tell if menu item is visible * ***************************************************************************/ #include "menu.priv.h" -MODULE_ID("Id: m_item_vis.c,v 1.6 1997/05/01 16:47:26 juergen Exp $") +MODULE_ID("Id: m_item_vis.c,v 1.7 1997/10/21 08:44:31 juergen Exp $") /*--------------------------------------------------------------------------- | Facility : libnmenu diff --git a/lib/libmenu/m_items.c b/lib/libmenu/m_items.c index 0387adbc355..e1b26097227 100644 --- a/lib/libmenu/m_items.c +++ b/lib/libmenu/m_items.c @@ -1,3 +1,5 @@ +/* $OpenBSD: m_items.c,v 1.3 1997/12/03 05:31:23 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses menu library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -21,13 +23,13 @@ +-----------------------------------------------------------------------------*/ /*************************************************************************** -* Module menu_items * +* Module m_items * * Connect and disconnect items to and from menus * ***************************************************************************/ #include "menu.priv.h" -MODULE_ID("Id: m_items.c,v 1.4 1997/05/01 16:47:26 juergen Exp $") +MODULE_ID("Id: m_items.c,v 1.5 1997/10/21 08:44:31 juergen Exp $") /*--------------------------------------------------------------------------- | Facility : libnmenu diff --git a/lib/libmenu/m_new.c b/lib/libmenu/m_new.c index 03955a37cc2..c5ba00f84de 100644 --- a/lib/libmenu/m_new.c +++ b/lib/libmenu/m_new.c @@ -1,3 +1,5 @@ +/* $OpenBSD: m_new.c,v 1.3 1997/12/03 05:31:23 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses menu library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -21,13 +23,13 @@ +-----------------------------------------------------------------------------*/ /*************************************************************************** -* Module menu_new * +* Module m_new * * Creation and destruction of new menus * ***************************************************************************/ #include "menu.priv.h" -MODULE_ID("Id: m_new.c,v 1.5 1997/05/01 16:47:26 juergen Exp $") +MODULE_ID("Id: m_new.c,v 1.6 1997/10/21 08:44:31 juergen Exp $") /*--------------------------------------------------------------------------- | Facility : libnmenu diff --git a/lib/libmenu/m_opts.c b/lib/libmenu/m_opts.c index cbfbf05d230..d97505001a9 100644 --- a/lib/libmenu/m_opts.c +++ b/lib/libmenu/m_opts.c @@ -1,3 +1,5 @@ +/* $OpenBSD: m_opts.c,v 1.3 1997/12/03 05:31:24 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses menu library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -21,13 +23,13 @@ +-----------------------------------------------------------------------------*/ /*************************************************************************** -* Module menu_opts * +* Module m_opts * * Menus option routines * ***************************************************************************/ #include "menu.priv.h" -MODULE_ID("Id: m_opts.c,v 1.6 1997/05/01 16:47:26 juergen Exp $") +MODULE_ID("Id: m_opts.c,v 1.7 1997/10/21 08:44:31 juergen Exp $") /*--------------------------------------------------------------------------- | Facility : libnmenu diff --git a/lib/libmenu/m_pad.c b/lib/libmenu/m_pad.c new file mode 100644 index 00000000000..4bc28bdb9b3 --- /dev/null +++ b/lib/libmenu/m_pad.c @@ -0,0 +1,82 @@ +/* $OpenBSD: m_pad.c,v 1.1 1997/12/03 05:31:24 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| The ncurses menu library is Copyright (C) 1995-1997 | +| by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | +| All Rights Reserved. | +| | +| Permission to use, copy, modify, and distribute this software and its | +| documentation for any purpose and without fee is hereby granted, provided | +| that the above copyright notice appear in all copies and that both that | +| copyright notice and this permission notice appear in supporting | +| documentation, and that the name of the above listed copyright holder(s) not | +| be used in advertising or publicity pertaining to distribution of the | +| software without specific, written prior permission. | +| | +| THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO | +| THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- | +| NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR | +| ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- | +| SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, | +| NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH | +| THE USE OR PERFORMANCE OF THIS SOFTWARE. | ++-----------------------------------------------------------------------------*/ + +/*************************************************************************** +* Module m_pad * +* Control menus padding character * +***************************************************************************/ + +#include "menu.priv.h" + +MODULE_ID("Id: m_pad.c,v 1.1 1997/10/21 08:48:28 juergen Exp $") + +/* Macro to redraw menu if it is posted and changed */ +#define Refresh_Menu(menu) \ + if ( (menu) && ((menu)->status & _POSTED) )\ + {\ + _nc_Draw_Menu( menu );\ + _nc_Show_Menu( menu );\ + } + +/*--------------------------------------------------------------------------- +| 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 +| character. +| +| Return Values : E_OK - success +| E_BAD_ARGUMENT - an invalid value has been passed ++--------------------------------------------------------------------------*/ +int set_menu_pad(MENU *menu, int pad) +{ + bool do_refresh = (menu != (MENU*)0); + + if (!isprint((unsigned char)pad)) + RETURN(E_BAD_ARGUMENT); + + Normalize_Menu( menu ); + menu->pad = pad; + + if (do_refresh) + Refresh_Menu( menu ); + + RETURN(E_OK); +} + +/*--------------------------------------------------------------------------- +| Facility : libnmenu +| Function : int menu_pad(const MENU *menu) +| +| Description : Return the value of the padding character +| +| Return Values : The pad character ++--------------------------------------------------------------------------*/ +int menu_pad(const MENU * menu) +{ + return (Normalize_Menu( menu ) -> pad); +} + +/* m_pad.c ends here */ diff --git a/lib/libmenu/m_pattern.c b/lib/libmenu/m_pattern.c new file mode 100644 index 00000000000..a57c0e18603 --- /dev/null +++ b/lib/libmenu/m_pattern.c @@ -0,0 +1,109 @@ +/* $OpenBSD: m_pattern.c,v 1.1 1997/12/03 05:31:25 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| The ncurses menu library is Copyright (C) 1995-1997 | +| by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | +| All Rights Reserved. | +| | +| Permission to use, copy, modify, and distribute this software and its | +| documentation for any purpose and without fee is hereby granted, provided | +| that the above copyright notice appear in all copies and that both that | +| copyright notice and this permission notice appear in supporting | +| documentation, and that the name of the above listed copyright holder(s) not | +| be used in advertising or publicity pertaining to distribution of the | +| software without specific, written prior permission. | +| | +| THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO | +| THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- | +| NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR | +| ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- | +| SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, | +| NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH | +| THE USE OR PERFORMANCE OF THIS SOFTWARE. | ++-----------------------------------------------------------------------------*/ + +/*************************************************************************** +* Module m_pattern * +* Pattern matching handling * +***************************************************************************/ + +#include "menu.priv.h" + +MODULE_ID("Id: m_pattern.c,v 1.1 1997/10/21 08:44:31 juergen Exp $") + +/*--------------------------------------------------------------------------- +| 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 +| EmptyString - if there is a pattern buffer but no +| pattern is stored +| PatternString - as expected ++--------------------------------------------------------------------------*/ +char *menu_pattern(const MENU * menu) +{ + return (menu ? (menu->pattern ? menu->pattern : "") : (char *)0); +} + +/*--------------------------------------------------------------------------- +| 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. +| +| Return Values : E_OK - success +| E_BAD_ARGUMENT - invalid menu or pattern pointer +| E_NOT_CONNECTED - no items connected to menu +| E_BAD_STATE - menu in user hook routine +| E_NO_MATCH - no item matches pattern ++--------------------------------------------------------------------------*/ +int set_menu_pattern(MENU *menu, const char *p) +{ + ITEM *matchitem; + int matchpos; + + if (!menu || !p) + RETURN(E_BAD_ARGUMENT); + + if (!(menu->items)) + RETURN(E_NOT_CONNECTED); + + if ( menu->status & _IN_DRIVER ) + RETURN(E_BAD_STATE); + + Reset_Pattern(menu); + + if (!(*p)) + { + pos_menu_cursor(menu); + RETURN(E_OK); + } + + if (menu->status & _LINK_NEEDED) + _nc_Link_Items(menu); + + matchpos = menu->toprow; + matchitem = menu->curitem; + assert(matchitem); + + while(*p) + { + if ( !isprint(*p) || + (_nc_Match_Next_Character_In_Item_Name(menu,*p,&matchitem) != E_OK) ) + { + Reset_Pattern(menu); + pos_menu_cursor(menu); + RETURN(E_NO_MATCH); + } + p++; + } + + /* This is reached if there was a match. So we position to the new item */ + Adjust_Current_Item(menu,matchpos,matchitem); + RETURN(E_OK); +} + +/* m_pattern.c ends here */ diff --git a/lib/libmenu/m_post.c b/lib/libmenu/m_post.c index b7bcdc66276..7ec452784d9 100644 --- a/lib/libmenu/m_post.c +++ b/lib/libmenu/m_post.c @@ -1,3 +1,5 @@ +/* $OpenBSD: m_post.c,v 1.3 1997/12/03 05:31:25 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses menu library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -21,13 +23,13 @@ +-----------------------------------------------------------------------------*/ /*************************************************************************** -* Module menu_post * +* Module m_post * * Write or erase menus from associated subwindows * ***************************************************************************/ #include "menu.priv.h" -MODULE_ID("Id: m_post.c,v 1.12 1997/05/01 16:47:26 juergen Exp $") +MODULE_ID("Id: m_post.c,v 1.13 1997/10/21 08:44:31 juergen Exp $") /*--------------------------------------------------------------------------- | Facility : libnmenu diff --git a/lib/libmenu/m_req_name.c b/lib/libmenu/m_req_name.c index dfc8a36c9fd..35eeffb58af 100644 --- a/lib/libmenu/m_req_name.c +++ b/lib/libmenu/m_req_name.c @@ -1,3 +1,5 @@ +/* $OpenBSD: m_req_name.c,v 1.2 1997/12/03 05:31:25 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses menu library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -21,13 +23,13 @@ +-----------------------------------------------------------------------------*/ /*************************************************************************** -* Module menu_request_name * +* Module m_request_name * * Routines to handle external names of menu requests * ***************************************************************************/ #include "menu.priv.h" -MODULE_ID("Id: m_req_name.c,v 1.8 1997/05/01 16:47:26 juergen Exp $") +MODULE_ID("Id: m_req_name.c,v 1.9 1997/10/21 08:44:31 juergen Exp $") static const char *request_names[ MAX_MENU_COMMAND - MIN_MENU_COMMAND + 1 ] = { "LEFT_ITEM" , diff --git a/lib/libmenu/m_scale.c b/lib/libmenu/m_scale.c new file mode 100644 index 00000000000..65f1bbc3cc7 --- /dev/null +++ b/lib/libmenu/m_scale.c @@ -0,0 +1,63 @@ +/* $OpenBSD: m_scale.c,v 1.1 1997/12/03 05:31:26 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| The ncurses menu library is Copyright (C) 1995-1997 | +| by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | +| All Rights Reserved. | +| | +| Permission to use, copy, modify, and distribute this software and its | +| documentation for any purpose and without fee is hereby granted, provided | +| that the above copyright notice appear in all copies and that both that | +| copyright notice and this permission notice appear in supporting | +| documentation, and that the name of the above listed copyright holder(s) not | +| be used in advertising or publicity pertaining to distribution of the | +| software without specific, written prior permission. | +| | +| THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO | +| THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- | +| NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR | +| ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- | +| SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, | +| NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH | +| THE USE OR PERFORMANCE OF THIS SOFTWARE. | ++-----------------------------------------------------------------------------*/ + +/*************************************************************************** +* Module m_scale * +* Menu scaling routine * +***************************************************************************/ + +#include "menu.priv.h" + +MODULE_ID("Id: m_scale.c,v 1.1 1997/10/21 08:44:31 juergen Exp $") + +/*--------------------------------------------------------------------------- +| Facility : libnmenu +| Function : int scale_menu(const MENU *menu) +| +| Description : Returns the minimum window size necessary for the +| subwindow of menu. +| +| Return Values : E_OK - success +| E_BAD_ARGUMENT - invalid menu pointer +| E_NOT_CONNECTED - no items are connected to menu ++--------------------------------------------------------------------------*/ +int scale_menu(const MENU *menu, int *rows, int *cols) +{ + if (!menu) + RETURN( E_BAD_ARGUMENT ); + + if (menu->items && *(menu->items)) + { + if (rows) + *rows = menu->height; + if (cols) + *cols = menu->width; + RETURN(E_OK); + } + else + RETURN( E_NOT_CONNECTED ); +} + +/* m_scale.c ends here */ + diff --git a/lib/libmenu/m_spacing.c b/lib/libmenu/m_spacing.c index 3b5b313d26e..ed846088825 100644 --- a/lib/libmenu/m_spacing.c +++ b/lib/libmenu/m_spacing.c @@ -1,3 +1,5 @@ +/* $OpenBSD: m_spacing.c,v 1.2 1997/12/03 05:31:26 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses menu library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -21,13 +23,13 @@ +-----------------------------------------------------------------------------*/ /*************************************************************************** -* Module menu_spacing * +* Module m_spacing * * Routines to handle spacing between entries * ***************************************************************************/ #include "menu.priv.h" -MODULE_ID("Id: m_spacing.c,v 1.7 1997/05/01 16:47:26 juergen Exp $") +MODULE_ID("Id: m_spacing.c,v 1.8 1997/10/21 08:40:51 juergen Exp $") #define MAX_SPC_DESC ((TABSIZE) ? (TABSIZE) : 8) #define MAX_SPC_COLS ((TABSIZE) ? (TABSIZE) : 8) diff --git a/lib/libmenu/m_sub.c b/lib/libmenu/m_sub.c new file mode 100644 index 00000000000..d08e144f6c5 --- /dev/null +++ b/lib/libmenu/m_sub.c @@ -0,0 +1,72 @@ +/* $OpenBSD: m_sub.c,v 1.1 1997/12/03 05:31:27 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| The ncurses menu library is Copyright (C) 1995-1997 | +| by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | +| All Rights Reserved. | +| | +| Permission to use, copy, modify, and distribute this software and its | +| documentation for any purpose and without fee is hereby granted, provided | +| that the above copyright notice appear in all copies and that both that | +| copyright notice and this permission notice appear in supporting | +| documentation, and that the name of the above listed copyright holder(s) not | +| be used in advertising or publicity pertaining to distribution of the | +| software without specific, written prior permission. | +| | +| THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO | +| THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- | +| NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR | +| ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- | +| SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, | +| NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH | +| THE USE OR PERFORMANCE OF THIS SOFTWARE. | ++-----------------------------------------------------------------------------*/ + +/*************************************************************************** +* Module m_sub * +* Menus subwindow association routines * +***************************************************************************/ + +#include "menu.priv.h" + +MODULE_ID("Id: m_sub.c,v 1.1 1997/10/21 08:44:31 juergen Exp $") + +/*--------------------------------------------------------------------------- +| 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 ++--------------------------------------------------------------------------*/ +int set_menu_sub(MENU *menu, WINDOW *win) +{ + if (menu) + { + if ( menu->status & _POSTED ) + RETURN(E_POSTED); + menu->usersub = win; + _nc_Calculate_Item_Length_and_Width(menu); + } + else + _nc_Default_Menu.usersub = win; + + RETURN(E_OK); +} + +/*--------------------------------------------------------------------------- +| 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 ++--------------------------------------------------------------------------*/ +WINDOW *menu_sub(const MENU * menu) +{ + const MENU* m = Normalize_Menu(menu); + return Get_Menu_Window(m); +} + +/* m_sub.c ends here */ diff --git a/lib/libmenu/m_userptr.c b/lib/libmenu/m_userptr.c index e04ce7951f8..3c461c7182f 100644 --- a/lib/libmenu/m_userptr.c +++ b/lib/libmenu/m_userptr.c @@ -1,3 +1,5 @@ +/* $OpenBSD: m_userptr.c,v 1.3 1997/12/03 05:31:27 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses menu library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -21,24 +23,24 @@ +-----------------------------------------------------------------------------*/ /*************************************************************************** -* Module menu_userptr * +* Module m_userptr * * Associate application data with menus * ***************************************************************************/ #include "menu.priv.h" -MODULE_ID("Id: m_userptr.c,v 1.5 1997/05/01 16:47:26 juergen Exp $") +MODULE_ID("Id: m_userptr.c,v 1.7 1997/10/21 08:44:31 juergen Exp $") /*--------------------------------------------------------------------------- | Facility : libnmenu -| Function : int set_menu_userptr(MENU *menu, const void *userptr) +| Function : int set_menu_userptr(MENU *menu, void *userptr) | | Description : Set the pointer that is reserved in any menu to store | application relevant informations. | | Return Values : E_OK - success +--------------------------------------------------------------------------*/ -int set_menu_userptr(MENU * menu, const void * userptr) +int set_menu_userptr(MENU * menu, void * userptr) { Normalize_Menu(menu)->userptr = userptr; RETURN( E_OK ); @@ -46,7 +48,7 @@ int set_menu_userptr(MENU * menu, const void * userptr) /*--------------------------------------------------------------------------- | Facility : libnmenu -| Function : char *menu_userptr(const MENU *menu) +| Function : void *menu_userptr(const MENU *menu) | | Description : Return the pointer that is reserved in any menu to | store application relevant informations. @@ -54,7 +56,7 @@ int set_menu_userptr(MENU * menu, const void * userptr) | Return Values : Value of the pointer. If no such pointer has been set, | NULL is returned +--------------------------------------------------------------------------*/ -const void *menu_userptr(const MENU * menu) +void *menu_userptr(const MENU * menu) { return( Normalize_Menu(menu)->userptr); } diff --git a/lib/libmenu/m_win.c b/lib/libmenu/m_win.c index 7107e76bb99..edf3861be4f 100644 --- a/lib/libmenu/m_win.c +++ b/lib/libmenu/m_win.c @@ -1,3 +1,5 @@ +/* $OpenBSD: m_win.c,v 1.3 1997/12/03 05:31:28 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses menu library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -21,13 +23,13 @@ +-----------------------------------------------------------------------------*/ /*************************************************************************** -* Module menu_win * -* Menus window and subwindow association routines * +* Module m_win * +* Menus window association routines * ***************************************************************************/ #include "menu.priv.h" -MODULE_ID("Id: m_win.c,v 1.5 1997/05/01 16:47:26 juergen Exp $") +MODULE_ID("Id: m_win.c,v 1.6 1997/10/21 08:44:31 juergen Exp $") /*--------------------------------------------------------------------------- | Facility : libnmenu @@ -67,70 +69,4 @@ WINDOW *menu_win(const MENU *menu) return (m->userwin ? m->userwin : stdscr); } -/*--------------------------------------------------------------------------- -| 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 -+--------------------------------------------------------------------------*/ -int set_menu_sub(MENU *menu, WINDOW *win) -{ - if (menu) - { - if ( menu->status & _POSTED ) - RETURN(E_POSTED); - menu->usersub = win; - _nc_Calculate_Item_Length_and_Width(menu); - } - else - _nc_Default_Menu.usersub = win; - - RETURN(E_OK); -} - -/*--------------------------------------------------------------------------- -| 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 -+--------------------------------------------------------------------------*/ -WINDOW *menu_sub(const MENU * menu) -{ - const MENU* m = Normalize_Menu(menu); - return Get_Menu_Window(m); -} - -/*--------------------------------------------------------------------------- -| Facility : libnmenu -| Function : int scale_menu(const MENU *menu) -| -| Description : Returns the minimum window size necessary for the -| subwindow of menu. -| -| Return Values : E_OK - success -| E_BAD_ARGUMENT - invalid menu pointer -| E_NOT_CONNECTED - no items are connected to menu -+--------------------------------------------------------------------------*/ -int scale_menu(const MENU *menu, int *rows, int *cols) -{ - if (!menu) - RETURN( E_BAD_ARGUMENT ); - - if (menu->items && *(menu->items)) - { - if (rows) - *rows = menu->height; - if (cols) - *cols = menu->width; - RETURN(E_OK); - } - else - RETURN( E_NOT_CONNECTED ); -} - /* m_win.c ends here */ diff --git a/lib/libmenu/menu.h b/lib/libmenu/menu.h index b63c7406f61..206676347aa 100644 --- a/lib/libmenu/menu.h +++ b/lib/libmenu/menu.h @@ -1,3 +1,5 @@ +/* $OpenBSD: menu.h,v 1.3 1997/12/03 05:31:28 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses menu library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -46,7 +48,7 @@ typedef int Item_Options; typedef struct { - char* str; + const char* str; unsigned short length; } TEXT; @@ -55,7 +57,7 @@ typedef struct tagITEM TEXT name; /* name of menu item */ TEXT description; /* description of item, optional in display */ struct tagMENU *imenu; /* Pointer to parent menu */ - const void *userptr; /* Pointer to user defined per item data */ + 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 */ @@ -107,7 +109,7 @@ typedef struct tagMENU Menu_Hook iteminit; Menu_Hook itemterm; - const void *userptr; /* Pointer to menus user data */ + void *userptr; /* Pointer to menus user data */ char *mark; /* Pointer to marker string */ Menu_Options opt; /* Menu options */ @@ -178,10 +180,10 @@ extern const char *item_description(const ITEM *), *menu_mark(const MENU *), *menu_request_name(int); -extern char *menu_pattern(const MENU *); +extern char *menu_pattern(const MENU *); -extern const void *menu_userptr(const MENU *), - *item_userptr(const ITEM *); +extern void *menu_userptr(const MENU *), + *item_userptr(const ITEM *); extern chtype menu_back(const MENU *), menu_fore(const MENU *), @@ -204,7 +206,7 @@ extern int free_item(ITEM *), set_item_init(MENU *,void(*)(MENU *)), set_item_opts(ITEM *,Item_Options), set_item_term(MENU *,void(*)(MENU *)), - set_item_userptr(ITEM *, const void *), + set_item_userptr(ITEM *, void *), set_item_value(ITEM *,bool), set_menu_back(MENU *,chtype), set_menu_fore(MENU *,chtype), @@ -218,7 +220,7 @@ extern int free_item(ITEM *), set_menu_pattern(MENU *,const char *), set_menu_sub(MENU *,WINDOW *), set_menu_term(MENU *,void(*)(MENU *)), - set_menu_userptr(MENU *,const void *), + set_menu_userptr(MENU *,void *), set_menu_win(MENU *,WINDOW *), set_top_row(MENU *,int), top_row(const MENU *), diff --git a/lib/libmenu/menu.priv.h b/lib/libmenu/menu.priv.h index e478e0c0ff7..f8021da4506 100644 --- a/lib/libmenu/menu.priv.h +++ b/lib/libmenu/menu.priv.h @@ -1,3 +1,5 @@ +/* $OpenBSD: menu.priv.h,v 1.3 1997/12/03 05:31:28 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses menu library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -97,3 +99,4 @@ extern bool _nc_Connect_Items(MENU *, ITEM **); extern void _nc_Disconnect_Items(MENU *); extern void _nc_New_TopRow_and_CurrentItem(MENU *,int, ITEM *); extern void _nc_Link_Items(MENU *); +extern int _nc_Match_Next_Character_In_Item_Name(MENU*,int,ITEM**); diff --git a/lib/libmenu/mf_common.h b/lib/libmenu/mf_common.h index 1e0b3caf6bf..72f7344342a 100644 --- a/lib/libmenu/mf_common.h +++ b/lib/libmenu/mf_common.h @@ -1,3 +1,5 @@ +/* $OpenBSD: mf_common.h,v 1.3 1997/12/03 05:31:29 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses menu library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -31,15 +33,12 @@ #include <assert.h> #include <string.h> #include <ctype.h> +#include <errno.h> -#if !HAVE_EXTERN_ERRNO +#if DECL_ERRNO extern int errno; #endif -#if HAVE_EXTERN_ERRNO -#include <errno.h> -#endif - /* in case of debug version we ignore the suppression of assertions */ #ifdef TRACE # ifdef NDEBUG @@ -60,6 +59,7 @@ extern int errno; #define MAX_REGULAR_CHARACTER (0xff) #define SET_ERROR(code) (errno=(code)) +#define GET_ERROR() (errno) #define RETURN(code) return( SET_ERROR(code) ) /* The few common values in the status fields for menus and forms */ diff --git a/lib/libmenu/shlib_version b/lib/libmenu/shlib_version index 1edea46de91..893819d18ff 100644 --- a/lib/libmenu/shlib_version +++ b/lib/libmenu/shlib_version @@ -1,2 +1,2 @@ major=1 -minor=0 +minor=1 |