Rename the global options variables to be shorter and to make session options

clear. No functional change, getting this out of the way to make later options
changes easier.
This commit is contained in:
Nicholas Marriott 2009-07-07 19:49:19 +00:00
parent 474fdebb7a
commit 923ccfa2e8
10 changed files with 67 additions and 70 deletions

View File

@ -137,9 +137,9 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
cmd = data->cmd;
if (cmd == NULL)
cmd = options_get_string(&global_options, "default-command");
cmd = options_get_string(&global_s_options, "default-command");
if (c == NULL || c->cwd == NULL)
cwd = options_get_string(&global_options, "default-path");
cwd = options_get_string(&global_s_options, "default-path");
else
cwd = c->cwd;
@ -150,7 +150,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
sy = c->tty.sy;
}
if (options_get_number(&global_options, "status")) {
if (options_get_number(&global_s_options, "status")) {
if (sy == 0)
sy = 1;
else

View File

@ -87,7 +87,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
u_int i;
if (data->flags & CMD_GFLAG)
oo = &global_options;
oo = &global_s_options;
else {
if ((s = cmd_find_session(ctx, data->target)) == NULL)
return (-1);

View File

@ -82,7 +82,7 @@ cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx)
u_int i;
if (data->flags & CMD_GFLAG)
oo = &global_window_options;
oo = &global_w_options;
else {
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
return (-1);

View File

@ -54,7 +54,7 @@ cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx)
long long vn;
if (data->flags & CMD_GFLAG)
oo = &global_options;
oo = &global_s_options;
else {
if ((s = cmd_find_session(ctx, data->target)) == NULL)
return (-1);

View File

@ -54,7 +54,7 @@ cmd_show_window_options_exec(struct cmd *self, struct cmd_ctx *ctx)
long long vn;
if (data->flags & CMD_GFLAG)
oo = &global_window_options;
oo = &global_w_options;
else {
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
return (-1);

View File

@ -373,8 +373,8 @@ server_main(int srv_fd)
unlink(socket_path);
xfree(socket_path);
options_free(&global_options);
options_free(&global_window_options);
options_free(&global_s_options);
options_free(&global_w_options);
if (server_password != NULL)
xfree(server_password);
@ -573,10 +573,8 @@ server_redraw_locked(struct client *c)
yy = c->tty.sy - 1;
if (xx == 0 || yy == 0)
return;
colour = options_get_number(
&global_window_options, "clock-mode-colour");
style = options_get_number(
&global_window_options, "clock-mode-style");
colour = options_get_number(&global_w_options, "clock-mode-colour");
style = options_get_number(&global_w_options, "clock-mode-style");
screen_init(&screen, xx, yy, 0);
@ -1062,7 +1060,7 @@ server_second_timers(void)
time_t t;
t = time(NULL);
xtimeout = options_get_number(&global_options, "lock-after-time");
xtimeout = options_get_number(&global_s_options, "lock-after-time");
if (xtimeout > 0 && t > server_activity + xtimeout)
server_lock();

View File

@ -127,7 +127,7 @@ session_create(const char *name,
RB_INIT(&s->windows);
SLIST_INIT(&s->alerts);
paste_init_stack(&s->buffers);
options_init(&s->options, &global_options);
options_init(&s->options, &global_s_options);
s->sx = sx;
s->sy = sy;

103
tmux.c
View File

@ -42,8 +42,8 @@ volatile sig_atomic_t sigusr1;
volatile sig_atomic_t sigusr2;
char *cfg_file;
struct options global_options;
struct options global_window_options;
struct options global_s_options; /* session options */
struct options global_w_options; /* window options */
int server_locked;
char *server_password;
@ -267,54 +267,53 @@ main(int argc, char **argv)
log_open_tty(debug_level);
siginit();
options_init(&global_options, NULL);
options_set_number(&global_options, "bell-action", BELL_ANY);
options_set_number(&global_options, "buffer-limit", 9);
options_set_number(&global_options, "display-time", 750);
options_set_number(&global_options, "history-limit", 2000);
options_set_number(&global_options, "lock-after-time", 0);
options_set_number(&global_options, "message-attr", GRID_ATTR_REVERSE);
options_set_number(&global_options, "message-bg", 3);
options_set_number(&global_options, "message-fg", 0);
options_set_number(&global_options, "prefix", '\002');
options_set_number(&global_options, "repeat-time", 500);
options_set_number(&global_options, "set-remain-on-exit", 0);
options_set_number(&global_options, "set-titles", 0);
options_set_number(&global_options, "status", 1);
options_set_number(&global_options, "status-attr", GRID_ATTR_REVERSE);
options_set_number(&global_options, "status-bg", 2);
options_set_number(&global_options, "status-fg", 0);
options_set_number(&global_options, "status-interval", 15);
options_set_number(&global_options, "status-keys", MODEKEY_EMACS);
options_set_number(&global_options, "status-left-length", 10);
options_set_number(&global_options, "status-right-length", 40);
options_set_string(&global_options, "status-left", "[#S]");
options_init(&global_s_options, NULL);
options_set_number(&global_s_options, "bell-action", BELL_ANY);
options_set_number(&global_s_options, "buffer-limit", 9);
options_set_number(&global_s_options, "display-time", 750);
options_set_number(&global_s_options, "history-limit", 2000);
options_set_number(&global_s_options, "lock-after-time", 0);
options_set_number(&global_s_options, "message-attr", GRID_ATTR_REVERSE);
options_set_number(&global_s_options, "message-bg", 3);
options_set_number(&global_s_options, "message-fg", 0);
options_set_number(&global_s_options, "prefix", '\002');
options_set_number(&global_s_options, "repeat-time", 500);
options_set_number(&global_s_options, "set-remain-on-exit", 0);
options_set_number(&global_s_options, "set-titles", 0);
options_set_number(&global_s_options, "status", 1);
options_set_number(&global_s_options, "status-attr", GRID_ATTR_REVERSE);
options_set_number(&global_s_options, "status-bg", 2);
options_set_number(&global_s_options, "status-fg", 0);
options_set_number(&global_s_options, "status-interval", 15);
options_set_number(&global_s_options, "status-keys", MODEKEY_EMACS);
options_set_number(&global_s_options, "status-left-length", 10);
options_set_number(&global_s_options, "status-right-length", 40);
options_set_string(&global_s_options, "status-left", "[#S]");
options_set_string(
&global_options, "status-right", "\"#24T\" %%H:%%M %%d-%%b-%%y");
options_set_number(&global_options, "status-utf8", 0);
&global_s_options, "status-right", "\"#24T\" %%H:%%M %%d-%%b-%%y");
options_set_number(&global_s_options, "status-utf8", 0);
options_init(&global_window_options, NULL);
options_set_number(&global_window_options, "aggressive-resize", 0);
options_set_number(&global_window_options, "automatic-rename", 1);
options_set_number(&global_window_options, "clock-mode-colour", 4);
options_set_number(&global_window_options, "clock-mode-style", 1);
options_set_number(&global_window_options, "force-height", 0);
options_set_number(&global_window_options, "force-width", 0);
options_set_number(
&global_window_options, "mode-attr", GRID_ATTR_REVERSE);
options_set_number(&global_window_options, "main-pane-width", 81);
options_set_number(&global_window_options, "main-pane-height", 24);
options_set_number(&global_window_options, "mode-bg", 3);
options_set_number(&global_window_options, "mode-fg", 0);
options_set_number(&global_window_options, "mode-keys", MODEKEY_EMACS);
options_set_number(&global_window_options, "monitor-activity", 0);
options_set_string(&global_window_options, "monitor-content", "%s", "");
options_set_number(&global_window_options, "utf8", 0);
options_set_number(&global_window_options, "window-status-attr", 0);
options_set_number(&global_window_options, "window-status-bg", 8);
options_set_number(&global_window_options, "window-status-fg", 8);
options_set_number(&global_window_options, "xterm-keys", 0);
options_set_number(&global_window_options, "remain-on-exit", 0);
options_init(&global_w_options, NULL);
options_set_number(&global_w_options, "aggressive-resize", 0);
options_set_number(&global_w_options, "automatic-rename", 1);
options_set_number(&global_w_options, "clock-mode-colour", 4);
options_set_number(&global_w_options, "clock-mode-style", 1);
options_set_number(&global_w_options, "force-height", 0);
options_set_number(&global_w_options, "force-width", 0);
options_set_number(&global_w_options, "mode-attr", GRID_ATTR_REVERSE);
options_set_number(&global_w_options, "main-pane-width", 81);
options_set_number(&global_w_options, "main-pane-height", 24);
options_set_number(&global_w_options, "mode-bg", 3);
options_set_number(&global_w_options, "mode-fg", 0);
options_set_number(&global_w_options, "mode-keys", MODEKEY_EMACS);
options_set_number(&global_w_options, "monitor-activity", 0);
options_set_string(&global_w_options, "monitor-content", "%s", "");
options_set_number(&global_w_options, "utf8", 0);
options_set_number(&global_w_options, "window-status-attr", 0);
options_set_number(&global_w_options, "window-status-bg", 8);
options_set_number(&global_w_options, "window-status-fg", 8);
options_set_number(&global_w_options, "xterm-keys", 0);
options_set_number(&global_w_options, "remain-on-exit", 0);
if (!(flags & IDENTIFY_UTF8)) {
/*
@ -368,7 +367,7 @@ main(int argc, char **argv)
shell = _PATH_BSHELL;
}
options_set_string(
&global_options, "default-command", "exec %s -l", shell);
&global_s_options, "default-command", "exec %s -l", shell);
if (getcwd(cwd, sizeof cwd) == NULL) {
pw = getpwuid(getuid());
@ -377,7 +376,7 @@ main(int argc, char **argv)
else
strlcpy(cwd, "/", sizeof cwd);
}
options_set_string(&global_options, "default-path", "%s", cwd);
options_set_string(&global_s_options, "default-path", "%s", cwd);
if (unlock) {
if (argc != 0) {
@ -481,8 +480,8 @@ main(int argc, char **argv)
}
out:
options_free(&global_options);
options_free(&global_window_options);
options_free(&global_s_options);
options_free(&global_w_options);
close(cctx.srv_fd);
buffer_destroy(cctx.srv_in);

4
tmux.h
View File

@ -945,8 +945,8 @@ extern volatile sig_atomic_t sigcont;
extern volatile sig_atomic_t sigchld;
extern volatile sig_atomic_t sigusr1;
extern volatile sig_atomic_t sigusr2;
extern struct options global_options;
extern struct options global_window_options;
extern struct options global_s_options;
extern struct options global_w_options;
extern char *cfg_file;
extern int server_locked;
extern char *server_password;

View File

@ -204,7 +204,7 @@ window_create1(u_int sx, u_int sy)
w->sx = sx;
w->sy = sy;
options_init(&w->options, &global_window_options);
options_init(&w->options, &global_w_options);
for (i = 0; i < ARRAY_LENGTH(&windows); i++) {
if (ARRAY_ITEM(&windows, i) == NULL) {