From 70b2be3cf7cececd1c4114f21e80189360643a52 Mon Sep 17 00:00:00 2001 From: Olivier Perret Date: Sun, 21 Jan 2018 14:39:29 +0100 Subject: m_option: add print callback to color type This lets scripts query the value of 'background' and similar properties --- options/m_option.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'options/m_option.c') diff --git a/options/m_option.c b/options/m_option.c index 71744e1646..7ce137ba53 100644 --- a/options/m_option.c +++ b/options/m_option.c @@ -1830,10 +1830,17 @@ exit: return is_help ? M_OPT_EXIT : M_OPT_INVALID; } +static char *print_color(const m_option_t *opt, const void *val) +{ + const struct m_color *c = val; + return talloc_asprintf(NULL, "#%02X%02X%02X%02X", c->a, c->r, c->g, c->b); +} + const m_option_type_t m_option_type_color = { .name = "Color", .size = sizeof(struct m_color), .parse = parse_color, + .print = print_color, .copy = copy_opt, }; -- cgit v1.2.3