1
0
mirror of https://github.com/tmux/tmux.git synced 2025-04-06 16:18:48 +00:00

Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam 2020-07-27 10:01:21 +01:00
commit 2fdd5fa507
9 changed files with 39 additions and 16 deletions

View File

@ -316,9 +316,9 @@ alerts_set_message(struct winlink *wl, const char *type, const char *option)
if (visual == VISUAL_OFF) if (visual == VISUAL_OFF)
continue; continue;
if (c->session->curw == wl) 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 { else {
status_message_set(c, 1, "%s in window %d", type, status_message_set(c, -1, 1, "%s in window %d", type,
wl->idx); wl->idx);
} }
} }

View File

@ -39,8 +39,8 @@ const struct cmd_entry cmd_display_message_entry = {
.name = "display-message", .name = "display-message",
.alias = "display", .alias = "display",
.args = { "ac:Ipt:F:v", 0, 1 }, .args = { "acd:Ipt:F:v", 0, 1 },
.usage = "[-aIpv] [-c target-client] [-F format] " .usage = "[-aIpv] [-c target-client] [-d delay] [-F format] "
CMD_TARGET_PANE_USAGE " [message]", CMD_TARGET_PANE_USAGE " [message]",
.target = { 't', CMD_FIND_PANE, 0 }, .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; struct window_pane *wp = target->wp;
const char *template; const char *template;
char *msg, *cause; char *msg, *cause;
int delay = -1;
struct format_tree *ft; struct format_tree *ft;
int flags; int flags;
@ -85,6 +86,15 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_ERROR); 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'); template = args_get(args, 'F');
if (args->argc != 0) if (args->argc != 0)
template = args->argv[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')) if (args_has(args, 'p'))
cmdq_print(item, "%s", msg); cmdq_print(item, "%s", msg);
else if (tc != NULL) else if (tc != NULL)
status_message_set(tc, 0, "%s", msg); status_message_set(tc, delay, 0, "%s", msg);
free(msg); free(msg);
format_free(ft); format_free(ft);

View File

@ -114,7 +114,7 @@ cmd_list_keys_print_notes(struct cmdq_item *item, struct args *args,
note = xstrdup(bd->note); note = xstrdup(bd->note);
tmp = utf8_padcstr(key, keywidth + 1); tmp = utf8_padcstr(key, keywidth + 1);
if (args_has(args, '1') && tc != NULL) 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 else
cmdq_print(item, "%s%s%s", prefix, tmp, note); cmdq_print(item, "%s%s%s", prefix, tmp, note);
free(tmp); free(tmp);

View File

@ -858,7 +858,7 @@ cmdq_error(struct cmdq_item *item, const char *fmt, ...)
c->retval = 1; c->retval = 1;
} else { } else {
*msg = toupper((u_char) *msg); *msg = toupper((u_char) *msg);
status_message_set(c, 1, "%s", msg); status_message_set(c, -1, 1, "%s", msg);
} }
free(msg); free(msg);

View File

@ -1176,7 +1176,7 @@ mode_tree_run_command(struct client *c, struct cmd_find_state *fs,
if (status == CMD_PARSE_ERROR) { if (status == CMD_PARSE_ERROR) {
if (c != NULL) { if (c != NULL) {
*error = toupper((u_char)*error); *error = toupper((u_char)*error);
status_message_set(c, 1, "%s", error); status_message_set(c, -1, 1, "%s", error);
} }
free(error); free(error);
} }

View File

@ -423,11 +423,11 @@ status_redraw(struct client *c)
/* Set a status line message. */ /* Set a status line message. */
void 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; struct timeval tv;
va_list ap; va_list ap;
int delay;
status_message_clear(c); status_message_clear(c);
status_push_screen(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); 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) { if (delay > 0) {
tv.tv_sec = delay / 1000; tv.tv_sec = delay / 1000;
tv.tv_usec = (delay % 1000) * 1000L; 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)) if (event_initialized(&c->message_timer))
evtimer_del(&c->message_timer); evtimer_del(&c->message_timer);
evtimer_set(&c->message_timer, status_message_callback, c); evtimer_set(&c->message_timer, status_message_callback, c);
evtimer_add(&c->message_timer, &tv); evtimer_add(&c->message_timer, &tv);
} }

10
tmux.1
View File

@ -5378,6 +5378,7 @@ The following keys are also available:
.It Xo Ic display-message .It Xo Ic display-message
.Op Fl aIpv .Op Fl aIpv
.Op Fl c Ar target-client .Op Fl c Ar target-client
.Op Fl d Ar delay
.Op Fl t Ar target-pane .Op Fl t Ar target-pane
.Op Ar message .Op Ar message
.Xc .Xc
@ -5387,7 +5388,14 @@ If
.Fl p .Fl p
is given, the output is printed to stdout, otherwise it is displayed in the is given, the output is printed to stdout, otherwise it is displayed in the
.Ar target-client .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 The format of
.Ar message .Ar message
is described in the is described in the

3
tmux.h
View File

@ -2452,8 +2452,7 @@ struct style_range *status_get_range(struct client *, u_int, u_int);
void status_init(struct client *); void status_init(struct client *);
void status_free(struct client *); void status_free(struct client *);
int status_redraw(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 *); void status_message_clear(struct client *);
int status_message_redraw(struct client *); int status_message_redraw(struct client *);
void status_prompt_set(struct client *, struct cmd_find_state *, void status_prompt_set(struct client *, struct cmd_find_state *,

View File

@ -1003,7 +1003,7 @@ window_customize_set_option_callback(struct client *c, void *itemdata,
fail: fail:
*cause = toupper((u_char)*cause); *cause = toupper((u_char)*cause);
status_message_set(c, 1, "%s", cause); status_message_set(c, -1, 1, "%s", cause);
free(cause); free(cause);
return (0); return (0);
} }
@ -1209,7 +1209,7 @@ window_customize_set_command_callback(struct client *c, void *itemdata,
fail: fail:
*error = toupper((u_char)*error); *error = toupper((u_char)*error);
status_message_set(c, 1, "%s", error); status_message_set(c, -1, 1, "%s", error);
free(error); free(error);
return (0); return (0);
} }