home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name MNDISABL -- Disable keys bound to locations which
- * do not have selectable items.
- *
- * Synopsis presult = mndisabl (pmenu);
- *
- * BMENU *presult Pointer to just-changed BMENU
- * structure, or NIL if failure.
- * BMENU *pmenu Pointer to BMENU in which to
- * disable certain key bindings.
- *
- * Description This function disables keys which are bound to
- * nonexistent or protected items, and enables
- * keys which were previously disabled by MNDISABL,
- * but which now point to valid items.
- *
- * Returns presult Pointer to newly-changed BMENU
- * structure, or NIL if failure.
- * b_wnerr Possible values:
- * (No change) Success.
- * MN_BAD_MENU Invalid menu.
- * MN_BAD_KEY Invalid keymap entry.
- * MN_BAD_ITEM Invalid menu item found.
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1987,1989
- *
- **/
-
-
-
- #include <bmenu.h>
-
-
- BMENU *mndisabl (pmenu)
- BMENU *pmenu;
- {
- BKEYMAP *pkey;
- int code;
-
- /* Validate menu data structures. */
- mnvalidm (pmenu)
-
- /* Go through entire key list... */
- for (pkey = pmenu->pkeys; pkey != NIL; pkey = pkey->next)
- {
- /* Check key signature. */
- if (pkey->signature != MN_KEY_SIGN)
- wnreterr (MN_BAD_KEY);
-
- /* If the key is bound to a particular location, */
- if (MNMOVE (pkey->action) == MN_SELECT)
- {
- /* and there is no selectable item at that */
- /* location... */
- if (mnmchitm (pmenu, NIL, pkey->row, pkey->col, 0, &code) == NIL)
- /* Disable the key if no error walking the item list*/
- {
- if (code == WN_NO_ERROR)
- pkey->action |= MN_TEMP_DISABLE;
- else
- return (NIL);
- }
-
- /* Enable keys which match items now but were */
- /* temporarily disabled in the past. */
- else if (pkey->action & MN_TEMP_DISABLE)
- pkey->action &= ~(MN_TEMP_DISABLE);
- }
- }
-
- return (pmenu);
- }