diff --git a/alerts.c b/alerts.c index d3c5df050..81c41fa6a 100644 --- a/alerts.c +++ b/alerts.c @@ -315,11 +315,11 @@ 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, 1, 0, "%s in current window", - type); + status_message_set(c, -1, 1, 0, 0, + "%s in current window", type); } else { - status_message_set(c, -1, 1, 0, "%s in window %d", type, - wl->idx); + status_message_set(c, -1, 1, 0, 0, + "%s in window %d", type, wl->idx); } } } diff --git a/cmd-display-message.c b/cmd-display-message.c index 512509f05..9ba6d13eb 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:d:lINpt:F:v", 0, 1, NULL }, - .usage = "[-aIlNpv] [-c target-client] [-d delay] [-F format] " + .args = { "aCc:d:lINpt:F:v", 0, 1, NULL }, + .usage = "[-aCIlNpv] [-c target-client] [-d delay] [-F format] " CMD_TARGET_PANE_USAGE " [message]", .target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL }, @@ -69,6 +69,7 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item) const char *template; char *msg, *cause; int delay = -1, flags, Nflag = args_has(args, 'N'); + int Cflag = args_has(args, 'C'); struct format_tree *ft; u_int count = args_count(args); struct evbuffer *evb; @@ -150,7 +151,7 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item) server_client_print(tc, 0, evb); evbuffer_free(evb); } else if (tc != NULL) - status_message_set(tc, delay, 0, Nflag, "%s", msg); + status_message_set(tc, delay, 0, Nflag, Cflag, "%s", msg); free(msg); format_free(ft); diff --git a/cmd-if-shell.c b/cmd-if-shell.c index 205a8ce10..815189392 100644 --- a/cmd-if-shell.c +++ b/cmd-if-shell.c @@ -157,7 +157,7 @@ cmd_if_shell_callback(struct job *job) if (cmdlist == NULL) { if (cdata->item == NULL) { *error = toupper((u_char)*error); - status_message_set(c, -1, 1, 0, "%s", error); + status_message_set(c, -1, 1, 0, 0, "%s", error); } else cmdq_error(cdata->item, "%s", error); free(error); diff --git a/cmd-list-keys.c b/cmd-list-keys.c index b5050f090..ddfc0e0cd 100644 --- a/cmd-list-keys.c +++ b/cmd-list-keys.c @@ -114,8 +114,8 @@ 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, 1, 0, "%s%s%s", prefix, tmp, - note); + status_message_set(tc, -1, 1, 0, 0, "%s%s%s", prefix, + tmp, note); } else cmdq_print(item, "%s%s%s", prefix, tmp, note); free(tmp); @@ -298,8 +298,8 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item) free(cp); if (args_has(args, '1') && tc != NULL) { - status_message_set(tc, -1, 1, 0, "bind-key %s", - tmp); + status_message_set(tc, -1, 1, 0, 0, + "bind-key %s", tmp); } else cmdq_print(item, "bind-key %s", tmp); free(key); diff --git a/cmd-queue.c b/cmd-queue.c index 26c7ec32b..2a221516d 100644 --- a/cmd-queue.c +++ b/cmd-queue.c @@ -892,7 +892,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, 0, "%s", msg); + status_message_set(c, -1, 1, 0, 0, "%s", msg); } free(msg); diff --git a/cmd-run-shell.c b/cmd-run-shell.c index 9e224c4ec..be4c7cac2 100644 --- a/cmd-run-shell.c +++ b/cmd-run-shell.c @@ -204,7 +204,7 @@ cmd_run_shell_timer(__unused int fd, __unused short events, void* arg) if (cmdlist == NULL) { if (cdata->item == NULL) { *error = toupper((u_char)*error); - status_message_set(c, -1, 1, 0, "%s", error); + status_message_set(c, -1, 1, 0, 0, "%s", error); } else cmdq_error(cdata->item, "%s", error); free(error); diff --git a/mode-tree.c b/mode-tree.c index e1170a3dc..24cbea04d 100644 --- a/mode-tree.c +++ b/mode-tree.c @@ -66,6 +66,7 @@ struct mode_tree_data { u_int line_size; u_int depth; + u_int maxdepth; u_int width; u_int height; @@ -196,6 +197,8 @@ mode_tree_build_lines(struct mode_tree_data *mtd, int flat = 1; mtd->depth = depth; + if (depth > mtd->maxdepth) + mtd->maxdepth = depth; TAILQ_FOREACH(mti, mtl, entry) { mtd->line_list = xreallocarray(mtd->line_list, mtd->line_size + 1, sizeof *mtd->line_list); @@ -528,6 +531,7 @@ mode_tree_build(struct mode_tree_data *mtd) TAILQ_INIT(&mtd->saved); mode_tree_clear_lines(mtd); + mtd->maxdepth = 0; mode_tree_build_lines(mtd, &mtd->children, 0); if (mtd->line_list != NULL && tag == UINT64_MAX) @@ -658,7 +662,7 @@ mode_tree_draw(struct mode_tree_data *mtd) char *text, *start, *key; const char *tag, *symbol; size_t size, n; - int keylen, pad; + int keylen, pad, namelen[mtd->maxdepth + 1]; if (mtd->line_size == 0) return; @@ -682,6 +686,15 @@ mode_tree_draw(struct mode_tree_data *mtd) keylen = mti->keylen + 3; } + for (i = 0; i < mtd->maxdepth + 1; i++) + namelen[i] = 0; + for (i = 0; i < mtd->line_size; i++) { + line = &mtd->line_list[i]; + mti = line->item; + if ((int)strlen(mti->name) > namelen[line->depth]) + namelen[line->depth] = strlen(mti->name); + } + for (i = 0; i < mtd->line_size; i++) { if (i < mtd->offset) continue; @@ -731,8 +744,9 @@ mode_tree_draw(struct mode_tree_data *mtd) tag = "*"; else tag = ""; - xasprintf(&text, "%-*s%s%s%s%s", keylen, key, start, mti->name, - tag, (mti->text != NULL) ? ": " : "" ); + xasprintf(&text, "%-*s%s%*s%s%s", keylen, key, start, + namelen[line->depth], mti->name, tag, + (mti->text != NULL) ? ": " : "" ); width = utf8_cstrwidth(text); if (width > w) width = w; @@ -1297,7 +1311,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, 0, "%s", error); + status_message_set(c, -1, 1, 0, 0, "%s", error); } free(error); } diff --git a/status.c b/status.c index 32833f8c9..745ee3aea 100644 --- a/status.c +++ b/status.c @@ -470,7 +470,7 @@ status_redraw(struct client *c) /* Set a status line message. */ void status_message_set(struct client *c, int delay, int ignore_styles, - int ignore_keys, const char *fmt, ...) + int ignore_keys, int no_freeze, const char *fmt, ...) { struct timeval tv; va_list ap; @@ -514,7 +514,9 @@ status_message_set(struct client *c, int delay, int ignore_styles, c->message_ignore_keys = ignore_keys; c->message_ignore_styles = ignore_styles; - c->tty.flags |= (TTY_NOCURSOR|TTY_FREEZE); + if (!no_freeze) + c->tty.flags |= TTY_FREEZE; + c->tty.flags |= TTY_NOCURSOR; c->flags |= CLIENT_REDRAWSTATUS; } diff --git a/tmux.1 b/tmux.1 index c2cc679a0..74afcce2a 100644 --- a/tmux.1 +++ b/tmux.1 @@ -6744,7 +6744,7 @@ The following keys are available in menus: .El .Tg display .It Xo Ic display-message -.Op Fl aIlNpv +.Op Fl aCIlNpv .Op Fl c Ar target-client .Op Fl d Ar delay .Op Fl t Ar target-pane @@ -6767,6 +6767,9 @@ option is used; a delay of zero waits for a key press. .Ql N ignores key presses and closes only after the delay expires. If +.Fl C +given, the pane will continue to be updated while the message is displayed. +If .Fl l is given, .Ar message diff --git a/tmux.h b/tmux.h index d448faa38..84028cb05 100644 --- a/tmux.h +++ b/tmux.h @@ -2891,7 +2891,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(5, 6) status_message_set(struct client *, int, int, int, +void printflike(6, 7) status_message_set(struct client *, int, int, int, int, const char *, ...); void status_message_clear(struct client *); int status_message_redraw(struct client *); diff --git a/window-customize.c b/window-customize.c index 387254e0c..c49e57af9 100644 --- a/window-customize.c +++ b/window-customize.c @@ -1000,7 +1000,7 @@ window_customize_set_option_callback(struct client *c, void *itemdata, fail: *cause = toupper((u_char)*cause); - status_message_set(c, -1, 1, 0, "%s", cause); + status_message_set(c, -1, 1, 0, 0, "%s", cause); free(cause); return (0); } @@ -1203,7 +1203,7 @@ window_customize_set_command_callback(struct client *c, void *itemdata, fail: *error = toupper((u_char)*error); - status_message_set(c, -1, 1, 0, "%s", error); + status_message_set(c, -1, 1, 0, 0, "%s", error); free(error); return (0); }