Move struct options into options.c.

This commit is contained in:
nicm 2015-10-27 15:58:42 +00:00
parent 67c3a014b9
commit 44657bf932
37 changed files with 223 additions and 201 deletions

View File

@ -80,11 +80,11 @@ alerts_enabled(struct window *w, int flags)
struct session *s; struct session *s;
if (flags & WINDOW_ACTIVITY) { if (flags & WINDOW_ACTIVITY) {
if (options_get_number(&w->options, "monitor-activity")) if (options_get_number(w->options, "monitor-activity"))
return (1); return (1);
} }
if (flags & WINDOW_SILENCE) { if (flags & WINDOW_SILENCE) {
if (options_get_number(&w->options, "monitor-silence") != 0) if (options_get_number(w->options, "monitor-silence") != 0)
return (1); return (1);
} }
if (~flags & WINDOW_BELL) if (~flags & WINDOW_BELL)
@ -92,7 +92,7 @@ alerts_enabled(struct window *w, int flags)
RB_FOREACH(s, sessions, &sessions) { RB_FOREACH(s, sessions, &sessions) {
if (!session_has(s, w)) if (!session_has(s, w))
continue; continue;
if (options_get_number(&s->options, "bell-action") != BELL_NONE) if (options_get_number(s->options, "bell-action") != BELL_NONE)
return (1); return (1);
} }
return (0); return (0);
@ -116,7 +116,7 @@ alerts_reset(struct window *w)
event_del(&w->alerts_timer); event_del(&w->alerts_timer);
timerclear(&tv); 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); log_debug("@%u alerts timer reset %u", w->id, (u_int)tv.tv_sec);
if (tv.tv_sec != 0) if (tv.tv_sec != 0)
@ -160,11 +160,11 @@ alerts_check_bell(struct session *s, struct winlink *wl)
if (s->curw->window == w) if (s->curw->window == w)
w->flags &= ~WINDOW_BELL; w->flags &= ~WINDOW_BELL;
action = options_get_number(&s->options, "bell-action"); action = options_get_number(s->options, "bell-action");
if (action == BELL_NONE) if (action == BELL_NONE)
return (0); return (0);
visual = options_get_number(&s->options, "visual-bell"); visual = options_get_number(s->options, "visual-bell");
TAILQ_FOREACH(c, &clients, entry) { TAILQ_FOREACH(c, &clients, entry) {
if (c->session != s || c->flags & CLIENT_CONTROL) if (c->session != s || c->flags & CLIENT_CONTROL)
continue; continue;
@ -201,14 +201,14 @@ alerts_check_activity(struct session *s, struct winlink *wl)
if (s->curw == wl && !(s->flags & SESSION_UNATTACHED)) if (s->curw == wl && !(s->flags & SESSION_UNATTACHED))
return (0); return (0);
if (!options_get_number(&w->options, "monitor-activity")) if (!options_get_number(w->options, "monitor-activity"))
return (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); alerts_ring_bell(s);
wl->flags |= WINLINK_ACTIVITY; 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) { TAILQ_FOREACH(c, &clients, entry) {
if (c->session != s) if (c->session != s)
continue; continue;
@ -233,14 +233,14 @@ alerts_check_silence(struct session *s, struct winlink *wl)
if (s->curw == wl && !(s->flags & SESSION_UNATTACHED)) if (s->curw == wl && !(s->flags & SESSION_UNATTACHED))
return (0); return (0);
if (options_get_number(&w->options, "monitor-silence") == 0) if (options_get_number(w->options, "monitor-silence") == 0)
return (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); alerts_ring_bell(s);
wl->flags |= WINLINK_SILENCE; 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) { TAILQ_FOREACH(c, &clients, entry) {
if (c->session != s) if (c->session != s)
continue; continue;

View File

@ -291,9 +291,9 @@ client_main(struct event_base *base, int argc, char **argv, int flags)
fatal("pledge failed"); fatal("pledge failed");
/* Free stuff that is not used in the client. */ /* Free stuff that is not used in the client. */
options_free(&global_options); options_free(global_options);
options_free(&global_s_options); options_free(global_s_options);
options_free(&global_w_options); options_free(global_w_options);
environ_free(&global_environ); environ_free(&global_environ);
/* Create stdin handler. */ /* Create stdin handler. */

View File

@ -121,7 +121,7 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
} }
if (!Eflag) { if (!Eflag) {
update = options_get_string(&s->options, update = options_get_string(s->options,
"update-environment"); "update-environment");
environ_update(update, &c->environ, &s->environ); 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) { if (!Eflag) {
update = options_get_string(&s->options, update = options_get_string(s->options,
"update-environment"); "update-environment");
environ_update(update, &c->environ, &s->environ); environ_update(update, &c->environ, &s->environ);
} }

View File

@ -84,7 +84,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_q *cmdq)
layout_init(w, wp); layout_init(w, wp);
if (idx == -1) 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 */ wl = session_attach(dst_s, w, idx, &cause); /* can't fail */
if (!args_has(self->args, 'd')) if (!args_has(self->args, 'd'))
session_select(dst_s, wl->idx); session_select(dst_s, wl->idx);

View File

@ -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) if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
return (CMD_RETURN_ERROR); 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) if (paste_get_top(NULL) == NULL)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);

View File

@ -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 * session already has the correct winlink id to us, either
* automatically or specified by -s. * 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); session_renumber_windows(src);
recalculate_sizes(); recalculate_sizes();

View File

