diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2020-07-27 08:03:11 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2020-07-27 08:03:11 +0000 |
commit | e38aca5820a0330ce97cc34a3e22aac665b0d43b (patch) | |
tree | 56d33712c9b9eb7d6da4c1288de70b98914209c6 /usr.bin/tmux | |
parent | 66a496f79cdc9e673aecc4d5e99a5236d7b118c8 (diff) |
Add a -d option to display-message to set delay, from theonekeyg at
gmail dot com in GitHub issue 2322.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/alerts.c | 6 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-display-message.c | 18 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-list-keys.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-queue.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/mode-tree.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/status.c | 14 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 14 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 5 | ||||
-rw-r--r-- | usr.bin/tmux/window-customize.c | 6 |
9 files changed, 49 insertions, 26 deletions
diff --git a/usr.bin/tmux/alerts.c b/usr.bin/tmux/alerts.c index 98170ddc717..dc3240b1468 100644 --- a/usr.bin/tmux/alerts.c +++ b/usr.bin/tmux/alerts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: alerts.c,v 1.30 2020/05/16 15:54:20 nicm Exp $ */ +/* $OpenBSD: alerts.c,v 1.31 2020/07/27 08:03:10 nicm Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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/usr.bin/tmux/cmd-display-message.c b/usr.bin/tmux/cmd-display-message.c index bca113f3ef3..5a0b2850097 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.54 2020/05/16 15:54:20 nicm Exp $ */ +/* $OpenBSD: cmd-display-message.c,v 1.55 2020/07/27 08:03:10 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -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/usr.bin/tmux/cmd-list-keys.c b/usr.bin/tmux/cmd-list-keys.c index 410a1a45cea..d75b76c51fb 100644 --- a/usr.bin/tmux/cmd-list-keys.c +++ b/usr.bin/tmux/cmd-list-keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-list-keys.c,v 1.60 2020/07/06 07:27:39 nicm Exp $ */ +/* $OpenBSD: cmd-list-keys.c,v 1.61 2020/07/27 08:03:10 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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/usr.bin/tmux/cmd-queue.c b/usr.bin/tmux/cmd-queue.c index b139fa014a4..b955918b98a 100644 --- a/usr.bin/tmux/cmd-queue.c +++ b/usr.bin/tmux/cmd-queue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-queue.c,v 1.98 2020/06/01 09:43:01 nicm Exp $ */ +/* $OpenBSD: cmd-queue.c,v 1.99 2020/07/27 08:03:10 nicm Exp $ */ /* * Copyright (c) 2013 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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/usr.bin/tmux/mode-tree.c b/usr.bin/tmux/mode-tree.c index e3679ce3720..f696c05e2a0 100644 --- a/usr.bin/tmux/mode-tree.c +++ b/usr.bin/tmux/mode-tree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mode-tree.c,v 1.50 2020/06/16 08:18:34 nicm Exp $ */ +/* $OpenBSD: mode-tree.c,v 1.51 2020/07/27 08:03:10 nicm Exp $ */ /* * Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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/usr.bin/tmux/status.c b/usr.bin/tmux/status.c index f1e7a929df4..e23c612842c 100644 --- a/usr.bin/tmux/status.c +++ b/usr.bin/tmux/status.c @@ -1,4 +1,4 @@ -/* $OpenBSD: status.c,v 1.217 2020/06/11 10:56:19 nicm Exp $ */ +/* $OpenBSD: status.c,v 1.218 2020/07/27 08:03:10 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 4c11a7cffd7..fd5782a5d15 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.789 2020/07/13 07:04:17 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.790 2020/07/27 08:03:10 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: July 13 2020 $ +.Dd $Mdocdate: July 27 2020 $ .Dt TMUX 1 .Os .Sh NAME @@ -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/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 8d6c13a9e9c..3c2eaec3446 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.1074 2020/07/21 05:24:33 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.1075 2020/07/27 08:03:10 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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/usr.bin/tmux/window-customize.c b/usr.bin/tmux/window-customize.c index 51750e1489d..bdd2a40bb15 100644 --- a/usr.bin/tmux/window-customize.c +++ b/usr.bin/tmux/window-customize.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-customize.c,v 1.5 2020/07/23 14:17:56 nicm Exp $ */ +/* $OpenBSD: window-customize.c,v 1.6 2020/07/27 08:03:10 nicm Exp $ */ /* * Copyright (c) 2020 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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); } |