From 3f35b5299fb2c08637aa12757185e5b82eeb3fc1 Mon Sep 17 00:00:00 2001 From: nicm Date: Sun, 16 Oct 2016 19:36:37 +0000 Subject: Provide a way for hooks to tag formats onto the commands they fire so that the user can get at additional information - now used for the "hook" format, more to come. --- format.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'format.c') diff --git a/format.c b/format.c index a8c5fa51..1b933275 100644 --- a/format.c +++ b/format.c @@ -468,6 +468,19 @@ format_cb_pane_tabs(struct format_tree *ft, struct format_entry *fe) evbuffer_free(buffer); } +/* Merge a format tree. */ +static void +format_merge(struct format_tree *ft, struct format_tree *from) +{ + struct format_entry *fe; + + RB_FOREACH(fe, format_entry_tree, &from->tree) { + if (fe->value != NULL) + format_add(ft, fe->key, "%s", fe->value); + } + +} + /* Create a new tree. */ struct format_tree * format_create(struct cmdq_item *item, int flags) @@ -491,8 +504,8 @@ format_create(struct cmdq_item *item, int flags) if (item != NULL && item->cmd != NULL) format_add(ft, "command", "%s", item->cmd->entry->name); - if (item != NULL && item->hook != NULL) - format_add(ft, "hook", "%s", item->hook); + if (item != NULL && item->formats != NULL) + format_merge(ft, item->formats); return (ft); } -- cgit