diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2009-07-24 14:52:47 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2009-07-24 14:52:47 +0000 |
commit | 5a1a1066371328f9d53a9bc5e5c4c53acb26c2b2 (patch) | |
tree | b9b54a76352420ff03b31146ad0846e438332949 /key-bindings.c | |
parent | ce4eb6559e1aabb67e08a367a7c5e049e800c7ed (diff) |
Permit commands to be bound to key presses without the prefix key first. The
new -n flag to bind-key and unbind-key sets or removes these bindings, and
list-key shows them in []s.
Diffstat (limited to 'key-bindings.c')
-rw-r--r-- | key-bindings.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/key-bindings.c b/key-bindings.c index d37e23b3..186c1a9b 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -32,7 +32,18 @@ struct key_bindings dead_key_bindings; int key_bindings_cmp(struct key_binding *bd1, struct key_binding *bd2) { - return (bd1->key - bd2->key); + int key1, key2; + + key1 = bd1->key & ~KEYC_PREFIX; + key2 = bd2->key & ~KEYC_PREFIX; + if (key1 != key2) + return (key1 - key2); + + if (bd1->key & KEYC_PREFIX && !(bd2->key & KEYC_PREFIX)) + return (-1); + if (bd2->key & KEYC_PREFIX && !(bd1->key & KEYC_PREFIX)) + return (1); + return (0); } struct key_binding * @@ -170,7 +181,8 @@ key_bindings_init(void) cmd->entry->init(cmd, table[i].key); TAILQ_INSERT_HEAD(cmdlist, cmd, qentry); - key_bindings_add(table[i].key, table[i].can_repeat, cmdlist); + key_bindings_add( + table[i].key | KEYC_PREFIX, table[i].can_repeat, cmdlist); } } |