diff options
author | nicm <nicm> | 2015-12-13 14:32:38 +0000 |
---|---|---|
committer | nicm <nicm> | 2015-12-13 14:32:38 +0000 |
commit | 4a4daf13031673870341c68b990e20c314140118 (patch) | |
tree | 2457218fe3b49af2401cb78cde064b2a7ff62916 /cmd-set-option.c | |
parent | 5ed17e84faed0a7655ec1eb3de291b60839dcb12 (diff) | |
download | rtmux-4a4daf13031673870341c68b990e20c314140118.tar.gz rtmux-4a4daf13031673870341c68b990e20c314140118.tar.bz2 rtmux-4a4daf13031673870341c68b990e20c314140118.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 'cmd-set-option.c')
-rw-r--r-- | cmd-set-option.c | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/cmd-set-option.c b/cmd-set-option.c index daee62ac..86856fbb 100644 --- a/cmd-set-option.c +++ b/cmd-set-option.c @@ -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')) { |