Skip to content

Commit

Permalink
Merge branch 'obsd-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasAdam committed Feb 10, 2025
2 parents ef68deb + 5d1a6ac commit ec119b2
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 24 deletions.
8 changes: 4 additions & 4 deletions alerts.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
7 changes: 4 additions & 3 deletions cmd-display-message.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion cmd-if-shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions cmd-list-keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion cmd-queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion cmd-run-shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
22 changes: 18 additions & 4 deletions mode-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ struct mode_tree_data {
u_int line_size;

u_int depth;
u_int maxdepth;

u_int width;
u_int height;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 4 additions & 2 deletions status.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
5 changes: 4 additions & 1 deletion tmux.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tmux.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down
4 changes: 2 additions & 2 deletions window-customize.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit ec119b2

Please sign in to comment.