summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/cmd-set-option.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2015-12-13 14:32:38 +0000
committernicm <nicm@openbsd.org>2015-12-13 14:32:38 +0000
commit3447b427c1ffcf379e7fc14b9e25cce4fa75a963 (patch)
tree4470a122c84b0cc4457651c553dc0f60b4b9a3b0 /usr.bin/tmux/cmd-set-option.c
parentless macro; (diff)
downloadwireguard-openbsd-3447b427c1ffcf379e7fc14b9e25cce4fa75a963.tar.xz
wireguard-openbsd-3447b427c1ffcf379e7fc14b9e25cce4fa75a963.zip
Instead of every command resolving the target (-t or -s) itself, prepare
the state (client, session, winlink, pane) for it it before entering the command. Each command provides some flags that tell the prepare step what it is expecting. This is a requirement for having hooks on commands (for example, if you hook "select-window -t1:2", the hook command should to operate on window 1:2 not whatever it thinks is the current window), and should allow some other target improvements. The old cmd_find_* functions remain for the moment but that layer will be dropped later. Joint work with Thomas Adam.
Diffstat (limited to 'usr.bin/tmux/cmd-set-option.c')
-rw-r--r--usr.bin/tmux/cmd-set-option.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/usr.bin/tmux/cmd-set-option.c b/usr.bin/tmux/cmd-set-option.c
index d95eae96dae..0425887467a 100644
--- a/usr.bin/tmux/cmd-set-option.c
+++ b/usr.bin/tmux/cmd-set-option.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-set-option.c,v 1.89 2015/12/12 18:32:24 nicm Exp $ */
+/* $OpenBSD: cmd-set-option.c,v 1.90 2015/12/13 14:32:38 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -67,8 +67,8 @@ struct options_entry *cmd_set_option_style(struct cmd *, struct cmd_q *,
const struct cmd_entry cmd_set_option_entry = {
"set-option", "set",
"agoqst:uw", 1, 2,
- "[-agosquw] [-t target-session|target-window] option [value]",
- 0,
+ "[-agosquw] [-t target-window] option [value]",
+ CMD_WINDOW_T|CMD_CANFAIL,
cmd_set_option_exec
};
@@ -76,7 +76,7 @@ const struct cmd_entry cmd_set_window_option_entry = {
"set-window-option", "setw",
"agoqt:u", 1, 2,
"[-agoqu] " CMD_TARGET_WINDOW_USAGE " option [value]",
- 0,
+ CMD_WINDOW_T|CMD_CANFAIL,
cmd_set_option_exec
};
@@ -84,12 +84,12 @@ enum cmd_retval
cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
{
struct args *args = self->args;
- const struct options_table_entry *oe;
- struct session *s;
- struct winlink *wl;
+ struct session *s = cmdq->state.tflag.s;
+ struct winlink *wl = cmdq->state.tflag.wl;
+ struct window *w;
struct client *c;
+ const struct options_table_entry *oe;
struct options *oo;
- struct window *w;
const char *optstr, *valstr;
/* Get the option name and value. */
@@ -131,7 +131,6 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
if (args_has(self->args, 'g'))
oo = global_w_options;
else {
- wl = cmd_find_window(cmdq, args_get(args, 't'), NULL);
if (wl == NULL) {
cmdq_error(cmdq,
"couldn't set '%s'%s", optstr,
@@ -145,7 +144,6 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
if (args_has(self->args, 'g'))
oo = global_s_options;
else {
- s = cmd_find_session(cmdq, args_get(args, 't'), 0);
if (s == NULL) {
cmdq_error(cmdq,
"couldn't set '%s'%s", optstr,
@@ -209,8 +207,8 @@ cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, const char *optstr,
const char *valstr)
{
struct args *args = self->args;
- struct session *s;
- struct winlink *wl;
+ struct session *s = cmdq->state.tflag.s;
+ struct winlink *wl = cmdq->state.tflag.wl;
struct options *oo;
if (args_has(args, 's'))
@@ -219,21 +217,13 @@ cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, const char *optstr,
self->entry == &cmd_set_window_option_entry) {
if (args_has(self->args, 'g'))
oo = global_w_options;
- else {
- wl = cmd_find_window(cmdq, args_get(args, 't'), NULL);
- if (wl == NULL)
- return (CMD_RETURN_ERROR);
+ else
oo = wl->window->options;
- }
} else {
if (args_has(self->args, 'g'))
oo = global_s_options;
- else {
- s = cmd_find_session(cmdq, args_get(args, 't'), 0);
- if (s == NULL)
- return (CMD_RETURN_ERROR);
+ else
oo = s->options;
- }
}
if (args_has(args, 'u')) {