=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/format.c,v retrieving revision 1.236 retrieving revision 1.237 diff -c -r1.236 -r1.237 *** src/usr.bin/tmux/format.c 2020/04/13 08:26:27 1.236 --- src/usr.bin/tmux/format.c 2020/04/13 10:59:58 1.237 *************** *** 1,4 **** ! /* $OpenBSD: format.c,v 1.236 2020/04/13 08:26:27 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: format.c,v 1.237 2020/04/13 10:59:58 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott *************** *** 1108,1115 **** fe->value = s; } ! /* Merge a format tree. */ ! static void format_merge(struct format_tree *ft, struct format_tree *from) { struct format_entry *fe; --- 1108,1115 ---- fe->value = s; } ! /* Merge one format tree into another. */ ! void format_merge(struct format_tree *ft, struct format_tree *from) { struct format_entry *fe; *************** *** 1124,1144 **** static void format_create_add_item(struct format_tree *ft, struct cmdq_item *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); ! } ! if (item->shared == NULL) return; ! if (item->shared->formats != NULL) ! format_merge(ft, item->shared->formats); ! ! m = &item->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) { --- 1124,1139 ---- 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; ! cmdq_merge_formats(item, ft); ! if (shared == NULL) return; ! 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,2431 **** char *expanded; if (item != NULL) ! ft = format_create(item->client, item, FORMAT_NONE, 0); else ft = format_create(NULL, item, FORMAT_NONE, 0); format_defaults(ft, c, s, wl, wp); --- 2420,2426 ---- 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); *************** *** 2433,2438 **** --- 2428,2443 ---- expanded = format_expand(ft, fmt); format_free(ft); 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. */