From e92e99c5d3df3e89b62ccd60f1eaad8147605151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 15 Dec 2018 19:13:45 +0100 Subject: [PATCH] config: add 'default' config to map particle This value specifies the particle to use when the tag value does not match any of the values specified in the "values" dict. --- config.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/config.c b/config.c index 3d31239..2503dc7 100644 --- a/config.c +++ b/config.c @@ -178,6 +178,7 @@ particle_map_from_config(const struct yml_node *node, const struct font *parent_ { const struct yml_node *tag = yml_get_value(node, "tag"); const struct yml_node *values = yml_get_value(node, "values"); + const struct yml_node *def = yml_get_value(node, "default"); assert(yml_is_scalar(tag)); assert(yml_is_dict(values)); @@ -196,9 +197,13 @@ particle_map_from_config(const struct yml_node *node, const struct font *parent_ assert(particle_map[idx].particle != NULL); } + struct particle *default_particle = NULL; + if (def != NULL) + default_particle = particle_from_config(def, parent_font); + return particle_map_new( yml_value_as_string(tag), particle_map, yml_dict_length(values), - NULL, 0, 0); + default_particle, 0, 0); } static struct particle *