home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c070 / 4.ddi / TOOLS.4 / TCTSRC1.EXE / EDREMKEY.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  2.2 KB  |  72 lines

  1. /**
  2. *
  3. * Name        EDREMKEY -- Remove an edit key from the edit key list
  4. *
  5. * Synopsis    ercode = edremkey(key_sequence)
  6. *
  7. *        int ercode        Returned error code.
  8. *        const KEY_SEQUENCE  The character and scan code of the
  9. *            *pkey_sequence  key sequence to be removed.
  10. *
  11. * Description    EDREMKEY removes the edit key list member represented
  12. *        by the specified character and scan code.  If the
  13. *        element is successfully removed, the return code is
  14. *        ED_NO_ERROR; if there is no corresponding element, the
  15. *        return code is ED_NO_KEY.
  16. *
  17. * Returns    ercode        Possible values are:
  18. *                ED_NO_ERROR - success.
  19. *                ED_NO_KEY    - no corresponding key
  20. *                sequence was found in the list.
  21. *
  22. * Version    6.00 (C)Copyright Blaise Computing Inc.  1989
  23. *
  24. **/
  25. #include <bedit.h>
  26.  
  27. int edremkey(pkey_sequence)
  28. const KEY_SEQUENCE *pkey_sequence;
  29. {
  30.     ED_KEY  *pfound_key;
  31.     ED_LIST *pfound_node;
  32.  
  33.     pfound_key = edretkey(pkey_sequence);
  34.     if (pfound_key == NIL)
  35.         /* The key sequence is not in the edit list.        */
  36.     return(ED_NO_KEY);
  37.  
  38.     /* Locate the edit key list node corresponding to the edit  */
  39.     /* key given.                            */
  40.  
  41.     for (pfound_node = b_pkey_root;
  42.      (pfound_node != NIL) && (&pfound_node->edit_key != pfound_key);
  43.      pfound_node = pfound_node->pnext)
  44.     ;
  45.  
  46.     /* If the member is the first element of the list (that is, */
  47.     /* pointed to by the root), just alter the root to point to */
  48.     /* the next element of the list.  If it is not the first    */
  49.     /* element of the list, surgically remove it from the edit  */
  50.     /* key list by altering the pnext and pprev pointers of the */
  51.     /* nodes surrounding it.                    */
  52.  
  53.     if (b_pkey_root == pfound_node)
  54.     {
  55.     b_pkey_root = b_pkey_root->pnext;
  56.     b_pkey_root->pprev = NIL;
  57.     pfound_node->pnext = pfound_node->pprev = NIL;
  58.     }
  59.     else
  60.     {
  61.     if (pfound_node->pprev != NIL)
  62.         pfound_node->pprev->pnext = pfound_node->pnext;
  63.     if (pfound_node->pnext != NIL)
  64.         pfound_node->pnext->pprev = pfound_node->pprev;
  65.     pfound_node->pnext = pfound_node->pprev = NIL;
  66.     }
  67.     free(pfound_key->edit_actions.pactions);
  68.     free(pfound_key);
  69.     free(pfound_node);
  70.     return(ED_NO_ERROR);
  71. }
  72.