summaryrefslogtreecommitdiff
path: root/lib/libmenu/m_driver.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libmenu/m_driver.c')
-rw-r--r--lib/libmenu/m_driver.c93
1 files changed, 10 insertions, 83 deletions
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;
}