DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
ETI menus

Changing and fetching the pattern buffer

Remember that the pattern buffer is used to make the first item that matches the pattern be the current item. In general, to match the current menu item, your application program inserts characters into the pattern buffer that have been
passed to the menu driver from the user's data entry. As an alternative, you can insert characters into the pattern buffer with the function set_menu_pattern.

SYNOPSIS

   int set_menu_pattern (menu, pattern)
   MENU * menu;
   char * pattern;
   

char * menu_pattern (menu) MENU * menu;

Function set_menu_pattern first clears the pattern buffer and then adds the characters in pattern to the buffer until pattern is exhausted. The function next tries to find the first item that matches the pattern. If it does not find a complete match, the pattern buffer is cleared and the current item does not change. If pattern is the null string (""), the pattern buffer is simply cleared. The pattern buffer is automatically cleared whenever

If successful, function set_menu_pattern returns E_OK. If an error occurs, function set_menu_pattern returns one of the following:

E_SYSTEM_ERROR
system error

E_BAD_ARGUMENT
NULL menu pointer or NULL pattern pointer

E_NO_MATCH
complete match failed
Function menu_pattern returns the value of the string in the pattern buffer. If the pattern buffer is empty (the null string ""), it returns the null string (""). If the menu pointer argument is NULL, it returns NULL, that is, (char *) 0.

To determine if your user has entered data that matches an item, you might write a routine that uses set_menu_pattern, as follows:

   int find_match (m, newpattern)  /* returns TRUE or
       FALSE */
   MENU * m;
   char * newpattern;
   {
          return set_menu_pattern(m, newpattern) == E_OK;
   }
If the newpattern matches a menu item, function set_menu_pattern returns E_OK and hence find_match returns TRUE. In addition, find_match advances the current item to the matching item.
Next topic: Manipulating the menu user pointer
Previous topic: Returning cursor to its correct position for menu driver processing

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004