diff options
author | 2018-08-02 11:44:07 +0000 | |
---|---|---|
committer | 2018-08-02 11:44:07 +0000 | |
commit | 4e325abea1cd580023726f7dca1e9cecf16ec07c (patch) | |
tree | 7ced543bd0cfa504300603cbcf941674106a6351 /usr.bin/tmux/key-bindings.c | |
parent | Minor tidying. (diff) | |
download | wireguard-openbsd-4e325abea1cd580023726f7dca1e9cecf16ec07c.tar.xz wireguard-openbsd-4e325abea1cd580023726f7dca1e9cecf16ec07c.zip |
Make key trees and some other bits static.
Diffstat (limited to 'usr.bin/tmux/key-bindings.c')
-rw-r--r-- | usr.bin/tmux/key-bindings.c | 51 |
1 files changed, 43 insertions, 8 deletions
diff --git a/usr.bin/tmux/key-bindings.c b/usr.bin/tmux/key-bindings.c index b41fa391326..67c4e6b01f7 100644 --- a/usr.bin/tmux/key-bindings.c +++ b/usr.bin/tmux/key-bindings.c @@ -1,4 +1,4 @@ -/* $OpenBSD: key-bindings.c,v 1.85 2018/02/28 08:55:44 nicm Exp $ */ +/* $OpenBSD: key-bindings.c,v 1.86 2018/08/02 11:44:07 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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); +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); -int -key_table_cmp(struct key_table *e1, struct key_table *e2) +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) |