int set_menu_pattern(MENU *m, char *s) { int top; ITEM *current; if (!m || !s) { return (E_BAD_ARGUMENT); } if (!Items(m)) { return (E_NOT_CONNECTED); } if (Indriver(m)) { return (E_BAD_STATE); } IthPattern(m, 0) = '\0'; Pindex(m) = 0; if (*s == '\0') { _position_cursor(m); return (E_OK); } if (LinkNeeded(m)) { _link_items(m); } top = Top(m); current = Current(m); for (; *s; s++) { if (_match(m, *s, ¤t) != E_OK) { IthPattern(m, 0) = '\0'; Pindex(m) = 0; _position_cursor(m); return (E_NO_MATCH); } } _chk_current(m, &top, current); _affect_change(m, top, current); return (E_OK); }
void _show(MENU *m) { int r, c; WINDOW *us; if (Posted(m) || Indriver(m)) { (void) mvderwin(Sub(m), Top(m), 0); us = US(m); getmaxyx(us, r, c); r = min(Height(m), r); c = min(Width(m), c); (void) copywin(Sub(m), us, 0, 0, 0, 0, r-1, c-1, FALSE); _position_cursor(m); } }