mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-24 21:05:40 +02:00
config: clean up particle_list_from_config()
This commit is contained in:
parent
b2082e38ed
commit
68606e49ed
1 changed files with 17 additions and 27 deletions
44
config.c
44
config.c
|
@ -220,40 +220,30 @@ static struct particle *
|
||||||
particle_list_from_config(const struct yml_node *node,
|
particle_list_from_config(const struct yml_node *node,
|
||||||
const struct font *parent_font)
|
const struct font *parent_font)
|
||||||
{
|
{
|
||||||
const struct yml_node *items_node = yml_get_value(node, "items");
|
const struct yml_node *items = yml_get_value(node, "items");
|
||||||
|
|
||||||
const struct yml_node *margin_node = yml_get_value(node, "margin");
|
const struct yml_node *margin = yml_get_value(node, "margin");
|
||||||
const struct yml_node *left_margin_node = yml_get_value(node, "left_margin");
|
const struct yml_node *_left_margin = yml_get_value(node, "left_margin");
|
||||||
const struct yml_node *right_margin_node = yml_get_value(node, "right_margin");
|
const struct yml_node *_right_margin = yml_get_value(node, "right_margin");
|
||||||
|
|
||||||
const struct yml_node *spacing_node = yml_get_value(node, "spacing");
|
const struct yml_node *spacing = yml_get_value(node, "spacing");
|
||||||
const struct yml_node *left_spacing_node = yml_get_value(node, "left_spacing");
|
const struct yml_node *_left_spacing = yml_get_value(node, "left_spacing");
|
||||||
const struct yml_node *right_spacing_node = yml_get_value(node, "right_spacing");
|
const struct yml_node *_right_spacing = yml_get_value(node, "right_spacing");
|
||||||
|
|
||||||
int left_margin = 0;
|
int left_margin = margin != NULL ? yml_value_as_int(margin) :
|
||||||
int right_margin = 0;
|
_left_margin != NULL ? yml_value_as_int(_left_margin) : 0;
|
||||||
int left_spacing = 0;
|
int right_margin = margin != NULL ? yml_value_as_int(margin) :
|
||||||
int right_spacing = 2;
|
_right_margin != NULL ? yml_value_as_int(_right_margin) : 0;
|
||||||
|
int left_spacing = spacing != NULL ? yml_value_as_int(spacing) :
|
||||||
|
_left_spacing != NULL ? yml_value_as_int(_left_spacing) : 0;
|
||||||
|
int right_spacing = spacing != NULL ? yml_value_as_int(spacing) :
|
||||||
|
_right_spacing != NULL ? yml_value_as_int(_right_spacing) : 2;;
|
||||||
|
|
||||||
if (margin_node != NULL)
|
size_t count = yml_list_length(items);
|
||||||
left_margin = right_margin = yml_value_as_int(margin_node);
|
|
||||||
if (left_margin_node != NULL)
|
|
||||||
left_margin = yml_value_as_int(left_margin_node);
|
|
||||||
if (right_margin_node != NULL)
|
|
||||||
right_margin = yml_value_as_int(right_margin_node);
|
|
||||||
|
|
||||||
if (spacing_node != NULL)
|
|
||||||
left_spacing = right_spacing = yml_value_as_int(spacing_node);
|
|
||||||
if (left_spacing_node != NULL)
|
|
||||||
left_spacing = yml_value_as_int(left_spacing_node);
|
|
||||||
if (right_spacing_node != NULL)
|
|
||||||
right_spacing = yml_value_as_int(right_spacing_node);
|
|
||||||
|
|
||||||
size_t count = yml_list_length(items_node);
|
|
||||||
struct particle *parts[count];
|
struct particle *parts[count];
|
||||||
|
|
||||||
size_t idx = 0;
|
size_t idx = 0;
|
||||||
for (struct yml_list_iter it = yml_list_iter(items_node);
|
for (struct yml_list_iter it = yml_list_iter(items);
|
||||||
it.node != NULL;
|
it.node != NULL;
|
||||||
yml_list_next(&it), idx++)
|
yml_list_next(&it), idx++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue