diff options
author | Thomas Adam <thomas@xteddy.org> | 2018-08-02 15:02:25 +0100 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2018-08-02 15:02:25 +0100 |
commit | eceaa9a49345d0ab1cdd2f0489acbbbf4838126a (patch) | |
tree | f60faaec2c6b99b7076ca8e86a1841ea93e18bde /key-bindings.c | |
parent | 2e19a5ecb96d5c4c9abd196b0a61ad88360530d0 (diff) | |
parent | fb1f0fee5af3da964ec359ae2b543353ce47f996 (diff) | |
download | rtmux-eceaa9a49345d0ab1cdd2f0489acbbbf4838126a.tar.gz rtmux-eceaa9a49345d0ab1cdd2f0489acbbbf4838126a.tar.bz2 rtmux-eceaa9a49345d0ab1cdd2f0489acbbbf4838126a.zip |
Merge branch 'obsd-master'
Diffstat (limited to 'key-bindings.c')
-rw-r--r-- | key-bindings.c | 51 |
1 files changed, 43 insertions, 8 deletions
diff --git a/key-bindings.c b/key-bindings.c index 83670d2d..41afd99c 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -24,17 +24,19 @@ #include "tmux.h" -RB_GENERATE(key_bindings, key_binding, entry, key_bindings_cmp); -RB_GENERATE(key_tables, key_table, entry, key_table_cmp); -struct key_tables key_tables = RB_INITIALIZER(&key_tables); - -int -key_table_cmp(struct key_table *e1, struct key_table *e2) +static int key_bindings_cmp(struct key_binding *, struct key_binding *); +RB_GENERATE_STATIC(key_bindings, key_binding, entry, key_bindings_cmp); +static int key_table_cmp(struct key_table *, struct key_table *); +RB_GENERATE_STATIC(key_tables, key_table, entry, key_table_cmp); +static struct key_tables key_tables = RB_INITIALIZER(&key_tables); + +static int +key_table_cmp(struct key_table *table1, struct key_table *table2) { - return (strcmp(e1->name, e2->name)); + return (strcmp(table1->name, table2->name)); } -int +static int key_bindings_cmp(struct key_binding *bd1, struct key_binding *bd2) { if (bd1->key < bd2->key) @@ -64,6 +66,18 @@ key_bindings_get_table(const char *name, int create) return (table); } +struct key_table * +key_bindings_first_table(void) +{ + return (RB_MIN(key_tables, &key_tables)); +} + +struct key_table * +key_bindings_next_table(struct key_table *table) +{ + return (RB_NEXT(key_tables, &key_tables, table)); +} + void key_bindings_unref_table(struct key_table *table) { @@ -83,6 +97,27 @@ key_bindings_unref_table(struct key_table *table) free(table); } +struct key_binding * +key_bindings_get(struct key_table *table, key_code key) +{ + struct key_binding bd; + + bd.key = key; + return (RB_FIND(key_bindings, &table->key_bindings, &bd)); +} + +struct key_binding * +key_bindings_first(struct key_table *table) +{ + return (RB_MIN(key_bindings, &table->key_bindings)); +} + +struct key_binding * +key_bindings_next(__unused struct key_table *table, struct key_binding *bd) +{ + return (RB_NEXT(key_bindings, &table->key_bindings, bd)); +} + void key_bindings_add(const char *name, key_code key, int repeat, struct cmd_list *cmdlist) |