From 50d6afab6aac26b2829acd9a9e60f24a8348434c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 17 Feb 2019 15:45:02 +0100 Subject: [PATCH] bar: add margin properties to the border --- bar/bar.c | 4 ++++ bar/bar.h | 2 ++ bar/private.h | 2 ++ config-verify.c | 5 +++++ config.c | 20 ++++++++++++++++++++ 5 files changed, 33 insertions(+) diff --git a/bar/bar.c b/bar/bar.c index f252ca5..f643b0d 100644 --- a/bar/bar.c +++ b/bar/bar.c @@ -378,6 +378,10 @@ bar_new(const struct bar_config *config) priv->right_margin = config->right_margin; priv->border.width = config->border.width; priv->border.color = config->border.color; + priv->border.left_margin = config->border.left_margin; + priv->border.right_margin = config->border.right_margin; + priv->border.top_margin = config->border.top_margin; + priv->border.bottom_margin = config->border.bottom_margin; priv->left.mods = malloc(config->left.count * sizeof(priv->left.mods[0])); priv->left.exps = calloc(config->left.count, sizeof(priv->left.exps[0])); priv->center.mods = malloc(config->center.count * sizeof(priv->center.mods[0])); diff --git a/bar/bar.h b/bar/bar.h index b4765a2..90bbb96 100644 --- a/bar/bar.h +++ b/bar/bar.h @@ -28,6 +28,8 @@ struct bar_config { struct { int width; struct rgba color; + int left_margin, right_margin; + int top_margin, bottom_margin; } border; struct { diff --git a/bar/private.h b/bar/private.h index 647fb20..78017c7 100644 --- a/bar/private.h +++ b/bar/private.h @@ -19,6 +19,8 @@ struct private { struct { int width; struct rgba color; + int left_margin, right_margin; + int top_margin, bottom_margin; } border; struct { diff --git a/config-verify.c b/config-verify.c index f947979..91dff96 100644 --- a/config-verify.c +++ b/config-verify.c @@ -331,6 +331,11 @@ verify_bar_border(keychain_t *chain, const struct yml_node *node) static const struct attr_info attrs[] = { {"width", true, &conf_verify_int}, {"color", true, &conf_verify_color}, + {"margin", false, &conf_verify_int}, + {"left-margin", false, &conf_verify_int}, + {"right-margin", false, &conf_verify_int}, + {"top-margin", false, &conf_verify_int}, + {"bottom-margin", false, &conf_verify_int}, {NULL, false, NULL}, }; diff --git a/config.c b/config.c index 73590ea..d576460 100644 --- a/config.c +++ b/config.c @@ -226,12 +226,32 @@ conf_to_bar(const struct yml_node *bar) if (border != NULL) { const struct yml_node *width = yml_get_value(border, "width"); const struct yml_node *color = yml_get_value(border, "color"); + const struct yml_node *margin = yml_get_value(border, "margin"); + const struct yml_node *left_margin = yml_get_value(border, "left-margin"); + const struct yml_node *right_margin = yml_get_value(border, "right-margin"); + const struct yml_node *top_margin = yml_get_value(border, "top-margin"); + const struct yml_node *bottom_margin = yml_get_value(border, "bottom-margin"); if (width != NULL) conf.border.width = yml_value_as_int(width); if (color != NULL) conf.border.color = conf_to_color(color); + + if (margin != NULL) + conf.border.left_margin = + conf.border.right_margin = + conf.border.top_margin = + conf.border.bottom_margin = yml_value_as_int(margin); + + if (left_margin != NULL) + conf.border.left_margin = yml_value_as_int(left_margin); + if (right_margin != NULL) + conf.border.right_margin = yml_value_as_int(right_margin); + if (top_margin != NULL) + conf.border.top_margin = yml_value_as_int(top_margin); + if (bottom_margin != NULL) + conf.border.bottom_margin = yml_value_as_int(bottom_margin); } /*