version 1.28, 2011/07/03 18:18:15 |
version 1.29, 2012/01/21 11:12:13 |
|
|
|
|
#include "tmux.h" |
#include "tmux.h" |
|
|
SPLAY_GENERATE(key_bindings, key_binding, entry, key_bindings_cmp); |
RB_GENERATE(key_bindings, key_binding, entry, key_bindings_cmp); |
|
|
struct key_bindings key_bindings; |
struct key_bindings key_bindings; |
struct key_bindings dead_key_bindings; |
struct key_bindings dead_key_bindings; |
|
|
struct key_binding bd; |
struct key_binding bd; |
|
|
bd.key = key; |
bd.key = key; |
return (SPLAY_FIND(key_bindings, &key_bindings, &bd)); |
return (RB_FIND(key_bindings, &key_bindings, &bd)); |
} |
} |
|
|
void |
void |
|
|
|
|
bd = xmalloc(sizeof *bd); |
bd = xmalloc(sizeof *bd); |
bd->key = key; |
bd->key = key; |
SPLAY_INSERT(key_bindings, &key_bindings, bd); |
RB_INSERT(key_bindings, &key_bindings, bd); |
|
|
bd->can_repeat = can_repeat; |
bd->can_repeat = can_repeat; |
bd->cmdlist = cmdlist; |
bd->cmdlist = cmdlist; |
|
|
|
|
if ((bd = key_bindings_lookup(key)) == NULL) |
if ((bd = key_bindings_lookup(key)) == NULL) |
return; |
return; |
SPLAY_REMOVE(key_bindings, &key_bindings, bd); |
RB_REMOVE(key_bindings, &key_bindings, bd); |
SPLAY_INSERT(key_bindings, &dead_key_bindings, bd); |
RB_INSERT(key_bindings, &dead_key_bindings, bd); |
} |
} |
|
|
void |
void |
|
|
{ |
{ |
struct key_binding *bd; |
struct key_binding *bd; |
|
|
while (!SPLAY_EMPTY(&dead_key_bindings)) { |
while (!RB_EMPTY(&dead_key_bindings)) { |
bd = SPLAY_ROOT(&dead_key_bindings); |
bd = RB_ROOT(&dead_key_bindings); |
SPLAY_REMOVE(key_bindings, &dead_key_bindings, bd); |
RB_REMOVE(key_bindings, &dead_key_bindings, bd); |
cmd_list_free(bd->cmdlist); |
cmd_list_free(bd->cmdlist); |
xfree(bd); |
xfree(bd); |
} |
} |
|
|
struct cmd *cmd; |
struct cmd *cmd; |
struct cmd_list *cmdlist; |
struct cmd_list *cmdlist; |
|
|
SPLAY_INIT(&key_bindings); |
RB_INIT(&key_bindings); |
|
|
for (i = 0; i < nitems(table); i++) { |
for (i = 0; i < nitems(table); i++) { |
cmdlist = xmalloc(sizeof *cmdlist); |
cmdlist = xmalloc(sizeof *cmdlist); |