diff options
author | 2015-12-13 14:32:38 +0000 | |
---|---|---|
committer | 2015-12-13 14:32:38 +0000 | |
commit | 3447b427c1ffcf379e7fc14b9e25cce4fa75a963 (patch) | |
tree | 4470a122c84b0cc4457651c553dc0f60b4b9a3b0 /usr.bin/tmux/cmd-display-message.c | |
parent | less macro; (diff) | |
download | wireguard-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-display-message.c')
-rw-r--r-- | usr.bin/tmux/cmd-display-message.c | 34 |
1 files changed, 6 insertions, 28 deletions
diff --git a/usr.bin/tmux/cmd-display-message.c b/usr.bin/tmux/cmd-display-message.c index a5858249a07..33009da7ded 100644 --- a/usr.bin/tmux/cmd-display-message.c +++ b/usr.bin/tmux/cmd-display-message.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-display-message.c,v 1.31 2015/12/11 12:27:36 nicm Exp $ */ +/* $OpenBSD: cmd-display-message.c,v 1.32 2015/12/13 14:32:38 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -39,7 +39,7 @@ const struct cmd_entry cmd_display_message_entry = { "c:pt:F:", 0, 1, "[-p] [-c target-client] [-F format] " CMD_TARGET_PANE_USAGE " [message]", - 0, + CMD_CLIENT_C|CMD_PANE_T, cmd_display_message_exec }; @@ -47,41 +47,19 @@ enum cmd_retval cmd_display_message_exec(struct cmd *self, struct cmd_q *cmdq) { struct args *args = self->args; - struct client *c; - struct session *s; - struct winlink *wl; - struct window_pane *wp; + struct client *c = cmdq->state.c; + struct session *s = cmdq->state.tflag.s; + struct winlink *wl = cmdq->state.tflag.wl; + struct window_pane *wp = cmdq->state.tflag.wp; const char *template; char *msg; struct format_tree *ft; - if (args_has(args, 't')) { - wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp); - if (wl == NULL) - return (CMD_RETURN_ERROR); - } else { - wl = cmd_find_pane(cmdq, NULL, &s, &wp); - if (wl == NULL) - return (CMD_RETURN_ERROR); - } - if (args_has(args, 'F') && args->argc != 0) { cmdq_error(cmdq, "only one of -F or argument must be given"); return (CMD_RETURN_ERROR); } - if (args_has(args, 'c')) { - c = cmd_find_client(cmdq, args_get(args, 'c'), 0); - if (c == NULL) - return (CMD_RETURN_ERROR); - } else { - c = cmd_find_client(cmdq, NULL, 1); - if (c == NULL && !args_has(self->args, 'p')) { - cmdq_error(cmdq, "no client available"); - return (CMD_RETURN_ERROR); - } - } - template = args_get(args, 'F'); if (args->argc != 0) template = args->argv[0]; |