home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name MNITMKEY -- Add both an item and a key binding
- * to a menu.
- *
- * Synopsis presult = mnitmkey (pmenu, row, col, option, pstring,
- * pkeys, action);
- *
- * BMENU *presult Pointer to menu which item and key(s)
- * were just added to, or NIL for failure.
- * BMENU *pmenu Pointer to menu to which to add item
- * and key(s).
- * int row, Row and column (relative to menu's
- * col window data area) at which to both
- * place the item, and bind the key(s).
- * int option The bitwise OR-ing of the following values:
- * MN_PROTECT
- * Item is protected.
- * MN_NOPROTECT
- * Item is not protected.
- * MN_CHAR_ATTR
- * PSTRING contains character/attribute
- * pairs, terminated by a '\0' in a
- * character cell.
- * MN_CHARS_ONLY
- * PSTRING contains a normal '\0'
- * terminated string.
- * const char *pstring
- * Text of the item.
- * const char *pkeys
- * List of keys that should bind to this
- * item.
- * int action The action which should be taken
- * when one of the keys in *pkeys is
- * pressed:
- * The bitwise OR-ing of the
- * following:
- * MN_TRANSMIT, MN_BEEP,
- * MN_DISABLE, and
- * MN_ABORT.
- *
- * Description This function writes an item to a menu, and also binds
- * keys to the item. An example is probably best here:
- *
- * The call:
- * presult = mnitmkey (pmenu, 0, 0, MN_NOPROTECT, "Open",
- * "Oo", MN_BEEP);
- *
- * Will add the text "Open" to the menu at (0,0), and
- * bind both the upper case and lower case "O" to select
- * the item and beep.
- *
- * The "key binding" means that when MNREAD is being
- * used and the user types an "o" or an "O", the
- * selection bar will move to the "Open" item and
- * beep.
- *
- * An error occurs if row or col exceeds the menu's
- * window dimensions.
- *
- * Returns presult Pointer to changed menu, or
- * NIL if failure.
- * b_wnerr Possible values:
- * (No change) Success.
- * MN_BAD_MENU pmenu is invalid.
- * WN_BAD_WIN pmenu's window is invalid.
- * WN_ILL_DIM row or col out of range
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1987,1989
- *
- **/
-
-
- #include <bkeybrd.h>
- #include <bmenu.h>
-
- #define NUL '\0'
-
-
- BMENU *mnitmkey (pmenu, row, col, option, pstring, pkeys, action)
- BMENU *pmenu;
- int row, col, option;
- const char *pstring, *pkeys;
- int action;
- {
- char c;
- int err;
-
- /* Add item to menu. */
- if (NIL == mnitem (pmenu, row, col, option, pstring))
- return (NIL);
-
- /* Add all of the characters pointed to by *pkeys */
- /* into the menu's key binding list. */
- while ((c = *pkeys++) != NUL)
- if (NIL == mnkey (pmenu, row, col,
- kbcharof (c), kbscanof (c),
- /* Make sure the movement portion of the action is */
- /* MN_SELECT. */
- (action & ~MN_MOVE_MASK) | MN_SELECT, MN_ADD))
- {
- err = b_wnerr;
- mnitem (pmenu, row, col, option, NIL);
- wnreterr (err);
- }
-
- return (pmenu);
- }