home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name EDREMKEY -- Remove an edit key from the edit key list
- *
- * Synopsis ercode = edremkey(key_sequence)
- *
- * int ercode Returned error code.
- * const KEY_SEQUENCE The character and scan code of the
- * *pkey_sequence key sequence to be removed.
- *
- * Description EDREMKEY removes the edit key list member represented
- * by the specified character and scan code. If the
- * element is successfully removed, the return code is
- * ED_NO_ERROR; if there is no corresponding element, the
- * return code is ED_NO_KEY.
- *
- * Returns ercode Possible values are:
- * ED_NO_ERROR - success.
- * ED_NO_KEY - no corresponding key
- * sequence was found in the list.
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1989
- *
- **/
- #include <bedit.h>
-
- int edremkey(pkey_sequence)
- const KEY_SEQUENCE *pkey_sequence;
- {
- ED_KEY *pfound_key;
- ED_LIST *pfound_node;
-
- pfound_key = edretkey(pkey_sequence);
- if (pfound_key == NIL)
- /* The key sequence is not in the edit list. */
- return(ED_NO_KEY);
-
- /* Locate the edit key list node corresponding to the edit */
- /* key given. */
-
- for (pfound_node = b_pkey_root;
- (pfound_node != NIL) && (&pfound_node->edit_key != pfound_key);
- pfound_node = pfound_node->pnext)
- ;
-
- /* If the member is the first element of the list (that is, */
- /* pointed to by the root), just alter the root to point to */
- /* the next element of the list. If it is not the first */
- /* element of the list, surgically remove it from the edit */
- /* key list by altering the pnext and pprev pointers of the */
- /* nodes surrounding it. */
-
- if (b_pkey_root == pfound_node)
- {
- b_pkey_root = b_pkey_root->pnext;
- b_pkey_root->pprev = NIL;
- pfound_node->pnext = pfound_node->pprev = NIL;
- }
- else
- {
- if (pfound_node->pprev != NIL)
- pfound_node->pprev->pnext = pfound_node->pnext;
- if (pfound_node->pnext != NIL)
- pfound_node->pnext->pprev = pfound_node->pprev;
- pfound_node->pnext = pfound_node->pprev = NIL;
- }
- free(pfound_key->edit_actions.pactions);
- free(pfound_key);
- free(pfound_node);
- return(ED_NO_ERROR);
- }