mirror of
https://github.com/tmux/tmux.git
synced 2025-09-01 20:57:00 +00:00
Add a helper function for the most common format_create/defaults/expand
pattern.
This commit is contained in:
17
format.c
17
format.c
@ -500,7 +500,6 @@ format_merge(struct format_tree *ft, struct format_tree *from)
|
||||
if (fe->value != NULL)
|
||||
format_add(ft, fe->key, "%s", fe->value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Create a new tree. */
|
||||
@ -1061,6 +1060,22 @@ format_expand(struct format_tree *ft, const char *fmt)
|
||||
return (buf);
|
||||
}
|
||||
|
||||
/* Expand a single string. */
|
||||
char *
|
||||
format_single(struct cmdq_item *item, const char *fmt, struct client *c,
|
||||
struct session *s, struct winlink *wl, struct window_pane *wp)
|
||||
{
|
||||
struct format_tree *ft;
|
||||
char *expanded;
|
||||
|
||||
ft = format_create(item, FORMAT_NONE, 0);
|
||||
format_defaults(ft, c, s, wl, wp);
|
||||
|
||||
expanded = format_expand(ft, fmt);
|
||||
format_free(ft);
|
||||
return (expanded);
|
||||
}
|
||||
|
||||
/* Set defaults for any of arguments that are not NULL. */
|
||||
void
|
||||
format_defaults(struct format_tree *ft, struct client *c, struct session *s,
|
||||
|
Reference in New Issue
Block a user