diff options
Diffstat (limited to 'usr.bin/tmux/format.c')
-rw-r--r-- | usr.bin/tmux/format.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c index 8778f47e8dd..37dc1e39cf1 100644 --- a/usr.bin/tmux/format.c +++ b/usr.bin/tmux/format.c @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.236 2020/04/13 08:26:27 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.237 2020/04/13 10:59:58 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1108,8 +1108,8 @@ format_cb_mouse_line(struct format_tree *ft, struct format_entry *fe) fe->value = s; } -/* Merge a format tree. */ -static void +/* Merge one format tree into another. */ +void format_merge(struct format_tree *ft, struct format_tree *from) { struct format_entry *fe; @@ -1124,21 +1124,16 @@ format_merge(struct format_tree *ft, struct format_tree *from) static void format_create_add_item(struct format_tree *ft, struct cmdq_item *item) { + struct cmdq_shared *shared = cmdq_get_shared(item); struct mouse_event *m; struct window_pane *wp; u_int x, y; - if (item->cmd != NULL) { - format_add(ft, "command", "%s", - cmd_get_entry (item->cmd)->name); - } + cmdq_merge_formats(item, ft); - if (item->shared == NULL) + if (shared == NULL) return; - if (item->shared->formats != NULL) - format_merge(ft, item->shared->formats); - - m = &item->shared->mouse; + m = &shared->mouse; if (m->valid && ((wp = cmd_mouse_pane(m, NULL, NULL)) != NULL)) { format_add(ft, "mouse_pane", "%%%u", wp->id); if (cmd_mouse_at(wp, m, &x, &y, 0) == 0) { @@ -2425,7 +2420,7 @@ format_single(struct cmdq_item *item, const char *fmt, struct client *c, char *expanded; if (item != NULL) - ft = format_create(item->client, item, FORMAT_NONE, 0); + 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); @@ -2435,6 +2430,16 @@ format_single(struct cmdq_item *item, const char *fmt, struct client *c, return (expanded); } +/* Expand a single string using target. */ +char * +format_single_from_target(struct cmdq_item *item, const char *fmt, + struct client *c) +{ + struct cmd_find_state *target = cmdq_get_target(item); + + return (format_single(item, fmt, c, target->s, target->wl, target->wp)); +} + /* Set defaults for any of arguments that are not NULL. */ void format_defaults(struct format_tree *ft, struct client *c, struct session *s, |