Changeset 8a921b5 for commands.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
  • commands.c

    rf449096 r8a921b5  
    9191              "Use 'show keymaps' to see the existing keymaps.\n"
    9292              "Key sequences may be things like M-C-t or NPAGE.\n\n"
    93               "Ex.: bindkey recv C-b command zwrite -c barnowl"),
     93              "Ex.: bindkey recv C-b command zwrite -c barnowl"
     94              "SEE ALSO: bindkey"),
     95
     96  OWLCMD_ARGS("unbindkey", owl_command_unbindkey, OWL_CTX_ANY,
     97              "removes a binding in a keymap",
     98              "bindkey <keymap> <keyseq>",
     99              "Removes a binding of a key sequence within a keymap.\n"
     100              "Use 'show keymaps' to see the existing keymaps.\n"
     101              "Ex.: unbindkey recv H"
     102              "SEE ALSO: bindkey"),
    94103
    95104  OWLCMD_ARGS("zwrite", owl_command_zwrite, OWL_CTX_INTERACTIVE,
     
    16721681  return NULL;
    16731682}
     1683
     1684
     1685char *owl_command_unbindkey(int argc, const char *const *argv)
     1686{
     1687  owl_keymap *km;
     1688  int ret;
     1689
     1690  if (argc < 3) {
     1691    owl_function_makemsg("Usage: bindkey <keymap> <binding>");
     1692    return NULL;
     1693  }
     1694  km = owl_keyhandler_get_keymap(owl_global_get_keyhandler(&g), argv[1]);
     1695  if (!km) {
     1696    owl_function_makemsg("No such keymap '%s'", argv[1]);
     1697    return NULL;
     1698  }
     1699  ret = owl_keymap_remove_binding(km, argv[2]);
     1700  if (ret == -1) {
     1701    owl_function_makemsg("Unable to unbind '%s' in keymap '%s'.",
     1702                         argv[2], argv[1]);
     1703    return NULL;
     1704  } else if (ret == -2) {
     1705    owl_function_makemsg("No such binding '%s' in keymap '%s'.",
     1706                         argv[2], argv[1]);
     1707  }
     1708  return NULL;
     1709}
     1710
    16741711
    16751712void owl_command_quit(void)
Note: See TracChangeset for help on using the changeset viewer.