@ -197,7 +197,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
goto error; goto error;
} }
} }
if (sy > 0 && options_get_number(&global_s_options, "status")) if (sy > 0 && options_get_number(global_s_options, "status"))
sy--; sy--;
if (sx == 0) if (sx == 0)
sx = 1; sx = 1;
@ -211,7 +211,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
argc = args->argc; argc = args->argc;
argv = args->argv; argv = args->argv;
} else if (target == NULL) { } 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') { if (cmd != NULL && *cmd != '\0') {
argc = 1; argc = 1;
argv = &cmd; argv = &cmd;
@ -232,13 +232,13 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
/* Construct the environment. */ /* Construct the environment. */
environ_init(&env); environ_init(&env);
if (c != NULL && !args_has(args, 'E')) { if (c != NULL && !args_has(args, 'E')) {
update = options_get_string(&global_s_options, update = options_get_string(global_s_options,
"update-environment"); "update-environment");
environ_update(update, &c->environ, &env); environ_update(update, &c->environ, &env);
} }
/* Create the new session. */ /* 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, s = session_create(newname, argc, argv, path, cwd, &env, tiop, idx, sx,
sy, &cause); sy, &cause);
if (s == NULL) { 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')) { if (argc >= 0 && args_has(args, 'n')) {
w = s->curw->window; w = s->curw->window;
window_set_name(w, args_get(args, 'n')); window_set_name(w, args_get(args, 'n'));
options_set_number(&w->options, "automatic-rename", 0); options_set_number(w->options, "automatic-rename", 0);
} }
/* /*

View File

@ -71,7 +71,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
detached = args_has(args, 'd'); detached = args_has(args, 'd');
if (args->argc == 0) { 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') { if (cmd != NULL && *cmd != '\0') {
argc = 1; argc = 1;
argv = (char **)&cmd; argv = (char **)&cmd;
@ -136,7 +136,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
} }
if (idx == -1) 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, wl = session_new(s, args_get(args, 'n'), argc, argv, path, cwd, idx,
&cause); &cause);
if (wl == NULL) { if (wl == NULL) {

View File

@ -47,7 +47,7 @@ cmd_rename_window_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
window_set_name(wl->window, args->argv[0]); 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); server_status_window(wl->window);

View File

@ -70,9 +70,9 @@ cmd_send_keys_exec(struct cmd *self, struct cmd_q *cmdq)
if (self->entry == &cmd_send_prefix_entry) { if (self->entry == &cmd_send_prefix_entry) {
if (args_has(args, '2')) if (args_has(args, '2'))
key = options_get_number(&s->options, "prefix2"); key = options_get_number(s->options, "prefix2");
else else
key = options_get_number(&s->options, "prefix"); key = options_get_number(s->options, "prefix");
window_pane_key(wp, NULL, s, key, NULL); window_pane_key(wp, NULL, s, key, NULL);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

View File

@ -126,10 +126,10 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
/* Work out the tree from the table. */ /* Work out the tree from the table. */
if (table == server_options_table) if (table == server_options_table)
oo = &global_options; oo = global_options;
else if (table == window_options_table) { else if (table == window_options_table) {
if (args_has(self->args, 'g')) if (args_has(self->args, 'g'))
oo = &global_w_options; oo = global_w_options;
else { else {
wl = cmd_find_window(cmdq, args_get(args, 't'), NULL); wl = cmd_find_window(cmdq, args_get(args, 't'), NULL);
if (wl == 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" : ""); 'g')) ? " need target window or -g" : "");
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
oo = &wl->window->options; oo = wl->window->options;
} }
} else if (table == session_options_table) { } else if (table == session_options_table) {
if (args_has(self->args, 'g')) if (args_has(self->args, 'g'))
oo = &global_s_options; oo = global_s_options;
else { else {
s = cmd_find_session(cmdq, args_get(args, 't'), 0); s = cmd_find_session(cmdq, args_get(args, 't'), 0);
if (s == NULL) { if (s == NULL) {
@ -153,7 +153,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
'g')) ? " need target session or -g" : ""); 'g')) ? " need target session or -g" : "");
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
oo = &s->options; oo = s->options;
} }
} else { } else {
cmdq_error(cmdq, "unknown table"); 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. */ /* Start or stop timers if necessary. */
if (strcmp(oe->name, "automatic-rename") == 0) { if (strcmp(oe->name, "automatic-rename") == 0) {
RB_FOREACH(w, windows, &windows) { 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; 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; struct options *oo;
if (args_has(args, 's')) if (args_has(args, 's'))
oo = &global_options; oo = global_options;
else if (args_has(self->args, 'w') || else if (args_has(self->args, 'w') ||
self->entry == &cmd_set_window_option_entry) { self->entry == &cmd_set_window_option_entry) {
if (args_has(self->args, 'g')) if (args_has(self->args, 'g'))
oo = &global_w_options; oo = global_w_options;
else { else {
wl = cmd_find_window(cmdq, args_get(args, 't'), NULL); wl = cmd_find_window(cmdq, args_get(args, 't'), NULL);
if (wl == NULL) if (wl == NULL)
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
oo = &wl->window->options; oo = wl->window->options;
} }
} else { } else {
if (args_has(self->args, 'g')) if (args_has(self->args, 'g'))
oo = &global_s_options; oo = global_s_options;
else { else {
s = cmd_find_session(cmdq, args_get(args, 't'), 0); s = cmd_find_session(cmdq, args_get(args, 't'), 0);
if (s == NULL) if (s == NULL)
return (CMD_RETURN_ERROR); 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); return (-1);
} }
if (args_has(args, 'g') || oo == &global_options) { if (args_has(args, 'g') || oo == global_options) {
switch (oe->type) { switch (oe->type) {
case OPTIONS_TABLE_STRING: case OPTIONS_TABLE_STRING:
options_set_string(oo, oe->name, "%s", oe->default_str); options_set_string(oo, oe->name, "%s", oe->default_str);

View File

@ -61,28 +61,28 @@ cmd_show_options_exec(struct cmd *self, struct cmd_q *cmdq)
int quiet; int quiet;
if (args_has(self->args, 's')) { if (args_has(self->args, 's')) {
oo = &global_options; oo = global_options;
table = server_options_table; table = server_options_table;
} else if (args_has(self->args, 'w') || } else if (args_has(self->args, 'w') ||
self->entry == &cmd_show_window_options_entry) { self->entry == &cmd_show_window_options_entry) {
table = window_options_table; table = window_options_table;
if (args_has(self->args, 'g')) if (args_has(self->args, 'g'))
oo = &global_w_options; oo = global_w_options;
else { else {
wl = cmd_find_window(cmdq, args_get(args, 't'), NULL); wl = cmd_find_window(cmdq, args_get(args, 't'), NULL);
if (wl == NULL) if (wl == NULL)
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
oo = &wl->window->options; oo = wl->window->options;
} }
} else { } else {
table = session_options_table; table = session_options_table;
if (args_has(self->args, 'g')) if (args_has(self->args, 'g'))
oo = &global_s_options; oo = global_s_options;
else { else {
s = cmd_find_session(cmdq, args_get(args, 't'), 0); s = cmd_find_session(cmdq, args_get(args, 't'), 0);
if (s == NULL) if (s == NULL)
return (CMD_RETURN_ERROR); 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; struct options_entry *o;
const char *optval; const char *optval;
RB_FOREACH(o, options_tree, &oo->tree) { o = options_first(oo);
while (o != NULL) {
if (*o->name == '@') { if (*o->name == '@') {
if (args_has(self->args, 'v')) if (args_has(self->args, 'v'))
cmdq_print(cmdq, "%s", o->str); cmdq_print(cmdq, "%s", o->str);
else else
cmdq_print(cmdq, "%s \"%s\"", o->name, o->str); cmdq_print(cmdq, "%s \"%s\"", o->name, o->str);
} }
o = options_next(o);
} }
for (oe = table; oe->name != NULL; oe++) { for (oe = table; oe->name != NULL; oe++) {

View File

@ -73,7 +73,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
server_fill_environ(s, &env); server_fill_environ(s, &env);
if (args->argc == 0) { 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') { if (cmd != NULL && *cmd != '\0') {
argc = 1; argc = 1;
argv = (char **)&cmd; argv = (char **)&cmd;
@ -135,9 +135,9 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
else else
size = (wp->sx * percentage) / 100; 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)) if (*shell == '\0' || areshell(shell))
shell = _PATH_BSHELL; shell = _PATH_BSHELL;

View File

@ -120,7 +120,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq)
} }
if (c != NULL && !args_has(args, 'E')) { 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); environ_update(update, &c->environ, &s->environ);
} }

View File

@ -581,15 +581,15 @@ format_find(struct format_tree *ft, const char *key, int modifiers)
found = NULL; found = NULL;
if (~modifiers & FORMAT_TIMESTRING) { if (~modifiers & FORMAT_TIMESTRING) {
o = options_find(&global_options, key); o = options_find(global_options, key);
if (o == NULL && ft->w != NULL) if (o == NULL && ft->w != NULL)
o = options_find(&ft->w->options, key); o = options_find(ft->w->options, key);
if (o == NULL) if (o == NULL)
o = options_find(&global_w_options, key); o = options_find(global_w_options, key);
if (o == NULL && ft->s != NULL) if (o == NULL && ft->s != NULL)
o = options_find(&ft->s->options, key); o = options_find(ft->s->options, key);
if (o == NULL) if (o == NULL)
o = options_find(&global_s_options, key); o = options_find(global_s_options, key);
if (o != NULL) { if (o != NULL) {
switch (o->type) { switch (o->type) {
case OPTIONS_STRING: 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_in_mode", "%d", wp->screen != &wp->base);
format_add(ft, "pane_synchronized", "%d", 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_tty", "%s", wp->tty);
format_add(ft, "pane_pid", "%ld", (long) wp->pid); format_add(ft, "pane_pid", "%ld", (long) wp->pid);

View File

@ -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 * Then try to look this up as an xterm key, if the flag to output them
* is set. * 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) { if ((out = xterm_keys_lookup(key)) != NULL) {
bufferevent_write(wp->event, out, strlen(out)); bufferevent_write(wp->event, out, strlen(out));
free(out); free(out);

View File

@ -1907,12 +1907,12 @@ input_exit_rename(struct input_ctx *ictx)
{ {
if (ictx->flags & INPUT_DISCARD) if (ictx->flags & INPUT_DISCARD)
return; return;
if (!options_get_number(&ictx->wp->window->options, "allow-rename")) if (!options_get_number(ictx->wp->window->options, "allow-rename"))
return; return;
log_debug("%s: \"%s\"", __func__, ictx->input_buf); log_debug("%s: \"%s\"", __func__, ictx->input_buf);
window_set_name(ictx->wp->window, 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); server_status_window(ictx->wp->window);
} }
@ -1921,7 +1921,7 @@ input_exit_rename(struct input_ctx *ictx)
int int
input_utf8_open(struct input_ctx *ictx) 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. */ /* Print, and do not switch state. */
input_print(ictx); input_print(ictx);
return (-1); return (-1);

View File

@ -245,10 +245,10 @@ layout_set_main_h(struct window *w)
width = (w->sx - (n - 1)) / columns; width = (w->sx - (n - 1)) / columns;
/* Get the main pane height and add one for separator line. */ /* 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. */ /* 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 * 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; height = (w->sy - (n - 1)) / rows;
/* Get the main pane width and add one for separator line. */ /* 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. */ /* 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 * If an other pane width was specified, honour it so long as it

View File

@ -58,7 +58,7 @@ check_window_name(struct window *w)
if (w->active == NULL) if (w->active == NULL)
return; return;
if (!options_get_number(&w->options, "automatic-rename")) if (!options_get_number(w->options, "automatic-rename"))
return; return;
if (~w->active->flags & PANE_CHANGED) { if (~w->active->flags & PANE_CHANGED) {
@ -122,7 +122,7 @@ format_window_name(struct window *w)
format_defaults_window(ft, w); format_defaults_window(ft, w);
format_defaults_pane(ft, w->active); 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); name = format_expand(ft, fmt);
format_free(ft); format_free(ft);

View File

@ -29,6 +29,13 @@
* a red-black tree. * 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); RB_GENERATE(options_tree, options_entry, entry, options_cmp);
int int
@ -37,11 +44,15 @@ options_cmp(struct options_entry *o1, struct options_entry *o2)
return (strcmp(o1->name, o2->name)); return (strcmp(o1->name, o2->name));
} }
void struct options *
options_init(struct options *oo, struct options *parent) options_create(struct options *parent)
{ {
struct options *oo;
oo = xcalloc(1, sizeof *oo);
RB_INIT(&oo->tree); RB_INIT(&oo->tree);
oo->parent = parent; oo->parent = parent;
return (oo);
} }
void void
@ -57,6 +68,19 @@ options_free(struct options *oo)
free(o->str); free(o->str);
free(o); 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 * struct options_entry *

View File

@ -151,7 +151,7 @@ paste_add(char *data, size_t size)
if (size == 0) if (size == 0)
return; 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) { RB_FOREACH_REVERSE_SAFE(pb, paste_time_tree, &paste_by_time, pb1) {
if (paste_num_automatic < limit) if (paste_num_automatic < limit)
break; break;

View File

@ -53,7 +53,7 @@ recalculate_sizes(void)
int flag, has_status, is_zoomed, forced; int flag, has_status, is_zoomed, forced;
RB_FOREACH(s, sessions, &sessions) { RB_FOREACH(s, sessions, &sessions) {
has_status = options_get_number(&s->options, "status"); has_status = options_get_number(s->options, "status");
s->attached = 0; s->attached = 0;
ssx = ssy = UINT_MAX; ssx = ssy = UINT_MAX;
@ -94,7 +94,7 @@ recalculate_sizes(void)
RB_FOREACH(w, windows, &windows) { RB_FOREACH(w, windows, &windows) {
if (w->active == NULL) if (w->active == NULL)
continue; continue;
flag = options_get_number(&w->options, "aggressive-resize"); flag = options_get_number(w->options, "aggressive-resize");
ssx = ssy = UINT_MAX; ssx = ssy = UINT_MAX;
RB_FOREACH(s, sessions, &sessions) { RB_FOREACH(s, sessions, &sessions) {
@ -115,12 +115,12 @@ recalculate_sizes(void)
continue; continue;
forced = 0; forced = 0;
limit = options_get_number(&w->options, "force-width"); limit = options_get_number(w->options, "force-width");
if (limit >= PANE_MINIMUM && ssx > limit) { if (limit >= PANE_MINIMUM && ssx > limit) {
ssx = limit; ssx = limit;
forced |= WINDOW_FORCEWIDTH; 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) { if (limit >= PANE_MINIMUM && ssy > limit) {
ssy = limit; ssy = limit;
forced |= WINDOW_FORCEHEIGHT; forced |= WINDOW_FORCEHEIGHT;

View File

@ -222,7 +222,7 @@ void
screen_redraw_screen(struct client *c, int draw_panes, int draw_status, screen_redraw_screen(struct client *c, int draw_panes, int draw_status,
int draw_borders) int draw_borders)
{ {
struct options *oo = &c->session->options; struct options *oo = c->session->options;
struct tty *tty = &c->tty; struct tty *tty = &c->tty;
u_int top; u_int top;
int status, spos; 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 session *s = c->session;
struct window *w = s->curw->window; struct window *w = s->curw->window;
struct options *oo = &w->options; struct options *oo = w->options;
struct tty *tty = &c->tty; struct tty *tty = &c->tty;
struct window_pane *wp; struct window_pane *wp;
struct grid_cell m_active_gc, active_gc, m_other_gc, other_gc; 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 tty *tty = &c->tty;
struct session *s = c->session; struct session *s = c->session;
struct options *oo = &s->options; struct options *oo = s->options;
struct window *w = wp->window; struct window *w = wp->window;
struct grid_cell gc; struct grid_cell gc;
u_int idx, px, py, i, j, xoff, yoff; u_int idx, px, py, i, j, xoff, yoff;

View File

@ -490,7 +490,7 @@ server_client_assume_paste(struct session *s)
struct timeval tv; struct timeval tv;
int t; 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); return (0);
timersub(&s->activity_time, &s->last_activity_time, &tv); 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->valid = 1;
m->key = key; m->key = key;
if (!options_get_number(&s->options, "mouse")) if (!options_get_number(s->options, "mouse"))
goto forward; goto forward;
} else } else
m->valid = 0; m->valid = 0;
@ -593,7 +593,7 @@ retry:
* If this is a repeating key, start the timer. Otherwise reset * If this is a repeating key, start the timer. Otherwise reset
* the client back to the root table. * 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) { if (xtimeout != 0 && bd->can_repeat) {
c->flags |= CLIENT_REPEAT; c->flags |= CLIENT_REPEAT;
@ -635,8 +635,8 @@ retry:
* No match, but in the root table. Prefix switches to the prefix table * No match, but in the root table. Prefix switches to the prefix table
* and everything else is passed through. * and everything else is passed through.
*/ */
if (key == options_get_number(&s->options, "prefix") || if (key == options_get_number(s->options, "prefix") ||
key == options_get_number(&s->options, "prefix2")) { key == options_get_number(s->options, "prefix2")) {
server_client_key_table(c, "prefix"); server_client_key_table(c, "prefix");
server_status_client(c); server_status_client(c);
return; return;
@ -713,7 +713,7 @@ server_client_check_focus(struct window_pane *wp)
int push; int push;
/* Are focus events off? */ /* Are focus events off? */
if (!options_get_number(&global_options, "focus-events")) if (!options_get_number(global_options, "focus-events"))
return; return;
/* Do we need to push the focus state? */ /* 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 *w = c->session->curw->window;
struct window_pane *wp = w->active; struct window_pane *wp = w->active;
struct screen *s = wp->screen; struct screen *s = wp->screen;
struct options *oo = &c->session->options; struct options *oo = c->session->options;
int status, mode, o; int status, mode, o;
if (c->flags & CLIENT_SUSPENDED) if (c->flags & CLIENT_SUSPENDED)
@ -862,7 +862,7 @@ server_client_check_redraw(struct client *c)
return; return;
if (c->flags & (CLIENT_REDRAW|CLIENT_STATUS)) { if (c->flags & (CLIENT_REDRAW|CLIENT_STATUS)) {
if (options_get_number(&s->options, "set-titles")) if (options_get_number(s->options, "set-titles"))
server_client_set_title(c); server_client_set_title(c);
if (c->message_string != NULL) if (c->message_string != NULL)
@ -922,7 +922,7 @@ server_client_set_title(struct client *c)
char *title; char *title;
struct format_tree *ft; struct format_tree *ft;
template = options_get_string(&s->options, "set-titles-string"); template = options_get_string(s->options, "set-titles-string");
ft = format_create(); ft = format_create();
format_defaults(ft, c, NULL, NULL, NULL); format_defaults(ft, c, NULL, NULL, NULL);
@ -1206,7 +1206,7 @@ server_client_dispatch_shell(struct client *c)
{ {
const char *shell; const char *shell;
shell = options_get_string(&global_s_options, "default-shell"); shell = options_get_string(global_s_options, "default-shell");
if (*shell == '\0' || areshell(shell)) if (*shell == '\0' || areshell(shell))
shell = _PATH_BSHELL; shell = _PATH_BSHELL;
proc_send_s(c->peer, MSG_SHELL, shell); proc_send_s(c->peer, MSG_SHELL, shell);

View File

@ -39,7 +39,7 @@ server_fill_environ(struct session *s, struct environ *env)
long pid; long pid;
if (s != NULL) { if (s != NULL) {
term = options_get_string(&global_options, "default-terminal"); term = options_get_string(global_options, "default-terminal");
environ_set(env, "TERM", term); environ_set(env, "TERM", term);
idx = s->id; idx = s->id;
@ -183,7 +183,7 @@ server_lock_client(struct client *c)
if (c->flags & CLIENT_SUSPENDED) if (c->flags & CLIENT_SUSPENDED)
return; return;
cmd = options_get_string(&c->session->options, "lock-command"); cmd = options_get_string(c->session->options, "lock-command");
if (strlen(cmd) + 1 > MAX_IMSGSIZE - IMSG_HEADER_SIZE) if (strlen(cmd) + 1 > MAX_IMSGSIZE - IMSG_HEADER_SIZE)
return; return;
@ -219,7 +219,7 @@ server_kill_window(struct window *w)
server_redraw_session_group(s); server_redraw_session_group(s);
} }
if (options_get_number(&s->options, "renumber-windows")) { if (options_get_number(s->options, "renumber-windows")) {
if ((sg = session_group_find(s)) != NULL) { if ((sg = session_group_find(s)) != NULL) {
TAILQ_FOREACH(target_s, &sg->sessions, gentry) TAILQ_FOREACH(target_s, &sg->sessions, gentry)
session_renumber_windows(target_s); session_renumber_windows(target_s);
@ -272,7 +272,7 @@ server_link_window(struct session *src, struct winlink *srcwl,
} }
if (dstidx == -1) if (dstidx == -1)
dstidx = -1 - options_get_number(&dst->options, "base-index"); dstidx = -1 - options_get_number(dst->options, "base-index");
dstwl = session_attach(dst, srcwl->window, dstidx, cause); dstwl = session_attach(dst, srcwl->window, dstidx, cause);
if (dstwl == NULL) if (dstwl == NULL)
return (-1); return (-1);
@ -308,7 +308,7 @@ server_destroy_pane(struct window_pane *wp)
wp->fd = -1; wp->fd = -1;
} }
if (options_get_number(&w->options, "remain-on-exit")) { if (options_get_number(w->options, "remain-on-exit")) {
if (old_fd == -1) if (old_fd == -1)
return; return;
screen_write_start(&ctx, wp, &wp->base); screen_write_start(&ctx, wp, &wp->base);
@ -371,7 +371,7 @@ server_destroy_session(struct session *s)
struct client *c; struct client *c;
struct session *s_new; struct session *s_new;
if (!options_get_number(&s->options, "detach-on-destroy")) if (!options_get_number(s->options, "detach-on-destroy"))
s_new = server_next_session(s); s_new = server_next_session(s);
else else
s_new = NULL; s_new = NULL;
@ -407,7 +407,7 @@ server_check_unattached(void)
RB_FOREACH(s, sessions, &sessions) { RB_FOREACH(s, sessions, &sessions) {
if (!(s->flags & SESSION_UNATTACHED)) if (!(s->flags & SESSION_UNATTACHED))
continue; continue;
if (options_get_number (&s->options, "destroy-unattached")) if (options_get_number (s->options, "destroy-unattached"))
session_destroy(s); session_destroy(s);
} }
} }
@ -418,7 +418,7 @@ server_set_identify(struct client *c)
struct timeval tv; struct timeval tv;
int delay; int delay;
delay = options_get_number(&c->session->options, "display-panes-time"); delay = options_get_number(c->session->options, "display-panes-time");
tv.tv_sec = delay / 1000; tv.tv_sec = delay / 1000;
tv.tv_usec = (delay % 1000) * 1000L; tv.tv_usec = (delay % 1000) * 1000L;

View File

@ -217,7 +217,7 @@ server_loop(void)
server_client_loop(); server_client_loop();
if (!options_get_number(&global_options, "exit-unattached")) { if (!options_get_number(global_options, "exit-unattached")) {
if (!RB_EMPTY(&sessions)) if (!RB_EMPTY(&sessions))
return (0); return (0);
} }

View File

@ -120,10 +120,10 @@ session_create(const char *name, int argc, char **argv, const char *path,
TAILQ_INIT(&s->lastw); TAILQ_INIT(&s->lastw);
RB_INIT(&s->windows); RB_INIT(&s->windows);
options_init(&s->options, &global_s_options);
environ_init(&s->environ); environ_init(&s->environ);
if (env != NULL) if (env != NULL)
environ_copy(env, &s->environ); environ_copy(env, &s->environ);
s->options = options_create(global_s_options);
s->tio = NULL; s->tio = NULL;
if (tio != NULL) { if (tio != NULL) {
@ -190,6 +190,9 @@ session_free(unused int fd, unused short events, void *arg)
log_debug("session %s freed (%d references)", s->name, s->references); log_debug("session %s freed (%d references)", s->name, s->references);
if (s->references == 0) { if (s->references == 0) {
environ_free(&s->environ);
options_free(s->options);
free(s->name); free(s->name);
free(s); free(s);
} }
@ -212,8 +215,6 @@ session_destroy(struct session *s)
event_del(&s->lock_timer); event_del(&s->lock_timer);
session_group_remove(s); session_group_remove(s);
environ_free(&s->environ);
options_free(&s->options);
while (!TAILQ_EMPTY(&s->lastw)) while (!TAILQ_EMPTY(&s->lastw))
winlink_stack_remove(&s->lastw, TAILQ_FIRST(&s->lastw)); winlink_stack_remove(&s->lastw, TAILQ_FIRST(&s->lastw));
@ -271,7 +272,7 @@ session_update_activity(struct session *s, struct timeval *from)
if (~s->flags & SESSION_UNATTACHED) { if (~s->flags & SESSION_UNATTACHED) {
timerclear(&tv); timerclear(&tv);
tv.tv_sec = options_get_number(&s->options, "lock-after-time"); tv.tv_sec = options_get_number(s->options, "lock-after-time");
if (tv.tv_sec != 0) if (tv.tv_sec != 0)
evtimer_add(&s->lock_timer, &tv); evtimer_add(&s->lock_timer, &tv);
} }
@ -332,11 +333,11 @@ session_new(struct session *s, const char *name, int argc, char **argv,
environ_copy(&s->environ, &env); environ_copy(&s->environ, &env);
server_fill_environ(s, &env); server_fill_environ(s, &env);
shell = options_get_string(&s->options, "default-shell"); shell = options_get_string(s->options, "default-shell");
if (*shell == '\0' || areshell(shell)) if (*shell == '\0' || areshell(shell))
shell = _PATH_BSHELL; shell = _PATH_BSHELL;
hlimit = options_get_number(&s->options, "history-limit"); hlimit = options_get_number(s->options, "history-limit");
w = window_create(name, argc, argv, path, shell, cwd, &env, s->tio, w = window_create(name, argc, argv, path, shell, cwd, &env, s->tio,
s->sx, s->sy, hlimit, cause); s->sx, s->sy, hlimit, cause);
if (w == NULL) { if (w == NULL) {
@ -348,8 +349,8 @@ session_new(struct session *s, const char *name, int argc, char **argv,
notify_window_linked(s, w); notify_window_linked(s, w);
environ_free(&env); environ_free(&env);
if (options_get_number(&s->options, "set-remain-on-exit")) if (options_get_number(s->options, "set-remain-on-exit"))
options_set_number(&w->options, "remain-on-exit", 1); options_set_number(w->options, "remain-on-exit", 1);
session_group_synchronize_from(s); session_group_synchronize_from(s);
return (wl); return (wl);
@ -712,7 +713,7 @@ session_renumber_windows(struct session *s)
RB_INIT(&s->windows); RB_INIT(&s->windows);
/* Start renumbering from the base-index if it's set. */ /* Start renumbering from the base-index if it's set. */
new_idx = options_get_number(&s->options, "base-index"); new_idx = options_get_number(s->options, "base-index");
new_curw_idx = 0; new_curw_idx = 0;
/* Go through the winlinks and assign new indexes. */ /* Go through the winlinks and assign new indexes. */

View File

@ -61,7 +61,7 @@ status_prompt_find_history_file(void)
const char *home, *history_file; const char *home, *history_file;
char *path; char *path;
history_file = options_get_string(&global_options, "history-file"); history_file = options_get_string(global_options, "history-file");
if (*history_file == '\0') if (*history_file == '\0')
return (NULL); return (NULL);
if (*history_file == '/') if (*history_file == '/')
@ -160,7 +160,7 @@ status_timer_callback(unused int fd, unused short events, void *arg)
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_STATUS;
timerclear(&tv); timerclear(&tv);
tv.tv_sec = options_get_number(&s->options, "status-interval"); tv.tv_sec = options_get_number(s->options, "status-interval");
if (tv.tv_sec != 0) if (tv.tv_sec != 0)
evtimer_add(&c->status_timer, &tv); evtimer_add(&c->status_timer, &tv);
@ -178,7 +178,7 @@ status_timer_start(struct client *c)
else else
evtimer_set(&c->status_timer, status_timer_callback, c); evtimer_set(&c->status_timer, status_timer_callback, c);
if (s != NULL && options_get_number(&s->options, "status")) if (s != NULL && options_get_number(s->options, "status"))
status_timer_callback(-1, 0, c); status_timer_callback(-1, 0, c);
} }
@ -198,10 +198,10 @@ status_at_line(struct client *c)
{ {
struct session *s = c->session; struct session *s = c->session;
if (!options_get_number(&s->options, "status")) if (!options_get_number(s->options, "status"))
return (-1); return (-1);
if (options_get_number(&s->options, "status-position") == 0) if (options_get_number(s->options, "status-position") == 0)
return (0); return (0);
return (c->tty.sy - 1); return (c->tty.sy - 1);
} }
@ -216,12 +216,12 @@ status_redraw_get_left(struct client *c, time_t t, int utf8flag,
char *left; char *left;
size_t leftlen; size_t leftlen;
style_apply_update(gc, &s->options, "status-left-style"); style_apply_update(gc, s->options, "status-left-style");
template = options_get_string(&s->options, "status-left"); template = options_get_string(s->options, "status-left");
left = status_replace(c, NULL, template, t); left = status_replace(c, NULL, template, t);
*size = options_get_number(&s->options, "status-left-length"); *size = options_get_number(s->options, "status-left-length");
leftlen = screen_write_cstrlen(utf8flag, "%s", left); leftlen = screen_write_cstrlen(utf8flag, "%s", left);
if (leftlen < *size) if (leftlen < *size)
*size = leftlen; *size = leftlen;
@ -238,12 +238,12 @@ status_redraw_get_right(struct client *c, time_t t, int utf8flag,
char *right; char *right;
size_t rightlen; size_t rightlen;
style_apply_update(gc, &s->options, "status-right-style"); style_apply_update(gc, s->options, "status-right-style");
template = options_get_string(&s->options, "status-right"); template = options_get_string(s->options, "status-right");
right = status_replace(c, NULL, template, t); right = status_replace(c, NULL, template, t);
*size = options_get_number(&s->options, "status-right-length"); *size = options_get_number(s->options, "status-right-length");
rightlen = screen_write_cstrlen(utf8flag, "%s", right); rightlen = screen_write_cstrlen(utf8flag, "%s", right);
if (rightlen < *size) if (rightlen < *size)
*size = rightlen; *size = rightlen;
@ -261,7 +261,7 @@ status_get_window_at(struct client *c, u_int x)
x += c->wlmouse; x += c->wlmouse;
RB_FOREACH(wl, winlinks, &s->windows) { RB_FOREACH(wl, winlinks, &s->windows) {
oo = &wl->window->options; oo = wl->window->options;
len = strlen(options_get_string(oo, "window-status-separator")); len = strlen(options_get_string(oo, "window-status-separator"));
if (x < wl->status_width) if (x < wl->status_width)
@ -289,7 +289,7 @@ status_redraw(struct client *c)
int larrow, rarrow, utf8flag; int larrow, rarrow, utf8flag;
/* No status line? */ /* No status line? */
if (c->tty.sy == 0 || !options_get_number(&s->options, "status")) if (c->tty.sy == 0 || !options_get_number(s->options, "status"))
return (1); return (1);
left = right = NULL; left = right = NULL;
larrow = rarrow = 0; larrow = rarrow = 0;
@ -298,7 +298,7 @@ status_redraw(struct client *c)
t = time(NULL); t = time(NULL);
/* Set up default colour. */ /* Set up default colour. */
style_apply(&stdgc, &s->options, "status-style"); style_apply(&stdgc, s->options, "status-style");
/* Create the target screen. */ /* Create the target screen. */
memcpy(&old_status, &c->status, sizeof old_status); memcpy(&old_status, &c->status, sizeof old_status);
@ -313,7 +313,7 @@ status_redraw(struct client *c)
goto out; goto out;
/* Get UTF-8 flag. */ /* Get UTF-8 flag. */
utf8flag = options_get_number(&s->options, "status-utf8"); utf8flag = options_get_number(s->options, "status-utf8");
/* Work out left and right strings. */ /* Work out left and right strings. */
memcpy(&lgc, &stdgc, sizeof lgc); memcpy(&lgc, &stdgc, sizeof lgc);
@ -346,7 +346,7 @@ status_redraw(struct client *c)
if (wl == s->curw) if (wl == s->curw)
wloffset = wlwidth; wloffset = wlwidth;
oo = &wl->window->options; oo = wl->window->options;
sep = options_get_string(oo, "window-status-separator"); sep = options_get_string(oo, "window-status-separator");
seplen = screen_write_strlen(utf8flag, "%s", sep); seplen = screen_write_strlen(utf8flag, "%s", sep);
wlwidth += wl->status_width + seplen; wlwidth += wl->status_width + seplen;
@ -361,7 +361,7 @@ status_redraw(struct client *c)
screen_write_cnputs(&ctx, screen_write_cnputs(&ctx,
-1, &wl->status_cell, utf8flag, "%s", wl->status_text); -1, &wl->status_cell, utf8flag, "%s", wl->status_text);
oo = &wl->window->options; oo = wl->window->options;
sep = options_get_string(oo, "window-status-separator"); sep = options_get_string(oo, "window-status-separator");
screen_write_nputs(&ctx, -1, &stdgc, utf8flag, "%s", sep); screen_write_nputs(&ctx, -1, &stdgc, utf8flag, "%s", sep);
} }
@ -461,7 +461,7 @@ draw:
else else
wloffset = 0; wloffset = 0;
if (wlwidth < wlavailable) { if (wlwidth < wlavailable) {
switch (options_get_number(&s->options, "status-justify")) { switch (options_get_number(s->options, "status-justify")) {
case 1: /* centred */ case 1: /* centred */
wloffset += (wlavailable - wlwidth) / 2; wloffset += (wlavailable - wlwidth) / 2;
break; break;
@ -520,7 +520,7 @@ char *
status_print(struct client *c, struct winlink *wl, time_t t, status_print(struct client *c, struct winlink *wl, time_t t,
struct grid_cell *gc) struct grid_cell *gc)
{ {
struct options *oo = &wl->window->options; struct options *oo = wl->window->options;
struct session *s = c->session; struct session *s = c->session;
const char *fmt; const char *fmt;
char *text; char *text;
@ -553,7 +553,7 @@ status_message_set(struct client *c, const char *fmt, ...)
int delay; int delay;
u_int first, limit; u_int first, limit;
limit = options_get_number(&global_options, "message-limit"); limit = options_get_number(global_options, "message-limit");
status_prompt_clear(c); status_prompt_clear(c);
status_message_clear(c); status_message_clear(c);
@ -577,7 +577,7 @@ status_message_set(struct client *c, const char *fmt, ...)
free(msg); free(msg);
} }
delay = options_get_number(&c->session->options, "display-time"); delay = options_get_number(c->session->options, "display-time");
tv.tv_sec = delay / 1000; tv.tv_sec = delay / 1000;
tv.tv_usec = (delay % 1000) * 1000L; tv.tv_usec = (delay % 1000) * 1000L;
@ -631,13 +631,13 @@ status_message_redraw(struct client *c)
memcpy(&old_status, &c->status, sizeof old_status); memcpy(&old_status, &c->status, sizeof old_status);
screen_init(&c->status, c->tty.sx, 1, 0); screen_init(&c->status, c->tty.sx, 1, 0);
utf8flag = options_get_number(&s->options, "status-utf8"); utf8flag = options_get_number(s->options, "status-utf8");
len = screen_write_strlen(utf8flag, "%s", c->message_string); len = screen_write_strlen(utf8flag, "%s", c->message_string);
if (len > c->tty.sx) if (len > c->tty.sx)
len = c->tty.sx; len = c->tty.sx;
style_apply(&gc, &s->options, "message-style"); style_apply(&gc, s->options, "message-style");
screen_write_start(&ctx, NULL, &c->status); screen_write_start(&ctx, NULL, &c->status);
@ -686,7 +686,7 @@ status_prompt_set(struct client *c, const char *msg, const char *input,
c->prompt_flags = flags; c->prompt_flags = flags;
keys = options_get_number(&c->session->options, "status-keys"); keys = options_get_number(c->session->options, "status-keys");
if (keys == MODEKEY_EMACS) if (keys == MODEKEY_EMACS)
mode_key_init(&c->prompt_mdata, &mode_key_tree_emacs_edit); mode_key_init(&c->prompt_mdata, &mode_key_tree_emacs_edit);
else else
@ -761,7 +761,7 @@ status_prompt_redraw(struct client *c)
memcpy(&old_status, &c->status, sizeof old_status); memcpy(&old_status, &c->status, sizeof old_status);
screen_init(&c->status, c->tty.sx, 1, 0); screen_init(&c->status, c->tty.sx, 1, 0);
utf8flag = options_get_number(&s->options, "status-utf8"); utf8flag = options_get_number(s->options, "status-utf8");
len = screen_write_strlen(utf8flag, "%s", c->prompt_string); len = screen_write_strlen(utf8flag, "%s", c->prompt_string);
if (len > c->tty.sx) if (len > c->tty.sx)
@ -770,9 +770,9 @@ status_prompt_redraw(struct client *c)
/* Change colours for command mode. */ /* Change colours for command mode. */
if (c->prompt_mdata.mode == 1) if (c->prompt_mdata.mode == 1)
style_apply(&gc, &s->options, "message-command-style"); style_apply(&gc, s->options, "message-command-style");
else else
style_apply(&gc, &s->options, "message-style"); style_apply(&gc, s->options, "message-style");
screen_write_start(&ctx, NULL, &c->status); screen_write_start(&ctx, NULL, &c->status);
@ -815,7 +815,7 @@ void
status_prompt_key(struct client *c, int key) status_prompt_key(struct client *c, int key)
{ {
struct session *sess = c->session; struct session *sess = c->session;
struct options *oo = &sess->options; struct options *oo = sess->options;
struct paste_buffer *pb; struct paste_buffer *pb;
char *s, *first, *last, word[64], swapc; char *s, *first, *last, word[64], swapc;
const char *histstr, *bufdata, *wsep = NULL; const char *histstr, *bufdata, *wsep = NULL;

31
tmux.c
View File

@ -38,9 +38,9 @@
extern char *malloc_options; extern char *malloc_options;
#endif #endif
struct options global_options; /* server options */ struct options *global_options; /* server options */
struct options global_s_options; /* session options */ struct options *global_s_options; /* session options */
struct options global_w_options; /* window options */ struct options *global_w_options; /* window options */
struct environ global_environ; struct environ global_environ;
char *shell_cmd; char *shell_cmd;
@ -281,22 +281,21 @@ main(int argc, char **argv)
if (getcwd(tmp, sizeof tmp) != NULL) if (getcwd(tmp, sizeof tmp) != NULL)
environ_set(&global_environ, "PWD", tmp); environ_set(&global_environ, "PWD", tmp);
options_init(&global_options, NULL); global_options = options_create(NULL);
options_table_populate_tree(server_options_table, &global_options); options_table_populate_tree(server_options_table, global_options);
options_init(&global_s_options, NULL); global_s_options = options_create(NULL);
options_table_populate_tree(session_options_table, &global_s_options); options_table_populate_tree(session_options_table, global_s_options);
options_set_string(&global_s_options, "default-shell", "%s", options_set_string(global_s_options, "default-shell", "%s", getshell());
getshell());
options_init(&global_w_options, NULL); global_w_options = options_create(NULL);
options_table_populate_tree(window_options_table, &global_w_options); options_table_populate_tree(window_options_table, global_w_options);
/* Enable UTF-8 if the first client is on UTF-8 terminal. */ /* Enable UTF-8 if the first client is on UTF-8 terminal. */
if (flags & CLIENT_UTF8) { if (flags & CLIENT_UTF8) {
options_set_number(&global_s_options, "status-utf8", 1); options_set_number(global_s_options, "status-utf8", 1);
options_set_number(&global_s_options, "mouse-utf8", 1); options_set_number(global_s_options, "mouse-utf8", 1);
options_set_number(&global_w_options, "utf8", 1); options_set_number(global_w_options, "utf8", 1);
} }
/* Override keys to vi if VISUAL or EDITOR are set. */ /* Override keys to vi if VISUAL or EDITOR are set. */
@ -307,8 +306,8 @@ main(int argc, char **argv)
keys = MODEKEY_VI; keys = MODEKEY_VI;
else else
keys = MODEKEY_EMACS; keys = MODEKEY_EMACS;
options_set_number(&global_s_options, "status-keys", keys); options_set_number(global_s_options, "status-keys", keys);
options_set_number(&global_w_options, "mode-keys", keys); options_set_number(global_w_options, "mode-keys", keys);
} }
/* /*

22
tmux.h
View File

@ -680,11 +680,6 @@ struct options_entry {
RB_ENTRY(options_entry) entry; RB_ENTRY(options_entry) entry;
}; };
struct options {
RB_HEAD(options_tree, options_entry) tree;
struct options *parent;
};
/* Scheduled job. */ /* Scheduled job. */
struct job { struct job {
enum { enum {
@ -866,6 +861,7 @@ TAILQ_HEAD(window_panes, window_pane);
RB_HEAD(window_pane_tree, window_pane); RB_HEAD(window_pane_tree, window_pane);
/* Window structure. */ /* Window structure. */
struct options;
struct window { struct window {
u_int id; u_int id;
@ -899,7 +895,7 @@ struct window {
#define WINDOW_FORCEHEIGHT 0x4000 #define WINDOW_FORCEHEIGHT 0x4000
#define WINDOW_ALERTFLAGS (WINDOW_BELL|WINDOW_ACTIVITY|WINDOW_SILENCE) #define WINDOW_ALERTFLAGS (WINDOW_BELL|WINDOW_ACTIVITY|WINDOW_SILENCE)
struct options options; struct options *options;
u_int references; u_int references;
@ -993,7 +989,7 @@ struct session {
struct winlink_stack lastw; struct winlink_stack lastw;
struct winlinks windows; struct winlinks windows;
struct options options; struct options *options;
#define SESSION_UNATTACHED 0x1 /* not attached to any clients */ #define SESSION_UNATTACHED 0x1 /* not attached to any clients */
int flags; int flags;
@ -1405,9 +1401,9 @@ struct options_table_entry {
#define CMD_BUFFER_USAGE "[-b buffer-name]" #define CMD_BUFFER_USAGE "[-b buffer-name]"
/* tmux.c */ /* tmux.c */
extern struct options global_options; extern struct options *global_options;
extern struct options global_s_options; extern struct options *global_s_options;
extern struct options global_w_options; extern struct options *global_w_options;
extern struct environ global_environ; extern struct environ global_environ;
extern char *shell_cmd; extern char *shell_cmd;
extern int debug_level; extern int debug_level;
@ -1509,10 +1505,10 @@ void notify_session_created(struct session *);
void notify_session_closed(struct session *); void notify_session_closed(struct session *);
/* options.c */ /* options.c */
int options_cmp(struct options_entry *, struct options_entry *); struct options *options_create(struct options *);
RB_PROTOTYPE(options_tree, options_entry, entry, options_cmp);
void options_init(struct options *, struct options *);
void options_free(struct options *); void options_free(struct options *);
struct options_entry *options_first(struct options *);
struct options_entry *options_next(struct options_entry *);
struct options_entry *options_find1(struct options *, const char *); struct options_entry *options_find1(struct options *, const char *);
struct options_entry *options_find(struct options *, const char *); struct options_entry *options_find(struct options *, const char *);
void options_remove(struct options *, const char *); void options_remove(struct options *, const char *);

View File

@ -564,7 +564,7 @@ partial_key:
} }
/* Get the time period. */ /* Get the time period. */
delay = options_get_number(&global_options, "escape-time"); delay = options_get_number(global_options, "escape-time");
tv.tv_sec = delay / 1000; tv.tv_sec = delay / 1000;
tv.tv_usec = (delay % 1000) * 1000L; tv.tv_usec = (delay % 1000) * 1000L;

View File

@ -457,7 +457,7 @@ tty_term_find(char *name, int fd, char **cause)
} }
/* Apply terminal overrides. */ /* Apply terminal overrides. */
s = options_get_string(&global_options, "terminal-overrides"); s = options_get_string(global_options, "terminal-overrides");
tty_term_override(term, s); tty_term_override(term, s);
/* Delete curses data. */ /* Delete curses data. */

8
tty.c
View File

@ -229,7 +229,7 @@ tty_start_tty(struct tty *tty)
tty_puts(tty, "\033[?1000l\033[?1002l\033[?1006l\033[?1005l"); tty_puts(tty, "\033[?1000l\033[?1002l\033[?1006l\033[?1005l");
if (tty_term_flag(tty->term, TTYC_XT)) { if (tty_term_flag(tty->term, TTYC_XT)) {
if (options_get_number(&global_options, "focus-events")) { if (options_get_number(global_options, "focus-events")) {
tty->flags |= TTY_FOCUS; tty->flags |= TTY_FOCUS;
tty_puts(tty, "\033[?1004h"); tty_puts(tty, "\033[?1004h");
} }
@ -457,7 +457,7 @@ tty_set_italics(struct tty *tty)
const char *s; const char *s;
if (tty_term_has(tty->term, TTYC_SITM)) { if (tty_term_has(tty->term, TTYC_SITM)) {
s = options_get_string(&global_options, "default-terminal"); s = options_get_string(global_options, "default-terminal");
if (strcmp(s, "screen") != 0 && strncmp(s, "screen-", 7) != 0) { if (strcmp(s, "screen") != 0 && strncmp(s, "screen-", 7) != 0) {
tty_putcode(tty, TTYC_SITM); tty_putcode(tty, TTYC_SITM);
return; return;
@ -1686,8 +1686,8 @@ tty_default_colours(struct grid_cell *gc, const struct window_pane *wp)
return; return;
pgc = &wp->colgc; pgc = &wp->colgc;
agc = options_get_style(&wp->window->options, "window-active-style"); agc = options_get_style(wp->window->options, "window-active-style");
wgc = options_get_style(&wp->window->options, "window-style"); wgc = options_get_style(wp->window->options, "window-style");
if (gc->fg == 8 && !(gc->flags & GRID_FLAG_FG256)) { if (gc->fg == 8 && !(gc->flags & GRID_FLAG_FG256)) {
if (pgc->fg != 8 || (pgc->flags & GRID_FLAG_FG256)) { if (pgc->fg != 8 || (pgc->flags & GRID_FLAG_FG256)) {

View File

@ -169,7 +169,7 @@ window_choose_init(struct window_pane *wp)
screen_init(s, screen_size_x(&wp->base), screen_size_y(&wp->base), 0); screen_init(s, screen_size_x(&wp->base), screen_size_y(&wp->base), 0);
s->mode &= ~MODE_CURSOR; s->mode &= ~MODE_CURSOR;
keys = options_get_number(&wp->window->options, "mode-keys"); keys = options_get_number(wp->window->options, "mode-keys");
if (keys == MODEKEY_EMACS) if (keys == MODEKEY_EMACS)
mode_key_init(&data->mdata, &mode_key_tree_emacs_choice); mode_key_init(&data->mdata, &mode_key_tree_emacs_choice);
else else
@ -748,7 +748,7 @@ window_choose_write_line(
{ {
struct window_choose_mode_data *data = wp->modedata; struct window_choose_mode_data *data = wp->modedata;
struct window_choose_mode_item *item; struct window_choose_mode_item *item;
struct options *oo = &wp->window->options; struct options *oo = wp->window->options;
struct screen *s = &data->screen; struct screen *s = &data->screen;
struct grid_cell gc; struct grid_cell gc;
size_t last, xoff = 0; size_t last, xoff = 0;
@ -759,7 +759,7 @@ window_choose_write_line(
fatalx("called before callback assigned"); fatalx("called before callback assigned");
last = screen_size_y(s) - 1; last = screen_size_y(s) - 1;
utf8flag = options_get_number(&wp->window->options, "utf8"); utf8flag = options_get_number(wp->window->options, "utf8");
memcpy(&gc, &grid_default_cell, sizeof gc); memcpy(&gc, &grid_default_cell, sizeof gc);
if (data->selected == data->top + py) if (data->selected == data->top + py)
style_apply(&gc, oo, "mode-style"); style_apply(&gc, oo, "mode-style");

View File

@ -204,8 +204,8 @@ window_clock_draw_screen(struct window_pane *wp)
struct tm *tm; struct tm *tm;
u_int i, j, x, y, idx; u_int i, j, x, y, idx;
colour = options_get_number(&wp->window->options, "clock-mode-colour"); colour = options_get_number(wp->window->options, "clock-mode-colour");
style = options_get_number(&wp->window->options, "clock-mode-style"); style = options_get_number(wp->window->options, "clock-mode-style");
screen_write_start(&ctx, NULL, s); screen_write_start(&ctx, NULL, s);

View File

@ -195,7 +195,7 @@ window_copy_init(struct window_pane *wp)
s = &data->screen; s = &data->screen;
screen_init(s, screen_size_x(&wp->base), screen_size_y(&wp->base), 0); screen_init(s, screen_size_x(&wp->base), screen_size_y(&wp->base), 0);
keys = options_get_number(&wp->window->options, "mode-keys"); keys = options_get_number(wp->window->options, "mode-keys");
if (keys == MODEKEY_EMACS) if (keys == MODEKEY_EMACS)
mode_key_init(&data->mdata, &mode_key_tree_emacs_copy); mode_key_init(&data->mdata, &mode_key_tree_emacs_copy);
else else
@ -286,7 +286,7 @@ window_copy_vadd(struct window_pane *wp, const char *fmt, va_list ap)
if (backing == &wp->base) if (backing == &wp->base)
return; return;
utf8flag = options_get_number(&wp->window->options, "utf8"); utf8flag = options_get_number(wp->window->options, "utf8");
memcpy(&gc, &grid_default_cell, sizeof gc); memcpy(&gc, &grid_default_cell, sizeof gc);
old_hsize = screen_hsize(data->backing); old_hsize = screen_hsize(data->backing);
@ -629,13 +629,13 @@ window_copy_key(struct window_pane *wp, struct client *c, struct session *sess,
break; break;
case MODEKEYCOPY_NEXTWORD: case MODEKEYCOPY_NEXTWORD:
word_separators = word_separators =
options_get_string(&sess->options, "word-separators"); options_get_string(sess->options, "word-separators");
for (; np != 0; np--) for (; np != 0; np--)
window_copy_cursor_next_word(wp, word_separators); window_copy_cursor_next_word(wp, word_separators);
break; break;
case MODEKEYCOPY_NEXTWORDEND: case MODEKEYCOPY_NEXTWORDEND:
word_separators = word_separators =
options_get_string(&sess->options, "word-separators"); options_get_string(sess->options, "word-separators");
for (; np != 0; np--) for (; np != 0; np--)
window_copy_cursor_next_word_end(wp, word_separators); window_copy_cursor_next_word_end(wp, word_separators);
break; break;
@ -645,7 +645,7 @@ window_copy_key(struct window_pane *wp, struct client *c, struct session *sess,
break; break;
case MODEKEYCOPY_PREVIOUSWORD: case MODEKEYCOPY_PREVIOUSWORD:
word_separators = word_separators =
options_get_string(&sess->options, "word-separators"); options_get_string(sess->options, "word-separators");
for (; np != 0; np--) for (; np != 0; np--)
window_copy_cursor_previous_word(wp, word_separators); window_copy_cursor_previous_word(wp, word_separators);
break; break;
@ -777,7 +777,7 @@ window_copy_key(struct window_pane *wp, struct client *c, struct session *sess,
return; return;
input_on: input_on:
keys = options_get_number(&wp->window->options, "mode-keys"); keys = options_get_number(wp->window->options, "mode-keys");
if (keys == MODEKEY_EMACS) if (keys == MODEKEY_EMACS)
mode_key_init(&data->mdata, &mode_key_tree_emacs_edit); mode_key_init(&data->mdata, &mode_key_tree_emacs_edit);
else else
@ -787,7 +787,7 @@ input_on:
return; return;
input_off: input_off:
keys = options_get_number(&wp->window->options, "mode-keys"); keys = options_get_number(wp->window->options, "mode-keys");
if (keys == MODEKEY_EMACS) if (keys == MODEKEY_EMACS)
mode_key_init(&data->mdata, &mode_key_tree_emacs_copy); mode_key_init(&data->mdata, &mode_key_tree_emacs_copy);
else else
@ -1026,8 +1026,8 @@ window_copy_search_up(struct window_pane *wp, const char *searchstr)
if (*searchstr == '\0') if (*searchstr == '\0')
return; return;
utf8flag = options_get_number(&wp->window->options, "utf8"); utf8flag = options_get_number(wp->window->options, "utf8");
wrapflag = options_get_number(&wp->window->options, "wrap-search"); wrapflag = options_get_number(wp->window->options, "wrap-search");
searchlen = screen_write_strlen(utf8flag, "%s", searchstr); searchlen = screen_write_strlen(utf8flag, "%s", searchstr);
screen_init(&ss, searchlen, 1, 0); screen_init(&ss, searchlen, 1, 0);
@ -1093,8 +1093,8 @@ window_copy_search_down(struct window_pane *wp, const char *searchstr)
if (*searchstr == '\0') if (*searchstr == '\0')
return; return;
utf8flag = options_get_number(&wp->window->options, "utf8"); utf8flag = options_get_number(wp->window->options, "utf8");
wrapflag = options_get_number(&wp->window->options, "wrap-search"); wrapflag = options_get_number(wp->window->options, "wrap-search");
searchlen = screen_write_strlen(utf8flag, "%s", searchstr); searchlen = screen_write_strlen(utf8flag, "%s", searchstr);
screen_init(&ss, searchlen, 1, 0); screen_init(&ss, searchlen, 1, 0);
@ -1168,7 +1168,7 @@ window_copy_write_line(struct window_pane *wp, struct screen_write_ctx *ctx,
{ {
struct window_copy_mode_data *data = wp->modedata; struct window_copy_mode_data *data = wp->modedata;
struct screen *s = &data->screen; struct screen *s = &data->screen;
struct options *oo = &wp->window->options; struct options *oo = wp->window->options;
struct grid_cell gc; struct grid_cell gc;
char hdr[512]; char hdr[512];
size_t last, xoff = 0, size = 0, limit; size_t last, xoff = 0, size = 0, limit;
@ -1301,7 +1301,7 @@ window_copy_update_selection(struct window_pane *wp, int may_redraw)
{ {
struct window_copy_mode_data *data = wp->modedata; struct window_copy_mode_data *data = wp->modedata;
struct screen *s = &data->screen; struct screen *s = &data->screen;
struct options *oo = &wp->window->options; struct options *oo = wp->window->options;
struct grid_cell gc; struct grid_cell gc;
u_int sx, sy, ty, cy; u_int sx, sy, ty, cy;
@ -1401,7 +1401,7 @@ window_copy_get_selection(struct window_pane *wp, size_t *len)
* bottom-right-most, regardless of copy direction. If it is vi, also * bottom-right-most, regardless of copy direction. If it is vi, also
* keep bottom-right-most character. * keep bottom-right-most character.
*/ */
keys = options_get_number(&wp->window->options, "mode-keys"); keys = options_get_number(wp->window->options, "mode-keys");
if (data->rectflag) { if (data->rectflag) {
/* /*
* Need to ignore the column with the cursor in it, which for * Need to ignore the column with the cursor in it, which for
@ -1460,7 +1460,7 @@ window_copy_copy_buffer(struct window_pane *wp, const char *bufname, void *buf,
{ {
struct screen_write_ctx ctx; struct screen_write_ctx ctx;
if (options_get_number(&global_options, "set-clipboard")) { if (options_get_number(global_options, "set-clipboard")) {
screen_write_start(&ctx, wp, NULL); screen_write_start(&ctx, wp, NULL);
screen_write_setselection(&ctx, buf, len); screen_write_setselection(&ctx, buf, len);
screen_write_stop(&ctx); screen_write_stop(&ctx);
@ -1523,7 +1523,7 @@ window_copy_append_selection(struct window_pane *wp, const char *bufname)
if (buf == NULL) if (buf == NULL)
return; return;
if (options_get_number(&global_options, "set-clipboard")) { if (options_get_number(global_options, "set-clipboard")) {
screen_write_start(&ctx, wp, NULL); screen_write_start(&ctx, wp, NULL);
screen_write_setselection(&ctx, buf, len); screen_write_setselection(&ctx, buf, len);
screen_write_stop(&ctx); screen_write_stop(&ctx);
@ -2074,7 +2074,7 @@ window_copy_cursor_next_word_end(struct window_pane *wp,
const char *separators) const char *separators)
{ {
struct window_copy_mode_data *data = wp->modedata; struct window_copy_mode_data *data = wp->modedata;
struct options *oo = &wp->window->options; struct options *oo = wp->window->options;
struct screen *back_s = data->backing; struct screen *back_s = data->backing;
u_int px, py, xx, yy; u_int px, py, xx, yy;
int keys, expected = 1; int keys, expected = 1;

View File

@ -302,7 +302,7 @@ window_create1(u_int sx, u_int sy)
w->sx = sx; w->sx = sx;
w->sy = sy; w->sy = sy;
options_init(&w->options, &global_w_options); w->options = options_create(global_w_options);
w->references = 0; w->references = 0;
@ -335,7 +335,7 @@ window_create(const char *name, int argc, char **argv, const char *path,
w->active = TAILQ_FIRST(&w->panes); w->active = TAILQ_FIRST(&w->panes);
if (name != NULL) { if (name != NULL) {
w->name = xstrdup(name); w->name = xstrdup(name);
options_set_number(&w->options, "automatic-rename", 0); options_set_number(w->options, "automatic-rename", 0);
} else } else
w->name = default_window_name(w); w->name = default_window_name(w);
@ -359,7 +359,7 @@ window_destroy(struct window *w)
if (event_initialized(&w->alerts_timer)) if (event_initialized(&w->alerts_timer))
evtimer_del(&w->alerts_timer); evtimer_del(&w->alerts_timer);
options_free(&w->options); options_free(w->options);
window_destroy_panes(w); window_destroy_panes(w);
@ -437,8 +437,8 @@ window_redraw_active_switch(struct window *w, struct window_pane *wp)
* active or inactive pane do not have a custom style, they will need * active or inactive pane do not have a custom style, they will need
* to be redrawn. * to be redrawn.
*/ */
agc = options_get_style(&w->options, "window-active-style"); agc = options_get_style(w->options, "window-active-style");
wgc = options_get_style(&w->options, "window-style"); wgc = options_get_style(w->options, "window-style");
if (style_equal(agc, wgc)) if (style_equal(agc, wgc))
return; return;
if (style_equal(&grid_default_cell, &w->active->colgc)) if (style_equal(&grid_default_cell, &w->active->colgc))
@ -598,7 +598,7 @@ window_pane_at_index(struct window *w, u_int idx)
struct window_pane *wp; struct window_pane *wp;
u_int n; u_int n;
n = options_get_number(&w->options, "pane-base-index"); n = options_get_number(w->options, "pane-base-index");
TAILQ_FOREACH(wp, &w->panes, entry) { TAILQ_FOREACH(wp, &w->panes, entry) {
if (n == idx) if (n == idx)
return (wp); return (wp);
@ -636,7 +636,7 @@ window_pane_index(struct window_pane *wp, u_int *i)
struct window_pane *wq; struct window_pane *wq;
struct window *w = wp->window; struct window *w = wp->window;
*i = options_get_number(&w->options, "pane-base-index"); *i = options_get_number(w->options, "pane-base-index");
TAILQ_FOREACH(wq, &w->panes, entry) { TAILQ_FOREACH(wq, &w->panes, entry) {
if (wp == wq) { if (wp == wq) {
return (0); return (0);
@ -1002,7 +1002,7 @@ window_pane_alternate_on(struct window_pane *wp, struct grid_cell *gc,
if (wp->saved_grid != NULL) if (wp->saved_grid != NULL)
return; return;
if (!options_get_number(&wp->window->options, "alternate-screen")) if (!options_get_number(wp->window->options, "alternate-screen"))
return; return;
sx = screen_size_x(s); sx = screen_size_x(s);
sy = screen_size_y(s); sy = screen_size_y(s);
@ -1032,7 +1032,7 @@ window_pane_alternate_off(struct window_pane *wp, struct grid_cell *gc,
if (wp->saved_grid == NULL) if (wp->saved_grid == NULL)
return; return;
if (!options_get_number(&wp->window->options, "alternate-screen")) if (!options_get_number(wp->window->options, "alternate-screen"))
return; return;
sx = screen_size_x(s); sx = screen_size_x(s);
sy = screen_size_y(s); sy = screen_size_y(s);
@ -1120,7 +1120,7 @@ window_pane_key(struct window_pane *wp, struct client *c, struct session *s,
if (KEYC_IS_MOUSE(key)) if (KEYC_IS_MOUSE(key))
return; return;
if (options_get_number(&wp->window->options, "synchronize-panes")) { if (options_get_number(wp->window->options, "synchronize-panes")) {
TAILQ_FOREACH(wp2, &wp->window->panes, entry) { TAILQ_FOREACH(wp2, &wp->window->panes, entry) {
if (wp2 == wp || wp2->mode != NULL) if (wp2 == wp || wp2->mode != NULL)
continue; continue;