set_current_item(MENU * menu, ITEM * item) { T((T_CALLED("set_current_item(%p,%p)"), menu, item)); if (menu && item && (item->imenu == menu)) { if (menu->status & _IN_DRIVER) RETURN(E_BAD_STATE); assert(menu->curitem); if (item != menu->curitem) { if (menu->status & _LINK_NEEDED) { /* * Items are available, but they are not linked together. * So we have to link here. */ _nc_Link_Items(menu); } assert(menu->pattern); Reset_Pattern(menu); /* adjust the window to make item visible and update the menu */ Adjust_Current_Item(menu, menu->toprow, item); } } else RETURN(E_BAD_ARGUMENT); RETURN(E_OK); }
set_menu_pattern(MENU * menu, const char *p) { ITEM *matchitem; int matchpos; T((T_CALLED("set_menu_pattern(%p,%s)"), menu, _nc_visbuf(p))); 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(UChar(*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); }