Call format_defaults_window for panes as well.

This commit is contained in:
nicm 2020-05-16 14:55:38 +00:00
parent 5bf96c2f2c
commit 0487029fc5

View File

@ -2479,25 +2479,59 @@ format_single(struct cmdq_item *item, const char *fmt, struct client *c,
struct format_tree *ft;
char *expanded;
if (item != NULL)
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
else
ft = format_create(NULL, item, FORMAT_NONE, 0);
format_defaults(ft, c, s, wl, wp);
ft = format_create_defaults(item, c, s, wl, wp);
expanded = format_expand(ft, fmt);
format_free(ft);
return (expanded);
}
/* Expand a single string using state. */
char *
format_single_from_state(struct cmdq_item *item, const char *fmt,
struct client *c, struct cmd_find_state *fs)
{
return (format_single(item, fmt, c, fs->s, fs->wl, fs->wp));
}
/* Expand a single string using target. */
char *
format_single_from_target(struct cmdq_item *item, const char *fmt)
{
struct cmd_find_state *target = cmdq_get_target(item);
struct client *tc = cmdq_get_target_client(item);
struct client *tc = cmdq_get_target_client(item);
return (format_single(item, fmt, tc, target->s, target->wl, target->wp));
return (format_single_from_state(item, fmt, tc, cmdq_get_target(item)));
}
/* Create and add defaults. */
struct format_tree *
format_create_defaults(struct cmdq_item *item, struct client *c,
struct session *s, struct winlink *wl, struct window_pane *wp)
{
struct format_tree *ft;
if (item != NULL)
ft = format_create(cmdq_get_client(item), item, FORMAT_NONE, 0);
else
ft = format_create(NULL, item, FORMAT_NONE, 0);
format_defaults(ft, c, s, wl, wp);
return (ft);
}
/* Create and add defaults using state. */
struct format_tree *
format_create_from_state(struct cmdq_item *item, struct client *c,
struct cmd_find_state *fs)
{
return (format_create_defaults(item, c, fs->s, fs->wl, fs->wp));
}
/* Create and add defaults using target. */
struct format_tree *
format_create_from_target(struct cmdq_item *item)
{
struct client *tc = cmdq_get_target_client(item);
return (format_create_from_state(item, tc, cmdq_get_target(item)));
}
/* Set defaults for any of arguments that are not NULL. */
@ -2516,7 +2550,7 @@ format_defaults(struct format_tree *ft, struct client *c, struct session *s,
else
log_debug("%s: s=none", __func__);
if (wl != NULL)
log_debug("%s: wl=%u w=@%u", __func__, wl->idx, wl->window->id);
log_debug("%s: wl=%u", __func__, wl->idx);
else
log_debug("%s: wl=none", __func__);
if (wp != NULL)
@ -2624,6 +2658,8 @@ format_defaults_client(struct format_tree *ft, struct client *c)
format_add(ft, "client_termname", "%s", c->term_name);
format_add(ft, "client_termfeatures", "%s",
tty_get_features(c->term_features));
if (c->term_type != NULL)
format_add(ft, "client_termtype", "%s", c->term_type);
format_add_tv(ft, "client_created", &c->creation_time);
format_add_tv(ft, "client_activity", &c->activity_time);
@ -2688,11 +2724,9 @@ format_defaults_winlink(struct format_tree *ft, struct winlink *wl)
u_int ox, oy, sx, sy;
if (ft->w == NULL)
ft->w = wl->window;
format_defaults_window(ft, w);
ft->wl = wl;
format_defaults_window(ft, w);
if (c != NULL) {
flag = tty_window_offset(&c->tty, &ox, &oy, &sx, &sy);
format_add(ft, "window_bigger", "%d", flag);
@ -2752,7 +2786,7 @@ format_defaults_pane(struct format_tree *ft, struct window_pane *wp)
struct window_mode_entry *wme;
if (ft->w == NULL)
ft->w = w;
format_defaults_window(ft, w);
ft->wp = wp;
format_add(ft, "history_size", "%u", gd->hsize);