diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-12-03 17:44:03 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-12-03 17:44:03 +0000 |
commit | 27dfb0437a81ddba5c9430256d1aa212589ac499 (patch) | |
tree | 20a578259573d3acc0075276409a0a1396abd2bd /usr.bin/tmux/cmd-show-options.c | |
parent | 36248a1ec61b88fe6a01f270d58658df81e36f54 (diff) |
Eliminate duplicate code and ease the passage for server-wide options by adding
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.
Note: setw and showw are still there, but now aliases for set -w and show -w.
Diffstat (limited to 'usr.bin/tmux/cmd-show-options.c')
-rw-r--r-- | usr.bin/tmux/cmd-show-options.c | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/usr.bin/tmux/cmd-show-options.c b/usr.bin/tmux/cmd-show-options.c index f183a9ae51f..4d6eae0ec3e 100644 --- a/usr.bin/tmux/cmd-show-options.c +++ b/usr.bin/tmux/cmd-show-options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-show-options.c,v 1.7 2009/11/13 19:53:29 nicm Exp $ */ +/* $OpenBSD: cmd-show-options.c,v 1.8 2009/12/03 17:44:02 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -31,8 +31,8 @@ int cmd_show_options_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_show_options_entry = { "show-options", "show", - "[-g] " CMD_TARGET_SESSION_USAGE, - 0, "g", + "[-gw] [-t target-session|target-window]", + 0, "gw", cmd_target_init, cmd_target_parse, cmd_show_options_exec, @@ -43,25 +43,41 @@ const struct cmd_entry cmd_show_options_entry = { int cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx) { - struct cmd_target_data *data = self->data; + struct cmd_target_data *data = self->data; + const struct set_option_entry *table; struct session *s; + struct winlink *wl; struct options *oo; struct options_entry *o; const struct set_option_entry *entry; const char *optval; - if (cmd_check_flag(data->chflags, 'g')) - oo = &global_s_options; - else { - if ((s = cmd_find_session(ctx, data->target)) == NULL) - return (-1); - oo = &s->options; + if (cmd_check_flag(data->chflags, 'w')) { + table = set_window_option_table; + if (cmd_check_flag(data->chflags, 'g')) + oo = &global_w_options; + else { + wl = cmd_find_window(ctx, data->target, NULL); + if (wl == NULL) + return (-1); + oo = &wl->window->options; + } + } else { + table = set_session_option_table; + if (cmd_check_flag(data->chflags, 'g')) + oo = &global_s_options; + else { + s = cmd_find_session(ctx, data->target); + if (s == NULL) + return (-1); + oo = &s->options; + } } - for (entry = set_option_table; entry->name != NULL; entry++) { + for (entry = table; entry->name != NULL; entry++) { if ((o = options_find1(oo, entry->name)) == NULL) continue; - optval = set_option_print(entry, o); + optval = cmd_set_option_print(entry, o); ctx->print(ctx, "%s %s", entry->name, optval); } |