aboutsummaryrefslogtreecommitdiff
path: root/format.c
diff options
context:
space:
mode:
authornicm <nicm>2016-10-16 19:36:37 +0000
committernicm <nicm>2016-10-16 19:36:37 +0000
commit3f35b5299fb2c08637aa12757185e5b82eeb3fc1 (patch)
tree5323b2851735c5b1052a4c2bae303f532bee191c /format.c
parent026ad08b56b4577beab6bad06b8a7a21602bca11 (diff)
downloadrtmux-3f35b5299fb2c08637aa12757185e5b82eeb3fc1.tar.gz
rtmux-3f35b5299fb2c08637aa12757185e5b82eeb3fc1.tar.bz2
rtmux-3f35b5299fb2c08637aa12757185e5b82eeb3fc1.zip
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.
Diffstat (limited to 'format.c')
-rw-r--r--format.c17
1 files changed, 15 insertions, 2 deletions
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);
}