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.
This commit is contained in:
Daniel Eklöf 2018-12-15 19:13:45 +01:00
parent 40e6af2e2e
commit e92e99c5d3

View file

@ -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 *