summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm>2021-04-12 09:36:12 +0000
committernicm <nicm>2021-04-12 09:36:12 +0000
commite6abe55134df1b9dc3b7dd7f3a65dff272a35bb7 (patch)
tree6c99cf6da3a6d22ecbb9b69dfc7696e5fb31c796
parentcd208c9d72df79a34024df6b8eb8f984613de8ef (diff)
Add a flag to disable keys to close a message, GitHub issue 2625.
-rw-r--r--alerts.c9
-rw-r--r--cmd-display-message.c10
-rw-r--r--cmd-list-keys.c7
-rw-r--r--cmd-queue.c2
-rw-r--r--cmd-run-shell.c2
-rw-r--r--mode-tree.c2
-rw-r--r--server-client.c6
-rw-r--r--status.c7
-rw-r--r--tmux.14
-rw-r--r--tmux.h3
-rw-r--r--window-customize.c4
11 files changed, 35 insertions, 21 deletions
diff --git a/alerts.c b/alerts.c
index 0f2eb179..b5ea0cf4 100644
--- a/alerts.c
+++ b/alerts.c
@@ -315,10 +315,11 @@ alerts_set_message(struct winlink *wl, const char *type, const char *option)
tty_putcode(&c->tty, TTYC_BEL);
if (visual == VISUAL_OFF)
continue;
- if (c->session->curw == wl)
- status_message_set(c, -1, 1, "%s in current window", type);
- else {
- status_message_set(c, -1, 1, "%s in window %d", type,
+ if (c->session->curw == wl) {
+ status_message_set(c, -1, 1, 0, "%s in current window",
+ type);
+ } else {
+ status_message_set(c, -1, 1, 0, "%s in window %d", type,
wl->idx);
}
}
diff --git a/cmd-display-message.c b/cmd-display-message.c
index 301c1a5e..0522d37f 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 = { "acd:Ipt:F:v", 0, 1 },
- .usage = "[-aIpv] [-c target-client] [-d delay] [-F format] "
+ .args = { "acd:INpt:F:v", 0, 1 },
+ .usage = "[-aINpv] [-c target-client] [-d delay] [-F format] "
CMD_TARGET_PANE_USAGE " [message]",
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
@@ -132,8 +132,10 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
cmdq_error(item, "%s", msg);
else if (args_has(args, 'p'))
cmdq_print(item, "%s", msg);
- else if (tc != NULL)
- status_message_set(tc, delay, 0, "%s", msg);
+ else if (tc != NULL) {
+ status_message_set(tc, delay, 0, args_has(args, 'N'), "%s",
+ msg);
+ }
free(msg);
format_free(ft);
diff --git a/cmd-list-keys.c b/cmd-list-keys.c
index dd82e57e..ca4bf752 100644
--- a/cmd-list-keys.c
+++ b/cmd-list-keys.c
@@ -113,9 +113,10 @@ cmd_list_keys_print_notes(struct cmdq_item *item, struct args *args,
else
note = xstrdup(bd->note);
tmp = utf8_padcstr(key, keywidth + 1);
- if (args_has(args, '1') && tc != NULL)
- status_message_set(tc, -1, 1, "%s%s%s", prefix, tmp, note);
- else
+ if (args_has(args, '1') && tc != NULL) {
+ status_message_set(tc, -1, 1, 0, "%s%s%s", prefix, tmp,
+ note);
+ } else
cmdq_print(item, "%s%s%s", prefix, tmp, note);
free(tmp);
free(note);
diff --git a/cmd-queue.c b/cmd-queue.c
index a0d80c34..54163919 100644
--- a/cmd-queue.c
+++ b/cmd-queue.c
@@ -862,7 +862,7 @@ cmdq_error(struct cmdq_item *item, const char *fmt, ...)
c->retval = 1;
} else {
*msg = toupper((u_char) *msg);
- status_message_set(c, -1, 1, "%s", msg);
+ status_message_set(c, -1, 1, 0, "%s", msg);
}
free(msg);
diff --git a/cmd-run-shell.c b/cmd-run-shell.c
index 73ed79f4..56d5f723 100644
--- a/cmd-run-shell.c
+++ b/cmd-run-shell.c
@@ -193,7 +193,7 @@ cmd_run_shell_timer(__unused int fd, __unused short events, void* arg)
if (status == CMD_PARSE_ERROR) {
if (cdata->item == NULL) {
*error = toupper((u_char)*error);
- status_message_set(c, -1, 1, "%s", error);
+ status_message_set(c, -1, 1, 0, "%s", error);
} else
cmdq_error(cdata->item, "%s", error);
free(error);
diff --git a/mode-tree.c b/mode-tree.c
index c0f85026..ca7f33a4 100644
--- a/mode-tree.c
+++ b/mode-tree.c
@@ -1204,7 +1204,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, 1, "%s", error);
+ status_message_set(c, -1, 1, 0, "%s", error);
}
free(error);
}
diff --git a/server-client.c b/server-client.c
index 219fdf3a..25d61376 100644
--- a/server-client.c
+++ b/server-client.c
@@ -1311,7 +1311,11 @@ server_client_handle_key(struct client *c, struct key_event *event)
* immediately rather than queued.
*/
if (~c->flags & CLIENT_READONLY) {
- status_message_clear(c);
+ if (c->message_string != NULL) {
+ if (c->message_ignore_keys)
+ return (0);
+ status_message_clear(c);
+ }
if (c->overlay_key != NULL) {
switch (c->overlay_key(c, event)) {
case 0:
diff --git a/status.c b/status.c
index 154d9452..f9786f4b 100644
--- a/status.c
+++ b/status.c
@@ -424,7 +424,7 @@ status_redraw(struct client *c)
/* Set a status line message. */
void
status_message_set(struct client *c, int delay, int ignore_styles,
- const char *fmt, ...)
+ int ignore_keys, const char *fmt, ...)
{
struct timeval tv;
va_list ap;
@@ -433,7 +433,6 @@ status_message_set(struct client *c, int delay, int ignore_styles,
status_push_screen(c);
va_start(ap, fmt);
- c->message_ignore_styles = ignore_styles;
xvasprintf(&c->message_string, fmt, ap);
va_end(ap);
@@ -456,6 +455,10 @@ status_message_set(struct client *c, int delay, int ignore_styles,
evtimer_add(&c->message_timer, &tv);
}
+ if (delay != 0)
+ c->message_ignore_keys = ignore_keys;
+ c->message_ignore_styles = ignore_styles;
+
c->tty.flags |= (TTY_NOCURSOR|TTY_FREEZE);
c->flags |= CLIENT_REDRAWSTATUS;
}
diff --git a/tmux.1 b/tmux.1
index 74cb5f00..ba82a101 100644
--- a/tmux.1
+++ b/tmux.1
@@ -5565,7 +5565,7 @@ The following keys are also available:
.It Li "q" Ta "Exit menu"
.El
.It Xo Ic display-message
-.Op Fl aIpv
+.Op Fl aINpv
.Op Fl c Ar target-client
.Op Fl d Ar delay
.Op Fl t Ar target-pane
@@ -5585,6 +5585,8 @@ If
is not given, the
.Ic message-time
option is used; a delay of zero waits for a key press.
+.Ql N
+ignores key presses and closes only after the delay expires.
The format of
.Ar message
is described in the
diff --git a/tmux.h b/tmux.h
index 9160ef92..fb2f35f9 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1687,6 +1687,7 @@ struct client {
uint64_t redraw_panes;
+ int message_ignore_keys;
int message_ignore_styles;
char *message_string;
struct event message_timer;
@@ -2490,7 +2491,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 status_message_set(struct client *, int, int, const char *, ...);
+void status_message_set(struct client *, int, 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 fce002fd..34a13f73 100644
--- a/window-customize.c
+++ b/window-customize.c
@@ -999,7 +999,7 @@ window_customize_set_option_callback(struct client *c, void *itemdata,
fail:
*cause = toupper((u_char)*cause);
- status_message_set(c, -1, 1, "%s", cause);
+ status_message_set(c, -1, 1, 0, "%s", cause);
free(cause);
return (0);
}
@@ -1205,7 +1205,7 @@ window_customize_set_command_callback(struct client *c, void *itemdata,
fail:
*error = toupper((u_char)*error);
- status_message_set(c, -1, 1, "%s", error);
+ status_message_set(c, -1, 1, 0, "%s", error);
free(error);
return (0);
}