-/* $OpenBSD: cmd-find.c,v 1.66 2018/06/26 13:21:28 nicm Exp $ */
+/* $OpenBSD: cmd-find.c,v 1.67 2018/08/02 11:44:07 nicm Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicholas.marriott@gmail.com>
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 *,
}
/* Log the result. */
-void
+static void
cmd_find_log_state(const char *prefix, struct cmd_find_state *fs)
{
if (fs->s != NULL)
-/* $OpenBSD: cmd-list-keys.c,v 1.44 2017/05/01 12:20:55 nicm Exp $ */
+/* $OpenBSD: cmd-list-keys.c,v 1.45 2018/08/02 11:44:07 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
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)
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)
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);
-/* $OpenBSD: cmd-send-keys.c,v 1.42 2017/06/28 11:36:39 nicm Exp $ */
+/* $OpenBSD: cmd-send-keys.c,v 1.43 2018/08/02 11:44:07 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
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"))
}
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);
-/* $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>
#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)
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)
{
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)
-/* $OpenBSD: mode-tree.c,v 1.23 2018/02/28 08:55:44 nicm Exp $ */
+/* $OpenBSD: mode-tree.c,v 1.24 2018/08/02 11:44:07 nicm Exp $ */
/*
* Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com>
}
}
-void
+static void
mode_tree_up(struct mode_tree_data *mtd, int wrap)
{
if (mtd->current == 0) {
-/* $OpenBSD: server-client.c,v 1.253 2018/07/17 18:02:40 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.254 2018/08/02 11:44:07 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
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 *);
}
/* Clear identify mode on client. */
-void
+static void
server_client_clear_identify(struct client *c, struct window_pane *wp)
{
if (~c->flags & CLIENT_IDENTIFY)
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;
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
-/* $OpenBSD: tmux.h,v 1.833 2018/08/02 11:18:34 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.834 2018/08/02 11:44:07 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
int cmd_find_valid_state(struct cmd_find_state *);
void cmd_find_copy_state(struct cmd_find_state *,
struct cmd_find_state *);
-void cmd_find_log_state(const char *, struct cmd_find_state *);
void cmd_find_from_session(struct cmd_find_state *,
struct session *, int);
void cmd_find_from_winlink(struct cmd_find_state *,
int client_main(struct event_base *, int, char **, int);
/* key-bindings.c */
-RB_PROTOTYPE(key_bindings, key_binding, entry, key_bindings_cmp);
-RB_PROTOTYPE(key_tables, key_table, entry, key_table_cmp);
-extern struct key_tables key_tables;
-int key_table_cmp(struct key_table *, struct key_table *);
-int key_bindings_cmp(struct key_binding *, struct key_binding *);
struct key_table *key_bindings_get_table(const char *, int);
+struct key_table *key_bindings_first_table(void);
+struct key_table *key_bindings_next_table(struct key_table *);
void key_bindings_unref_table(struct key_table *);
+struct key_binding *key_bindings_get(struct key_table *, key_code);
+struct key_binding *key_bindings_first(struct key_table *);
+struct key_binding *key_bindings_next(struct key_table *, struct key_binding *);
void key_bindings_add(const char *, key_code, int, struct cmd_list *);
void key_bindings_remove(const char *, key_code);
void key_bindings_remove_table(const char *);
/* server-client.c */
u_int server_client_how_many(void);
void server_client_set_identify(struct client *, u_int);
-void server_client_clear_identify(struct client *, struct window_pane *);
void server_client_set_key_table(struct client *, const char *);
const char *server_client_get_key_table(struct client *);
int server_client_check_nested(struct client *);
void mode_tree_set_current(struct mode_tree_data *, uint64_t);
void mode_tree_each_tagged(struct mode_tree_data *, mode_tree_each_cb,
struct client *, key_code, int);
-void mode_tree_up(struct mode_tree_data *, int);
void mode_tree_down(struct mode_tree_data *, int);
struct mode_tree_data *mode_tree_start(struct window_pane *, struct args *,
mode_tree_build_cb, mode_tree_draw_cb, mode_tree_search_cb,