Changeset 8a921b5 for keymap.c


Ignore:
Timestamp:
Mar 22, 2010, 11:13:41 PM (11 years ago)
Author:
Leonid Grinberg <leonidg@mit.edu>
Branches:
master, release-1.6, release-1.7, release-1.8, release-1.9
Children:
6b78afb
Parents:
5643f99
git-author:
Leonid Grinberg <leonidg@mit.edu> (03/21/10 01:12:40)
git-committer:
Leonid Grinberg <leonidg@mit.edu> (03/22/10 23:13:41)
Message:
Add new command unbindkey for removing keybindings
File:
1 edited

Legend:

Unmodified
Added
Removed
  • keymap.c

    rbb0d439 r8a921b5  
    5151  }
    5252  return owl_list_append_element(&km->bindings, kb); 
    53 }
     53
     54}
     55
     56/* removes the binding associated with the keymap */
     57int owl_keymap_remove_binding(owl_keymap *km, const char *keyseq)
     58{
     59  owl_keybinding *kb, *curkb;
     60  int i;
     61
     62  if ((kb = owl_malloc(sizeof(owl_keybinding))) == NULL) return(-1);
     63  if (0 != owl_keybinding_make_keys(kb, keyseq)) {
     64    owl_free(kb);
     65    return(-1);
     66  }
     67
     68  for (i = owl_list_get_size(&km->bindings)-1; i >= 0; i--) {
     69    curkb = owl_list_get_element(&km->bindings, i);
     70    if (owl_keybinding_equal(curkb, kb)) {
     71      owl_list_remove_element(&km->bindings, i);
     72      owl_keybinding_delete(curkb);
     73      return(0);
     74    }
     75  }
     76  return(-2);
     77}
     78
    5479
    5580/* returns a summary line describing this keymap.  the caller must free. */
Note: See TracChangeset for help on using the changeset viewer.