config: pass a struct with inheritable values

For now, font and foreground color
This commit is contained in:
Daniel Eklöf 2019-01-13 14:13:14 +01:00
parent 7776135454
commit 8dc278aaf2
20 changed files with 84 additions and 48 deletions

View file

@ -183,7 +183,8 @@ from_conf(const struct yml_node *node, struct particle *common)
it.node != NULL;
yml_list_next(&it), idx++)
{
parts[idx] = conf_to_particle(it.node, common->font);
parts[idx] = conf_to_particle(
it.node, (struct conf_inherit){common->font, common->foreground});
}
return particle_list_new(common, parts, count, left_spacing, right_spacing);

View file

@ -205,17 +205,22 @@ from_conf(const struct yml_node *node, struct particle *common)
struct particle_map particle_map[yml_dict_length(values)];
struct conf_inherit inherited = {
.font = common->font,
.foreground = common->foreground
};
size_t idx = 0;
for (struct yml_dict_iter it = yml_dict_iter(values);
it.key != NULL;
yml_dict_next(&it), idx++)
{
particle_map[idx].tag_value = yml_value_as_string(it.key);
particle_map[idx].particle = conf_to_particle(it.value, common->font);
particle_map[idx].particle = conf_to_particle(it.value, inherited);
}
struct particle *default_particle = def != NULL
? conf_to_particle(def, common->font) : NULL;
? conf_to_particle(def, inherited) : NULL;
return map_new(
common, yml_value_as_string(tag), particle_map, yml_dict_length(values),

View file

@ -239,15 +239,20 @@ from_conf(const struct yml_node *node, struct particle *common)
const struct yml_node *empty = yml_get_value(node, "empty");
const struct yml_node *indicator = yml_get_value(node, "indicator");
struct conf_inherit inherited = {
.font = common->font,
.foreground = common->foreground,
};
return progress_bar_new(
common,
yml_value_as_string(tag),
yml_value_as_int(length),
conf_to_particle(start, common->font),
conf_to_particle(end, common->font),
conf_to_particle(fill, common->font),
conf_to_particle(empty, common->font),
conf_to_particle(indicator, common->font));
conf_to_particle(start, inherited),
conf_to_particle(end, inherited),
conf_to_particle(fill, inherited),
conf_to_particle(empty, inherited),
conf_to_particle(indicator, inherited));
}
static bool

View file

@ -167,7 +167,8 @@ from_conf(const struct yml_node *node, struct particle *common)
it.node != NULL;
yml_list_next(&it), idx++)
{
parts[idx] = conf_to_particle(it.node, common->font);
parts[idx] = conf_to_particle(
it.node, (struct conf_inherit){common->font, common->foreground});
}
return ramp_new(common, yml_value_as_string(tag), parts, count);