summaryrefslogtreecommitdiffstats
path: root/key-bindings.c
diff options
context:
space:
mode:
authornicm <nicm>2018-08-02 11:44:07 +0000
committernicm <nicm>2018-08-02 11:44:07 +0000
commit6048b0f48337b8d2359d9996a59665640278677c (patch)
tree1e6d7378f94d9d00bb721e5f1e81e957d548e949 /key-bindings.c
parentf12b8574155b12313afc63f7b6dd9baa261c9710 (diff)
Make key trees and some other bits static.
Diffstat (limited to 'key-bindings.c')
-rw-r--r--key-bindings.c51
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)