|
|
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
E_OK
.
If an error occurs,
function
set_menu_pattern returns
one of the following:
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.