summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--alerts.c24
-rw-r--r--client.c6
-rw-r--r--cmd-attach-session.c4
-rw-r--r--cmd-break-pane.c2
-rw-r--r--cmd-choose-buffer.c2
-rw-r--r--cmd-move-window.c2
-rw-r--r--cmd-new-session.c10
-rw-r--r--cmd-new-window.c4
-rw-r--r--cmd-rename-window.c2
-rw-r--r--cmd-send-keys.c4
-rw-r--r--cmd-set-option.c24
-rw-r--r--cmd-show-options.c14
-rw-r--r--cmd-split-window.c6
-rw-r--r--cmd-switch-client.c2
-rw-r--r--format.c12
-rw-r--r--input-keys.c2
-rw-r--r--input.c6
-rw-r--r--layout-set.c8
-rw-r--r--names.c4
-rw-r--r--options.c28
-rw-r--r--paste.c2
-rw-r--r--resize.c8
-rw-r--r--screen-redraw.c6
-rw-r--r--server-client.c20
-rw-r--r--server-fn.c16
-rw-r--r--server.c2
-rw-r--r--session.c19
-rw-r--r--status.c56
-rw-r--r--tmux.c31
-rw-r--r--tmux.h22
-rw-r--r--tty-keys.c2
-rw-r--r--tty-term.c2
-rw-r--r--tty.c8
-rw-r--r--window-choose.c6
-rw-r--r--window-clock.c4
-rw-r--r--window-copy.c34
-rw-r--r--window.c20
37 files changed, 223 insertions, 201 deletions
diff --git a/alerts.c b/alerts.c
index 806e565b..f1477030 100644
--- a/alerts.c
+++ b/alerts.c
@@ -80,11 +80,11 @@ alerts_enabled(struct window *w, int flags)
struct session *s;
if (flags & WINDOW_ACTIVITY) {
- if (options_get_number(&w->options, "monitor-activity"))
+ if (options_get_number(w->options, "monitor-activity"))
return (1);
}
if (flags & WINDOW_SILENCE) {
- if (options_get_number(&w->options, "monitor-silence") != 0)
+ if (options_get_number(w->options, "monitor-silence") != 0)
return (1);
}
if (~flags & WINDOW_BELL)
@@ -92,7 +92,7 @@ alerts_enabled(struct window *w, int flags)
RB_FOREACH(s, sessions, &sessions) {
if (!session_has(s, w))
continue;
- if (options_get_number(&s->options, "bell-action") != BELL_NONE)
+ if (options_get_number(s->options, "bell-action") != BELL_NONE)
return (1);
}
return (0);
@@ -116,7 +116,7 @@ alerts_reset(struct window *w)
event_del(&w->alerts_timer);
timerclear(&tv);
- tv.tv_sec = options_get_number(&w->options, "monitor-silence");
+ tv.tv_sec = options_get_number(w->options, "monitor-silence");
log_debug("@%u alerts timer reset %u", w->id, (u_int)tv.tv_sec);
if (tv.tv_sec != 0)
@@ -160,11 +160,11 @@ alerts_check_bell(struct session *s, struct winlink *wl)
if (s->curw->window == w)
w->flags &= ~WINDOW_BELL;
- action = options_get_number(&s->options, "bell-action");
+ action = options_get_number(s->options, "bell-action");
if (action == BELL_NONE)
return (0);
- visual = options_get_number(&s->options, "visual-bell");
+ visual = options_get_number(s->options, "visual-bell");
TAILQ_FOREACH(c, &clients, entry) {
if (c->session != s || c->flags & CLIENT_CONTROL)
continue;
@@ -201,14 +201,14 @@ alerts_check_activity(struct session *s, struct winlink *wl)
if (s->curw == wl && !(s->flags & SESSION_UNATTACHED))
return (0);
- if (!options_get_number(&w->options, "monitor-activity"))
+ if (!options_get_number(w->options, "monitor-activity"))
return (0);
- if (options_get_number(&s->options, "bell-on-alert"))
+ if (options_get_number(s->options, "bell-on-alert"))
alerts_ring_bell(s);
wl->flags |= WINLINK_ACTIVITY;
- if (options_get_number(&s->options, "visual-activity")) {
+ if (options_get_number(s->options, "visual-activity")) {
TAILQ_FOREACH(c, &clients, entry) {
if (c->session != s)
continue;
@@ -233,14 +233,14 @@ alerts_check_silence(struct session *s, struct winlink *wl)
if (s->curw == wl && !(s->flags & SESSION_UNATTACHED))
return (0);
- if (options_get_number(&w->options, "monitor-silence") == 0)
+ if (options_get_number(w->options, "monitor-silence") == 0)
return (0);
- if (options_get_number(&s->options, "bell-on-alert"))
+ if (options_get_number(s->options, "bell-on-alert"))
alerts_ring_bell(s);
wl->flags |= WINLINK_SILENCE;
- if (options_get_number(&s->options, "visual-silence")) {
+ if (options_get_number(s->options, "visual-silence")) {
TAILQ_FOREACH(c, &clients, entry) {
if (c->session != s)
continue;
diff --git a/client.c b/client.c
index 606feefe..aa453538 100644
--- a/client.c
+++ b/client.c
@@ -291,9 +291,9 @@ client_main(struct event_base *base, int argc, char **argv, int flags)
fatal("pledge failed");
/* Free stuff that is not used in the client. */
- options_free(&global_options);
- options_free(&global_s_options);
- options_free(&global_w_options);
+ options_free(global_options);
+ options_free(global_s_options);
+ options_free(global_w_options);
environ_free(&global_environ);
/* Create stdin handler. */
diff --git a/cmd-attach-session.c b/cmd-attach-session.c
index 4e390323..a3623ec4 100644
--- a/cmd-attach-session.c
+++ b/cmd-attach-session.c
@@ -121,7 +121,7 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
}
if (!Eflag) {
- update = options_get_string(&s->options,
+ update = options_get_string(s->options,
"update-environment");
environ_update(update, &c->environ, &s->environ);
}
@@ -152,7 +152,7 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
}
if (!Eflag) {
- update = options_get_string(&s->options,
+ update = options_get_string(s->options,
"update-environment");
environ_update(update, &c->environ, &s->environ);
}
diff --git a/cmd-break-pane.c b/cmd-break-pane.c
index 2aa5c5b7..39179cc7 100644
--- a/cmd-break-pane.c
+++ b/cmd-break-pane.c
@@ -84,7 +84,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_q *cmdq)
layout_init(w, wp);
if (idx == -1)
- idx = -1 - options_get_number(&dst_s->options, "base-index");
+ idx = -1 - options_get_number(dst_s->options, "base-index");
wl = session_attach(dst_s, w, idx, &cause); /* can't fail */
if (!args_has(self->args, 'd'))
session_select(dst_s, wl->idx);
diff --git a/cmd-choose-buffer.c b/cmd-choose-buffer.c
index b4590306..e790de6b 100644
--- a/cmd-choose-buffer.c
+++ b/cmd-choose-buffer.c
@@ -63,7 +63,7 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
return (CMD_RETURN_ERROR);
- utf8flag = options_get_number(&wl->window->options, "utf8");
+ utf8flag = options_get_number(wl->window->options, "utf8");
if (paste_get_top(NULL) == NULL)
return (CMD_RETURN_NORMAL);
diff --git a/cmd-move-window.c b/cmd-move-window.c
index b15df4f6..1bd46ab2 100644
--- a/cmd-move-window.c
+++ b/cmd-move-window.c
@@ -95,7 +95,7 @@ cmd_move_window_exec(struct cmd *self, struct cmd_q *cmdq)
* session already has the correct winlink id to us, either
* automatically or specified by -s.
*/
- if (!sflag && options_get_number(&src->options, "renumber-windows"))
+ if (!sflag && options_get_number(src->options, "renumber-windows"))
session_renumber_windows(src);
recalculate_sizes();
diff --git a/cmd-new-session.c b/cmd-new-session.c
index f1a6167a..48828e54 100644
--- a/cmd-new-session.c
+++ b/cmd-new-session.c
@@ -197,7 +197,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
goto error;
}
}
- if (sy > 0 && options_get_number(&global_s_options, "status"))
+ if (sy > 0 && options_get_number(global_s_options, "status"))
sy--;
if (sx == 0)
sx = 1;
@@ -211,7 +211,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
argc = args->argc;
argv = args->argv;
} else if (target == NULL) {
- cmd = options_get_string(&global_s_options, "default-command");
+ cmd = options_get_string(global_s_options, "default-command");
if (cmd != NULL && *cmd != '\0') {
argc = 1;
argv = &cmd;
@@ -232,13 +232,13 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
/* Construct the environment. */
environ_init(&env);
if (c != NULL && !args_has(args, 'E')) {
- update = options_get_string(&global_s_options,
+ update = options_get_string(global_s_options,
"update-environment");
environ_update(update, &c->environ, &env);
}
/* Create the new session. */
- idx = -1 - options_get_number(&global_s_options, "base-index");
+ idx = -1 - options_get_number(global_s_options, "base-index");
s = session_create(newname, argc, argv, path, cwd, &env, tiop, idx, sx,
sy, &cause);
if (s == NULL) {
@@ -252,7 +252,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
if (argc >= 0 && args_has(args, 'n')) {
w = s->curw->window;
window_set_name(w, args_get(args, 'n'));
- options_set_number(&w->options, "automatic-rename", 0);
+ options_set_number(w->options, "automatic-rename", 0);
}
/*
diff --git a/cmd-new-window.c b/cmd-new-window.c
index 893fe6e2..a3712d76 100644
--- a/cmd-new-window.c
+++ b/cmd-new-window.c
@@ -71,7 +71,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
detached = args_has(args, 'd');
if (args->argc == 0) {
- cmd = options_get_string(&s->options, "default-command");
+ cmd = options_get_string(s->options, "default-command");
if (cmd != NULL && *cmd != '\0') {
argc = 1;
argv = (char **)&cmd;
@@ -136,7 +136,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
}
if (idx == -1)
- idx = -1 - options_get_number(&s->options, "base-index");
+ idx = -1 - options_get_number(s->options, "base-index");
wl = session_new(s, args_get(args, 'n'), argc, argv, path, cwd, idx,
&cause);
if (wl == NULL) {
diff --git a/cmd-rename-window.c b/cmd-rename-window.c
index 2f677a48..bc85d96b 100644
--- a/cmd-rename-window.c
+++ b/cmd-rename-window.c
@@ -47,7 +47,7 @@ cmd_rename_window_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_ERROR);
window_set_name(wl->window, args->argv[0]);
- options_set_number(&wl->window->options, "automatic-rename", 0);
+ options_set_number(wl->window->options, "automatic-rename", 0);
server_status_window(wl->window);
diff --git a/cmd-send-keys.c b/cmd-send-keys.c
index b1f8d672..dd796d60 100644
--- a/cmd-send-keys.c
+++ b/cmd-send-keys.c
@@ -70,9 +70,9 @@ cmd_send_keys_exec(struct cmd *self, struct cmd_q *cmdq)
if (self->entry == &cmd_send_prefix_entry) {
if (args_has(args, '2'))
- key = options_get_number(&s->options, "prefix2");
+ key = options_get_number(s->options, "prefix2");
else
- key = options_get_number(&s->options, "prefix");
+ key = options_get_number(s->options, "prefix");
window_pane_key(wp, NULL, s, key, NULL);
return (CMD_RETURN_NORMAL);
}
diff --git a/cmd-set-option.c b/cmd-set-option.c
index e0b07edb..6762e6ad 100644
--- a/cmd-set-option.c
+++ b/cmd-set-option.c
@@ -126,10 +126,10 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
/* Work out the tree from the table. */
if (table == server_options_table)
- oo = &global_options;
+ oo = global_options;
else if (table == window_options_table) {
if (args_has(self->args, 'g'))
- oo = &global_w_options;
+ oo = global_w_options;
else {
wl = cmd_find_window(cmdq, args_get(args, 't'), NULL);
if (wl == NULL) {
@@ -139,11 +139,11 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
'g')) ? " need target window or -g" : "");
return (CMD_RETURN_ERROR);
}
- oo = &wl->window->options;
+ oo = wl->window->options;
}
} else if (table == session_options_table) {
if (args_has(self->args, 'g'))
- oo = &global_s_options;
+ oo = global_s_options;
else {
s = cmd_find_session(cmdq, args_get(args, 't'), 0);
if (s == NULL) {
@@ -153,7 +153,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
'g')) ? " need target session or -g" : "");
return (CMD_RETURN_ERROR);
}
- oo = &s->options;
+ oo = s->options;
}
} else {
cmdq_error(cmdq, "unknown table");
@@ -179,7 +179,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
/* Start or stop timers if necessary. */
if (strcmp(oe->name, "automatic-rename") == 0) {
RB_FOREACH(w, windows, &windows) {
- if (options_get_number(&w->options, "automatic-rename"))
+ if (options_get_number(w->options, "automatic-rename"))
w->active->flags |= PANE_CHANGED;
}
}
@@ -210,25 +210,25 @@ cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, const char *optstr,
struct options *oo;
if (args_has(args, 's'))
- oo = &global_options;
+ oo = global_options;
else if (args_has(self->args, 'w') ||
self->entry == &cmd_set_window_option_entry) {
if (args_has(self->args, 'g'))
- oo = &global_w_options;
+ oo = global_w_options;
else {
wl = cmd_find_window(cmdq, args_get(args, 't'), NULL);
if (wl == NULL)
return (CMD_RETURN_ERROR);
- oo = &wl->window->options;
+ oo = wl->window->options;
}
} else {
if (args_has(self->args, 'g'))
- oo = &global_s_options;
+ oo = global_s_options;
else {
s = cmd_find_session(cmdq, args_get(args, 't'), 0);
if (s == NULL)
return (CMD_RETURN_ERROR);
- oo = &s->options;
+ oo = s->options;
}
}
@@ -276,7 +276,7 @@ cmd_set_option_unset(struct cmd *self, struct cmd_q *cmdq,
return (-1);
}
- if (args_has(args, 'g') || oo == &global_options) {
+ if (args_has(args, 'g') || oo == global_options) {
switch (oe->type) {
case OPTIONS_TABLE_STRING:
options_set_string(oo, oe->name, "%s", oe->default_str);
diff --git a/cmd-show-options.c b/cmd-show-options.c
index a5011e72..e99d665f 100644
--- a/cmd-show-options.c
+++ b/cmd-show-options.c
@@ -61,28 +61,28 @@ cmd_show_options_exec(struct cmd *self, struct cmd_q *cmdq)
int quiet;
if (args_has(self->args, 's')) {
- oo = &global_options;
+ oo = global_options;
table = server_options_table;
} else if (args_has(self->args, 'w') ||
self->entry == &cmd_show_window_options_entry) {
table = window_options_table;
if (args_has(self->args, 'g'))
- oo = &global_w_options;
+ oo = global_w_options;
else {
wl = cmd_find_window(cmdq, args_get(args, 't'), NULL);
if (wl == NULL)
return (CMD_RETURN_ERROR);
- oo = &wl->window->options;
+ oo = wl->window->options;
}
} else {
table = session_options_table;
if (args_has(self->args, 'g'))
- oo = &global_s_options;
+ oo = global_s_options;
else {
s = cmd_find_session(cmdq, args_get(args, 't'), 0);
if (s == NULL)
return (CMD_RETURN_ERROR);
- oo = &s->options;
+ oo = s->options;
}
}
@@ -151,13 +151,15 @@ cmd_show_options_all(struct cmd *self, struct cmd_q *cmdq,
struct options_entry *o;
const char *optval;
- RB_FOREACH(o, options_tree, &oo->tree) {
+ o = options_first(oo);
+ while (o != NULL) {
if (*o->name == '@') {
if (args_has(self->args, 'v'))
cmdq_print(cmdq, "%s", o->str);
else
cmdq_print(cmdq, "%s \"%s\"", o->name, o->str);
}
+ o = options_next(o);
}
for (oe = table; oe->name != NULL; oe++) {
diff --git a/cmd-split-window.c b/cmd-split-window.c
index f397113f..60b04d77 100644
--- a/cmd-split-window.c
+++ b/cmd-split-window.c
@@ -73,7 +73,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
server_fill_environ(s, &env);
if (args->argc == 0) {
- cmd = options_get_string(&s->options, "default-command");
+ cmd = options_get_string(s->options, "default-command");
if (cmd != NULL && *cmd != '\0') {
argc = 1;
argv = (char **)&cmd;
@@ -135,9 +135,9 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
else
size = (wp->sx * percentage) / 100;
}
- hlimit = options_get_number(&s->options, "history-limit");
+ hlimit = options_get_number(s->options, "history-limit");
- shell = options_get_string(&s->options, "default-shell");
+ shell = options_get_string(s->options, "default-shell");
if (*shell == '\0' || areshell(shell))
shell = _PATH_BSHELL;
diff --git a/cmd-switch-client.c b/cmd-switch-client.c
index 3a72886a..5a8c8b08 100644
--- a/cmd-switch-client.c
+++ b/cmd-switch-client.c
@@ -120,7 +120,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq)
}
if (c != NULL && !args_has(args, 'E')) {
- update = options_get_string(&s->options, "update-environment");
+ update = options_get_string(s->options, "update-environment");
environ_update(update, &c->environ, &s->environ);
}
diff --git a/format.c b/format.c
index 285bfadb..0add71e5 100644
--- a/format.c
+++ b/format.c
@@ -581,15 +581,15 @@ format_find(struct format_tree *ft, const char *key, int modifiers)
found = NULL;
if (~modifiers & FORMAT_TIMESTRING) {
- o = options_find(&global_options, key);
+ o = options_find(global_options, key);
if (o == NULL && ft->w != NULL)
- o = options_find(&ft->w->options, key);
+ o = options_find(ft->w->options, key);
if (o == NULL)
- o = options_find(&global_w_options, key);
+ o = options_find(global_w_options, key);
if (o == NULL && ft->s != NULL)
- o = options_find(&ft->s->options, key);
+ o = options_find(ft->s->options, key);
if (o == NULL)
- o = options_find(&global_s_options, key);
+ o = options_find(global_s_options, key);
if (o != NULL) {
switch (o->type) {
case OPTIONS_STRING:
@@ -1101,7 +1101,7 @@ format_defaults_pane(struct format_tree *ft, struct window_pane *wp)
format_add(ft, "pane_in_mode", "%d", wp->screen != &wp->base);
format_add(ft, "pane_synchronized", "%d",
- !!options_get_number(&wp->window->options, "synchronize-panes"));
+ !!options_get_number(wp->window->options, "synchronize-panes"));
format_add(ft, "pane_tty", "%s", wp->tty);
format_add(ft, "pane_pid", "%ld", (long) wp->pid);
diff --git a/input-keys.c b/input-keys.c
index 6e49dd3b..579c0f39 100644
--- a/input-keys.c
+++ b/input-keys.c
@@ -171,7 +171,7 @@ input_key(struct window_pane *wp, int key, struct mouse_event *m)
* Then try to look this up as an xterm key, if the flag to output them
* is set.
*/
- if (options_get_number(&wp->window->options, "xterm-keys")) {
+ if (options_get_number(wp->window->options, "xterm-keys")) {
if ((out = xterm_keys_lookup(key)) != NULL) {
bufferevent_write(wp->event, out, strlen(out));
free(out);
diff --git a/input.c b/input.c
index ab56fc38..3a02b0ce 100644
--- a/input.c
+++ b/input.c
@@ -1907,12 +1907,12 @@ input_exit_rename(struct input_ctx *ictx)
{
if (ictx->flags & INPUT_DISCARD)
return;
- if (!options_get_number(&ictx->wp->window->options, "allow-rename"))
+ if (!options_get_number(ictx->wp->window->options, "allow-rename"))
return;
log_debug("%s: \"%s\"", __func__, ictx->input_buf);
window_set_name(ictx->wp->window, ictx->input_buf);
- options_set_number(&ictx->wp->window->options, "automatic-rename", 0);
+ options_set_number(ictx->wp->window->options, "automatic-rename", 0);
server_status_window(ictx->wp->window);
}
@@ -1921,7 +1921,7 @@ input_exit_rename(struct input_ctx *ictx)
int
input_utf8_open(struct input_ctx *ictx)
{
- if (!options_get_number(&ictx->wp->window->options, "utf8")) {
+ if (!options_get_number(ictx->wp->window->options, "utf8")) {
/* Print, and do not switch state. */
input_print(ictx);
return (-1);
diff --git a/layout-set.c b/layout-set.c
index da94cff2..852ec0f6 100644
--- a/layout-set.c
+++ b/layout-set.c
@@ -245,10 +245,10 @@ layout_set_main_h(struct window *w)
width = (w->sx - (n - 1)) / columns;
/* Get the main pane height and add one for separator line. */
- mainheight = options_get_number(&w->options, "main-pane-height") + 1;
+ mainheight = options_get_number(w->options, "main-pane-height") + 1;
/* Get the optional other pane height and add one for separator line. */
- otherheight = options_get_number(&w->options, "other-pane-height") + 1;
+ otherheight = options_get_number(w->options, "other-pane-height") + 1;
/*
* If an other pane height was specified, honour it so long as it
@@ -366,10 +366,10 @@ layout_set_main_v(struct window *w)
height = (w->sy - (n - 1)) / rows;
/* Get the main pane width and add one for separator line. */
- mainwidth = options_get_number(&w->options, "main-pane-width") + 1;
+ mainwidth = options_get_number(w->options, "main-pane-width") + 1;
/* Get the optional other pane width and add one for separator line. */
- otherwidth = options_get_number(&w->options, "other-pane-width") + 1;
+ otherwidth = options_get_number(w->options, "other-pane-width") + 1;
/*
* If an other pane width was specified, honour it so long as it
diff --git a/names.c b/names.c
index e880c577..0e806ca0 100644
--- a/names.c
+++ b/names.c
@@ -58,7 +58,7 @@ check_window_name(struct window *w)
if (w->active == NULL)
return;
- if (!options_get_number(&w->options, "automatic-rename"))
+ if (!options_get_number(w->options, "automatic-rename"))
return;
if (~w->active->flags & PANE_CHANGED) {
@@ -122,7 +122,7 @@ format_window_name(struct window *w)
format_defaults_window(ft, w);
format_defaults_pane(ft, w->active);
- fmt = options_get_string(&w->options, "automatic-rename-format");
+ fmt = options_get_string(w->options, "automatic-rename-format");
name = format_expand(ft, fmt);
format_free(ft);
diff --git a/options.c b/options.c
index 030cfd51..487918fd 100644
--- a/options.c
+++ b/options.c
@@ -29,6 +29,13 @@
* a red-black tree.
*/
+struct options {
+ RB_HEAD(options_tree, options_entry) tree;
+ struct options *parent;
+};
+
+int options_cmp(struct options_entry *, struct options_entry *);
+RB_PROTOTYPE(options_tree, options_entry, entry, options_cmp);
RB_GENERATE(options_tree, options_entry, entry, options_cmp);
int
@@ -37,11 +44,15 @@ options_cmp(struct options_entry *o1, struct options_entry *o2)
return (strcmp(o1->name, o2->name));
}
-void
-options_init(struct options *oo, struct options *parent)
+struct options *
+options_create(struct options *parent)
{
+ struct options *oo;
+
+ oo = xcalloc(1, sizeof *oo);
RB_INIT(&oo->tree);
oo->parent = parent;
+ return (oo);
}
void
@@ -57,6 +68,19 @@ options_free(struct options *oo)
free(o->str);
free(o);
}
+ free(oo);
+}
+
+struct options_entry *
+options_first(struct options *oo)
+{
+ return (RB_MIN(options_tree, &oo->tree));
+}
+
+struct options_entry *
+options_next(struct options_entry *o)
+{
+ return (RB_NEXT(options_tree, &oo->tree, o));
}
struct options_entry *
diff --git a/paste.c b/paste.c
index 44f88d0b..ad3b56b5 100644
--- a/paste.c
+++ b/paste.c
@@ -151,7 +151,7 @@ paste_add(char *data, size_t size)
if (size == 0)
return;
- limit = options_get_number(&global_options, "buffer-limit");
+ limit = options_get_number(global_options, "buffer-limit");
RB_FOREACH_REVERSE_SAFE(pb, paste_time_tree, &paste_by_time, pb1) {
if (paste_num_automatic < limit)
break;
diff --git a/resize.c b/resize.c
index 3606bfeb..c7805e05 100644
--- a/resize.c
+++ b/resize.c
@@ -53,7 +53,7 @@ recalculate_sizes(void)
int flag, has_status, is_zoomed, forced;
RB_FOREACH(s, sessions, &sessions) {
- has_status = options_get_number(&s->options, "status");
+ has_status = options_get_number(s->options, "status");
s->attached = 0;
ssx = ssy = UINT_MAX;
@@ -94,7 +94,7 @@ recalculate_sizes(void)
RB_FOREACH(w, windows, &windows) {
if (w->active == NULL)
continue;
- flag = options_get_number(&w->options, "aggressive-resize");
+ flag = options_get_number(w->options, "aggressive-resize");
ssx = ssy = UINT_MAX;
RB_FOREACH(s, sessions, &sessions) {
@@ -115,12 +115,12 @@ recalculate_sizes(void)
continue;
forced = 0;
- limit = options_get_number(&w->options, "force-width");
+ limit = options_get_number(w->options, "force-width");
if (limit >= PANE_MINIMUM && ssx > limit) {
ssx = limit;
forced |= WINDOW_FORCEWIDTH;
}
- limit = options_get_number(&w->options, "force-height");
+ limit = options_get_number(w->options, "force-height");
if (limit >= PANE_MINIMUM && ssy > limit) {
ssy = limit;
forced |= WINDOW_FORCEHEIGHT;
diff --git a/screen-redraw.c b/screen-redraw.c
index 799f5c55..fd4536d0 100644
--- a/screen-redraw.c
+++ b/screen-redraw.c
@@ -222,7 +222,7 @@ void
screen_redraw_screen(struct client *c, int draw_panes, int draw_status,
int draw_borders)
{
- struct options *oo = &c->session->options;
+ struct options *oo = c->session->options;
struct tty *tty = &c->tty;
u_int top;
int status, spos;
@@ -276,7 +276,7 @@ screen_redraw_draw_borders(struct client *c, int status, u_int top)
{
struct session *s = c->session;
struct window *w = s->curw->window;
- struct options *oo = &w->options;
+ struct options *oo = w->options;
struct tty *tty = &c->tty;
struct window_pane *wp;
struct grid_cell m_active_gc, active_gc, m_other_gc, other_gc;
@@ -392,7 +392,7 @@ screen_redraw_draw_number(struct client *c, struct window_pane *wp, u_int top)
{
struct tty *tty = &c->tty;
struct session *s = c->session;
- struct options *oo = &s->options;
+ struct options *oo = s->options;
struct window *w = wp->window;
struct grid_cell gc;
u_int idx, px, py, i, j, xoff, yoff;
diff --git a/server-client.c b/server-client.c
index 13f905b2..8d6eefa0 100644
--- a/server-client.c
+++ b/server-client.c
@@ -490,7 +490,7 @@ server_client_assume_paste(struct session *s)
struct timeval tv;
int t;
- if ((t = options_get_number(&s->options, "assume-paste-time")) == 0)
+ if ((t = options_get_number(s->options, "assume-paste-time")) == 0)
return (0);
timersub(&s->activity_time, &s->last_activity_time, &tv);
@@ -556,7 +556,7 @@ server_client_handle_key(struct client *c, int key)
m->valid = 1;
m->key = key;
- if (!options_get_number(&s->options, "mouse"))
+ if (!options_get_number(s->options, "mouse"))
goto forward;
} else
m->valid = 0;
@@ -593,7 +593,7 @@ retry:
* If this is a repeating key, start the timer. Otherwise reset
* the client back to the root table.
*/
- xtimeout = options_get_number(&s->options, "repeat-time");
+ xtimeout = options_get_number(s->options, "repeat-time");
if (xtimeout != 0 && bd->can_repeat) {
c->flags |= CLIENT_REPEAT;
@@ -635,8 +635,8 @@ retry:
* No match, but in the root table. Prefix switches to the prefix table
* and everything else is passed through.
*/
- if (key == options_get_number(&s->options, "prefix") ||
- key == options_get_number(&s->options, "prefix2")) {
+ if (key == options_get_number(s->options, "prefix") ||
+ key == options_get_number(s->options, "prefix2")) {
server_client_key_table(c, "prefix");
server_status_client(c);
return;
@@ -713,7 +713,7 @@ server_client_check_focus(struct window_pane *wp)
int push;
/* Are focus events off? */
- if (!options_get_number(&global_options, "focus-events"))
+ if (!options_get_number(global_options, "focus-events"))
return;
/* Do we need to push the focus state? */
@@ -773,7 +773,7 @@ server_client_reset_state(struct client *c)
struct window *w = c->session->curw->window;
struct window_pane *wp = w->active;
struct screen *s = wp->screen;
- struct options *oo = &c->session->options;
+ struct options *oo = c->session->options;
int status, mode, o;