aboutsummaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-01-07 11:08:31 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-01-07 11:08:31 +0000
commitba48109a9b6c4d125567eb75d7a9fe29d6640385 (patch)
tree9cb01b860fb62033f0ee1f2145814a4355101ff2 /config.c
parentrender: sixel: fix assertion: x/y coords may be outside visible area (diff)
parentconfig: add optional ‘center’ argument to ‘pad’ (diff)
Merge branch 'center-grid-content'
Closes #273
Diffstat (limited to 'config.c')
-rw-r--r--config.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/config.c b/config.c
index 883cf27c..0e106584 100644
--- a/config.c
+++ b/config.c
@@ -466,9 +466,15 @@ parse_section_main(const char *key, const char *value, struct config *conf,
else if (strcmp(key, "pad") == 0) {
unsigned x, y;
- if (sscanf(value, "%ux%u", &x, &y) != 2) {
+ char mode[16] = {0};
+
+ int ret = sscanf(value, "%ux%u %15s", &x, &y, mode);
+ bool center = strcasecmp(mode, "center") == 0;
+ bool invalid_mode = !center && mode[0] != '\0';
+
+ if ((ret != 2 && ret != 3) || invalid_mode) {
LOG_AND_NOTIFY_ERR(
- "%s:%d: [default]: pad: expected PAD_XxPAD_Y, "
+ "%s:%d: [default]: pad: expected PAD_XxPAD_Y [center], "
"where both are positive integers, got '%s'",
path, lineno, value);
return false;
@@ -476,6 +482,7 @@ parse_section_main(const char *key, const char *value, struct config *conf,
conf->pad_x = x;
conf->pad_y = y;
+ conf->center = center;
}
else if (strcmp(key, "bold-text-in-bright") == 0)