summaryrefslogtreecommitdiffstats
path: root/cmd-display-message.c
diff options
context:
space:
mode:
authornicm <nicm>2020-04-13 20:51:57 +0000
committernicm <nicm>2020-04-13 20:51:57 +0000
commit3f7f9a0e20522c73e33480673496240f1bac724b (patch)
treec0ec19a026014bfd6981622ecd9ee2783344ef25 /cmd-display-message.c
parent187277eaadc4a675659bf7ede88f50bfe6cc7be9 (diff)
Make client -c and -t handling common in cmd-queue.c and try to be
clearer about whether the client is the target client (must have a session) or not.
Diffstat (limited to 'cmd-display-message.c')
-rw-r--r--cmd-display-message.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/cmd-display-message.c b/cmd-display-message.c
index 8fb09f20..4e69f03a 100644
--- a/cmd-display-message.c
+++ b/cmd-display-message.c
@@ -45,7 +45,7 @@ const struct cmd_entry cmd_display_message_entry = {
.target = { 't', CMD_FIND_PANE, 0 },
- .flags = CMD_AFTERHOOK,
+ .flags = CMD_AFTERHOOK|CMD_CLIENT_CFLAG|CMD_CLIENT_CANFAIL,
.exec = cmd_display_message_exec
};
@@ -62,7 +62,7 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item);
- struct client *c, *target_c;
+ struct client *tc = cmdq_get_target_client(item), *c;
struct session *s = target->s;
struct winlink *wl = target->wl;
struct window_pane *wp = target->wp;
@@ -97,17 +97,16 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
* formats too, assuming it matches the session. If it doesn't, use the
* best client for the session.
*/
- c = cmd_find_client(item, args_get(args, 'c'), 1);
- if (c != NULL && c->session == s)
- target_c = c;
+ if (tc != NULL && tc->session == s)
+ c = tc;
else
- target_c = cmd_find_best_client(s);
+ c = cmd_find_best_client(s);
if (args_has(args, 'v'))
flags = FORMAT_VERBOSE;
else
flags = 0;
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, flags);
- format_defaults(ft, target_c, s, wl, wp);
+ format_defaults(ft, c, s, wl, wp);
if (args_has(args, 'a')) {
format_each(ft, cmd_display_message_each, item);
@@ -117,8 +116,8 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
msg = format_expand_time(ft, template);
if (args_has(args, 'p'))
cmdq_print(item, "%s", msg);
- else if (c != NULL)
- status_message_set(c, "%s", msg);
+ else if (tc != NULL)
+ status_message_set(tc, "%s", msg);
free(msg);
format_free(ft);