aboutsummaryrefslogtreecommitdiff
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
parentf12b8574155b12313afc63f7b6dd9baa261c9710 (diff)
downloadrtmux-6048b0f48337b8d2359d9996a59665640278677c.tar.gz
rtmux-6048b0f48337b8d2359d9996a59665640278677c.tar.bz2
rtmux-6048b0f48337b8d2359d9996a59665640278677c.zip
Make key trees and some other bits static.
-rw-r--r--cmd-find.c3
-rw-r--r--cmd-list-keys.c25
-rw-r--r--cmd-send-keys.c5
-rw-r--r--key-bindings.c51
-rw-r--r--mode-tree.c2
-rw-r--r--server-client.c9
6 files changed, 72 insertions, 23 deletions
diff --git a/cmd-find.c b/cmd-find.c
index cb0c411b..ff95ae1f 100644
--- a/cmd-find.c
+++ b/cmd-find.c
@@ -35,6 +35,7 @@ static int cmd_find_best_winlink_with_window(struct cmd_find_state *);
static const char *cmd_find_map_table(const char *[][2], const char *);
+static void cmd_find_log_state(const char *, struct cmd_find_state *);
static int cmd_find_get_session(struct cmd_find_state *, const char *);
static int cmd_find_get_window(struct cmd_find_state *, const char *, int);
static int cmd_find_get_window_with_session(struct cmd_find_state *,
@@ -716,7 +717,7 @@ cmd_find_copy_state(struct cmd_find_state *dst, struct cmd_find_state *src)
}
/* Log the result. */
-void
+static void
cmd_find_log_state(const char *prefix, struct cmd_find_state *fs)
{
if (fs->s != NULL)
diff --git a/cmd-list-keys.c b/cmd-list-keys.c
index 9e0cac62..5efb0cd2 100644
--- a/cmd-list-keys.c
+++ b/cmd-list-keys.c
@@ -75,10 +75,14 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
repeat = 0;
tablewidth = keywidth = 0;
- RB_FOREACH(table, key_tables, &key_tables) {
- if (tablename != NULL && strcmp(table->name, tablename) != 0)
+ table = key_bindings_first_table ();
+ while (table != NULL) {
+ if (tablename != NULL && strcmp(table->name, tablename) != 0) {
+ table = key_bindings_next_table(table);
continue;
- RB_FOREACH(bd, key_bindings, &table->key_bindings) {
+ }
+ bd = key_bindings_first(table);
+ while (bd != NULL) {
key = key_string_lookup_key(bd->key);
if (bd->flags & KEY_BINDING_REPEAT)
@@ -90,13 +94,20 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
width = utf8_cstrwidth(key);
if (width > keywidth)
keywidth = width;
+
+ bd = key_bindings_next(table, bd);
}
+ table = key_bindings_next_table(table);
}
- RB_FOREACH(table, key_tables, &key_tables) {
- if (tablename != NULL && strcmp(table->name, tablename) != 0)
+ table = key_bindings_first_table ();
+ while (table != NULL) {
+ if (tablename != NULL && strcmp(table->name, tablename) != 0) {
+ table = key_bindings_next_table(table);
continue;
- RB_FOREACH(bd, key_bindings, &table->key_bindings) {
+ }
+ bd = key_bindings_first(table);
+ while (bd != NULL) {
key = key_string_lookup_key(bd->key);
if (!repeat)
@@ -122,7 +133,9 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
free(cp);
cmdq_print(item, "bind-key %s", tmp);
+ bd = key_bindings_next(table, bd);
}
+ table = key_bindings_next_table(table);
}
return (CMD_RETURN_NORMAL);
diff --git a/cmd-send-keys.c b/cmd-send-keys.c
index 8d2c2608..6230ecf7 100644
--- a/cmd-send-keys.c
+++ b/cmd-send-keys.c
@@ -61,7 +61,7 @@ cmd_send_keys_inject(struct client *c, struct cmdq_item *item, key_code key)
struct window_pane *wp = item->target.wp;
struct session *s = item->target.s;
struct key_table *table;
- struct key_binding *bd, bd_find;
+ struct key_binding *bd;
if (wp->mode == NULL || wp->mode->key_table == NULL) {
if (options_get_number(wp->window->options, "xterm-keys"))
@@ -71,8 +71,7 @@ cmd_send_keys_inject(struct client *c, struct cmdq_item *item, key_code key)
}
table = key_bindings_get_table(wp->mode->key_table(wp), 1);
- bd_find.key = (key & ~KEYC_XTERM);
- bd = RB_FIND(key_bindings, &table->key_bindings, &bd_find);
+ bd = key_bindings_get(table, key & ~KEYC_XTERM);
if (bd != NULL) {
table->references++;
key_bindings_dispatch(bd, item, c, NULL, &item->target);
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)
diff --git a/mode-tree.c b/mode-tree.c
index 05ec492d..2e4b9072 100644
--- a/mode-tree.c
+++ b/mode-tree.c
@@ -192,7 +192,7 @@ mode_tree_clear_tagged(struct mode_tree_list *mtl)
}
}
-void
+static void
mode_tree_up(struct mode_tree_data *mtd, int wrap)
{
if (mtd->current == 0) {
diff --git a/server-client.c b/server-client.c
index 46b90ccb..38226758 100644
--- a/server-client.c
+++ b/server-client.c
@@ -43,6 +43,8 @@ static void server_client_check_redraw(struct client *);
static void server_client_set_title(struct client *);
static void server_client_reset_state(struct client *);
static int server_client_assume_paste(struct session *);
+static void server_client_clear_identify(struct client *,
+ struct window_pane *);
static void server_client_dispatch(struct imsg *, void *);
static void server_client_dispatch_command(struct client *, struct imsg *);
@@ -93,7 +95,7 @@ server_client_set_identify(struct client *c, u_int delay)
}
/* Clear identify mode on client. */
-void
+static void
server_client_clear_identify(struct client *c, struct window_pane *wp)
{
if (~c->flags & CLIENT_IDENTIFY)
@@ -815,7 +817,7 @@ server_client_handle_key(struct client *c, key_code key)
struct window_pane *wp;
struct timeval tv;
struct key_table *table, *first;
- struct key_binding bd_find, *bd;
+ struct key_binding *bd;
int xtimeout, flags;
struct cmd_find_state fs;
key_code key0;
@@ -928,8 +930,7 @@ table_changed:
try_again:
/* Try to see if there is a key binding in the current table. */
- bd_find.key = key0;
- bd = RB_FIND(key_bindings, &table->key_bindings, &bd_find);
+ bd = key_bindings_get(table, key0);
if (bd != NULL) {
/*
* Key was matched in this table. If currently repeating but a