home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name MNLITKEY -- Add both an item and a key binding
- * to a Lotus-style menu.
- *
- * Synopsis presult = mnlitkey (pmenu, row, col, option, pstring,
- * lrow, lcol, plstring, 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.
- * int lrow, Row and column (relative to menu's
- * lcol window data area) at which to place
- * the item's description.
- * const char *plstring
- * Text of the long description 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, adds a long
- * description to the item, and also binds keys to
- * the item. An example is probably best here:
- *
- * The call:
- * presult = mnlitkey (pmenu, 0, 0, MN_NOPROTECT, "Open",
- * 7, 0, "Open a file",
- * "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.
- *
- * It will also add "Open a file" to the menu data
- * structure, and that string will appear at (7,0) when
- * the highlight bar moves onto "Open" while using
- * MNLREAD.
- *
- * The "key binding" means that when MNREAD/MNLREAD 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 or lrow or lcol 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.
- * MN_NOT_FOUND Internal error.
- * 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 *mnlitkey (pmenu,
- row, col, option, pstring,
- lrow, lcol, plstring,
- pkeys, action)
- BMENU *pmenu;
- int row, col, option;
- const char *pstring;
- int lrow, lcol;
- const char *plstring;
- const char *pkeys;
- int action;
- {
- char c;
- int err;
-
- /* Add the item to the menu. */
- if (NIL == mnlitem (pmenu, row, col, option, pstring,
- lrow, lcol, plstring))
- 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);
- }