home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name MNDEFKEY -- Add default key bindings to menu.
- *
- * Synopsis presult = mndefkey (pmenu);
- *
- * BMENU *presult Pointer to just-changed BMENU
- * structure, or NIL if failure.
- * BMENU *pmenu Pointer to BMENU to which to add
- * key bindings.
- *
- * Description This function adds default key bindings to a menu.
- *
- * The default bindings are for the UP, DOWN, RIGHT,
- * and LEFT keys to work as they are labeled; for the
- * HOME and END keys to do logical-first and last; for
- * TAB and BACKTAB to do logical-next and previous;
- * for ENTER to transmit the selection; and for ESC to
- * abort the selection.
- *
- * To change the default key bindings, make B_MNKEYMAP
- * point to some key table other than B_MNDEFKEY.
- *
- * Returns presult Pointer to newly-changed BMENU
- * structure, or NIL if failure.
- * b_wnerr Possible values:
- * (No change) Success.
- * MN_BAD_MENU Invalid menu.
- * WN_NO_MEMORY Insufficient memory.
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1987,1989
- *
- **/
-
- #include <bmenu.h>
- #include <bkeys.h>
-
- #define FALSE 0
-
- BMENU *mndefkey (pmenu)
- BMENU *pmenu;
- {
- BKEYTAB *pktab;
-
- /* For each entry in the key map (char code, scan */
- /* code, action) insert in menu's key list. */
- for (pktab = b_mnkeytab;
- pktab->action != MN_INVALID_ACTION;
- pktab++)
- /* Add the key to the keylist if not done. */
- if (mnkey (pmenu, -1, -1, pktab->ch, pktab->scan,
- pktab->action, MN_ADD) == NIL)
- return (NIL);
-
- return (pmenu);
- }
-
-
-
- /**
- *
- * Name b_mndefkey -- Table which contains default
- * key map used by MNDEFKEY.
- *
- * Description This table contains the default menu key map. When
- * MNCREATE is called, MNCREATE calls MNDEFKEY to set
- * up the key map with which the menu is "born".
- *
- * The global variable B_MNKEYTAB points to the current
- * default key map, and is "born" pointing to the
- * key map found below.
- *
- **/
-
- BKEYTAB b_mndefkey [] =
- {
- {KB_C_N_UP, KB_S_N_UP, MN_UP },
- {KB_C_N_DOWN, KB_S_N_DOWN, MN_DOWN },
- {KB_C_N_RIGHT, KB_S_N_RIGHT, MN_RIGHT },
- {KB_C_N_LEFT, KB_S_N_LEFT, MN_LEFT },
- {KB_C_N_HOME, KB_S_N_HOME, MN_FIRST },
- {KB_C_N_END, KB_S_N_END, MN_LAST },
- {KB_C_N_TAB, KB_S_N_TAB, MN_NEXT },
- {KB_C_S_TAB, KB_S_S_TAB, MN_PREVIOUS },
- {KB_C_N_ENTER, KB_S_N_ENTER, MN_TRANSMIT },
- {KB_C_N_ESC, KB_S_N_ESC, MN_ABORT },
-
- {KB_C_N_NEW_UP, KB_S_N_NEW_UP, MN_UP },
- {KB_C_N_NEW_DOWN, KB_S_N_NEW_DOWN, MN_DOWN },
- {KB_C_N_NEW_RIGHT, KB_S_N_NEW_RIGHT, MN_RIGHT },
- {KB_C_N_NEW_LEFT, KB_S_N_NEW_LEFT, MN_LEFT },
- {KB_C_N_NEW_HOME, KB_S_N_NEW_HOME, MN_FIRST },
- {KB_C_N_NEW_END, KB_S_N_NEW_END, MN_LAST },
- {KB_C_N_PADENTER, KB_S_N_PADENTER, MN_TRANSMIT},
-
- {KB_C_N_PGUP, KB_S_N_PGUP, MN_PGUP },
- {KB_C_N_PGDN, KB_S_N_PGDN, MN_PGDN },
- {KB_C_N_NEW_PGUP, KB_S_N_NEW_PGUP, MN_PGUP },
- {KB_C_N_NEW_PGDN, KB_S_N_NEW_PGDN, MN_PGDN },
-
- {KB_C_C_RIGHT, KB_S_C_RIGHT, MN_PGRIGHT},
- {KB_C_C_LEFT, KB_S_C_LEFT, MN_PGLEFT },
- {KB_C_C_NEW_RIGHT, KB_S_C_NEW_RIGHT, MN_PGRIGHT},
- {KB_C_C_NEW_LEFT, KB_S_C_NEW_LEFT, MN_PGLEFT },
-
- {KBNDEF, KBNDEF, MN_INVALID_ACTION}
- };
-
-
-
- /**
- *
- * Name b_mnkeytab -- Variable which points to current
- * default key table used by MNDEFKEY.
- *
- * Description This variable points to the default key map which
- * MNCREATE attaches to each newborn menu. The
- * default for B_MNKEYTAB is to point at the B_MNDEFKEY
- * table.
- *
- **/
-
- BKEYTAB *b_mnkeytab = b_mndefkey;