aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--alerts.c4
-rw-r--r--cmd-display-message.c16
-rw-r--r--cmd-list-keys.c2
-rw-r--r--cmd-queue.c2
-rw-r--r--mode-tree.c2
-rw-r--r--status.c12
-rw-r--r--tmux.110
-rw-r--r--tmux.h3
-rw-r--r--window-customize.c4
9 files changed, 39 insertions, 16 deletions
diff --git a/alerts.c b/alerts.c
index 9675934a..38e88801 100644
--- a/alerts.c
+++ b/alerts.c
@@ -316,9 +316,9 @@ alerts_set_message(struct winlink *wl, const char *type, const char *option)
if (visual == VISUAL_OFF)
continue;
if (c->session->curw == wl)
- status_message_set(c, 1, "%s in current window", type);
+ status_message_set(c, -1, 1, "%s in current window", type);
else {
- status_message_set(c, 1, "%s in window %d", type,
+ status_message_set(c, -1, 1, "%s in window %d", type,
wl->idx);
}
}
diff --git a/cmd-display-message.c b/cmd-display-message.c
index 634f0a93..fc9c4851 100644
--- a/cmd-display-message.c
+++ b/cmd-display-message.c
@@ -39,8 +39,8 @@ const struct cmd_entry cmd_display_message_entry = {
.name = "display-message",
.alias = "display",
- .args = { "ac:Ipt:F:v", 0, 1 },
- .usage = "[-aIpv] [-c target-client] [-F format] "
+ .args = { "acd:Ipt:F:v", 0, 1 },
+ .usage = "[-aIpv] [-c target-client] [-d delay] [-F format] "
CMD_TARGET_PANE_USAGE " [message]",
.target = { 't', CMD_FIND_PANE, 0 },
@@ -68,6 +68,7 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
struct window_pane *wp = target->wp;
const char *template;
char *msg, *cause;
+ int delay = -1;
struct format_tree *ft;
int flags;
@@ -85,6 +86,15 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_ERROR);
}
+ if (args_has(args, 'd')) {
+ delay = args_strtonum(args, 'd', 0, UINT_MAX, &cause);
+ if (cause != NULL) {
+ cmdq_error(item, "delay %s", cause);
+ free(cause);
+ return (CMD_RETURN_ERROR);
+ }
+ }
+
template = args_get(args, 'F');
if (args->argc != 0)
template = args->argv[0];
@@ -117,7 +127,7 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
if (args_has(args, 'p'))
cmdq_print(item, "%s", msg);
else if (tc != NULL)
- status_message_set(tc, 0, "%s", msg);
+ status_message_set(tc, delay, 0, "%s", msg);
free(msg);
format_free(ft);
diff --git a/cmd-list-keys.c b/cmd-list-keys.c
index b3bdbd12..dd82e57e 100644
--- a/cmd-list-keys.c
+++ b/cmd-list-keys.c
@@ -114,7 +114,7 @@ cmd_list_keys_print_notes(struct cmdq_item *item, struct args *args,
note = xstrdup(bd->note);
tmp = utf8_padcstr(key, keywidth + 1);
if (args_has(args, '1') && tc != NULL)
- status_message_set(tc, 1, "%s%s%s", prefix, tmp, note);
+ status_message_set(tc, -1, 1, "%s%s%s", prefix, tmp, note);
else
cmdq_print(item, "%s%s%s", prefix, tmp, note);
free(tmp);
diff --git a/cmd-queue.c b/cmd-queue.c
index 693f7d90..36f1c9be 100644
--- a/cmd-queue.c
+++ b/cmd-queue.c
@@ -858,7 +858,7 @@ cmdq_error(struct cmdq_item *item, const char *fmt, ...)
c->retval = 1;
} else {
*msg = toupper((u_char) *msg);
- status_message_set(c, 1, "%s", msg);
+ status_message_set(c, -1, 1, "%s", msg);
}
free(msg);
diff --git a/mode-tree.c b/mode-tree.c
index c4b776f9..a47c0c06 100644
--- a/mode-tree.c
+++ b/mode-tree.c
@@ -1176,7 +1176,7 @@ mode_tree_run_command(struct client *c, struct cmd_find_state *fs,
if (status == CMD_PARSE_ERROR) {
if (c != NULL) {
*error = toupper((u_char)*error);
- status_message_set(c, 1, "%s", error);
+ status_message_set(c, -1, 1, "%s", error);
}
free(error);
}
diff --git a/status.c b/status.c
index 7313d2a0..668c0a3b 100644
--- a/status.c
+++ b/status.c
@@ -423,11 +423,11 @@ status_redraw(struct client *c)
/* Set a status line message. */
void
-status_message_set(struct client *c, int ignore_styles, const char *fmt, ...)
+status_message_set(struct client *c, int delay, int ignore_styles,
+ const char *fmt, ...)
{
struct timeval tv;
va_list ap;
- int delay;
status_message_clear(c);
status_push_screen(c);
@@ -439,7 +439,12 @@ status_message_set(struct client *c, int ignore_styles, const char *fmt, ...)
server_add_message("%s message: %s", c->name, c->message_string);
- delay = options_get_number(c->session->options, "display-time");
+ /*
+ * With delay -1, the display-time option is used; zero means wait for
+ * key press; more than zero is the actual delay time in milliseconds.
+ */
+ if (delay == -1)
+ delay = options_get_number(c->session->options, "display-time");
if (delay > 0) {
tv.tv_sec = delay / 1000;
tv.tv_usec = (delay % 1000) * 1000L;
@@ -447,6 +452,7 @@ status_message_set(struct client *c, int ignore_styles, const char *fmt, ...)
if (event_initialized(&c->message_timer))
evtimer_del(&c->message_timer);
evtimer_set(&c->message_timer, status_message_callback, c);
+
evtimer_add(&c->message_timer, &tv);
}
diff --git a/tmux.1 b/tmux.1
index 77cb3c56..cd20c056 100644
--- a/tmux.1
+++ b/tmux.1
@@ -5378,6 +5378,7 @@ The following keys are also available:
.It Xo Ic display-message
.Op Fl aIpv
.Op Fl c Ar target-client
+.Op Fl d Ar delay
.Op Fl t Ar target-pane
.Op Ar message
.Xc
@@ -5387,7 +5388,14 @@ If
.Fl p
is given, the output is printed to stdout, otherwise it is displayed in the
.Ar target-client
-status line.
+status line for up to
+.Ar delay
+milliseconds.
+If
+.Ar delay
+is not given, the
+.Ic message-time
+option is used; a delay of zero waits for a key press.
The format of
.Ar message
is described in the
diff --git a/tmux.h b/tmux.h
index a6749e99..daba4b25 100644
--- a/tmux.h
+++ b/tmux.h
@@ -2450,8 +2450,7 @@ struct style_range *status_get_range(struct client *, u_int, u_int);
void status_init(struct client *);
void status_free(struct client *);
int status_redraw(struct client *);
-void printflike(3, 4) status_message_set(struct client *, int, const char *,
- ...);
+void status_message_set(struct client *, int, int, const char *, ...);
void status_message_clear(struct client *);
int status_message_redraw(struct client *);
void status_prompt_set(struct client *, struct cmd_find_state *,
diff --git a/window-customize.c b/window-customize.c
index ecafc776..c8606245 100644
--- a/window-customize.c
+++ b/window-customize.c
@@ -1003,7 +1003,7 @@ window_customize_set_option_callback(struct client *c, void *itemdata,
fail:
*cause = toupper((u_char)*cause);
- status_message_set(c, 1, "%s", cause);
+ status_message_set(c, -1, 1, "%s", cause);
free(cause);
return (0);
}
@@ -1209,7 +1209,7 @@ window_customize_set_command_callback(struct client *c, void *itemdata,
fail:
*error = toupper((u_char)*error);
- status_message_set(c, 1, "%s", error);
+ status_message_set(c, -1, 1, "%s", error);
free(error);
return (0);
}