aboutsummaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorpi66 <pixel2176@proton.me>2025-12-19 11:17:29 +0000
committerDaniel Eklöf <daniel@ekloef.se>2026-03-02 08:13:01 +0000
commit21485fa66d9b7026bfd1dd2764431805cdb17cf1 (patch)
tree22a68406a54a8adf81abb2f860e5ee6187e847a2 /config.c
parentdoc: foot.ini: mention titlebar text color in button-color (diff)
support four-sided padding (left/top/right/bottom)
Diffstat (limited to 'config.c')
-rw-r--r--config.c41
1 files changed, 30 insertions, 11 deletions
diff --git a/config.c b/config.c
index 14e836c1..b1ff329c 100644
--- a/config.c
+++ b/config.c
@@ -945,13 +945,12 @@ parse_section_main(struct context *ctx)
}
else if (streq(key, "pad")) {
- unsigned x, y;
+ unsigned x, y, left, top, right, bottom;
char mode[64] = {0};
- int ret = sscanf(value, "%ux%u %63s", &x, &y, mode);
-
+ int ret = sscanf(value, "%ux%ux%ux%u %63s", &left, &top, &right, &bottom, mode);
enum center_when center = CENTER_NEVER;
- if (ret == 3) {
+ if (ret == 5) {
if (strcasecmp(mode, "center") == 0)
center = CENTER_ALWAYS;
else if (strcasecmp(mode, "center-when-fullscreen") == 0)
@@ -960,20 +959,38 @@ parse_section_main(struct context *ctx)
center = CENTER_MAXIMIZED_AND_FULLSCREEN;
else
center = CENTER_INVALID;
+ } else if (ret < 4) {
+ ret = sscanf(value, "%ux%u %63s", &x, &y, mode);
+ if (ret >= 2) {
+ left = right = x;
+ top = bottom = y;
+ if (ret == 3) {
+ if (strcasecmp(mode, "center") == 0)
+ center = CENTER_ALWAYS;
+ else if (strcasecmp(mode, "center-when-fullscreen") == 0)
+ center = CENTER_FULLSCREEN;
+ else if (strcasecmp(mode, "center-when-maximized-and-fullscreen") == 0)
+ center = CENTER_MAXIMIZED_AND_FULLSCREEN;
+ else
+ center = CENTER_INVALID;
+ }
+ }
}
- if ((ret != 2 && ret != 3) || center == CENTER_INVALID) {
+ if ((ret < 2 || ret > 5) || center == CENTER_INVALID) {
LOG_CONTEXTUAL_ERR(
- "invalid padding (must be in the form PAD_XxPAD_Y "
+ "invalid padding (must be in the form RIGHTxTOPxLEFTxBOTTOM or XxY "
"[center|"
"center-when-fullscreen|"
"center-when-maximized-and-fullscreen])");
return false;
}
- conf->pad_x = x;
- conf->pad_y = y;
- conf->center_when = ret == 2 ? CENTER_NEVER : center;
+ conf->pad_left = left;
+ conf->pad_top = top;
+ conf->pad_right = right;
+ conf->pad_bottom = bottom;
+ conf->center_when = (ret == 4 || ret == 2) ? CENTER_NEVER : center;
return true;
}
@@ -3453,8 +3470,10 @@ config_load(struct config *conf, const char *conf_path,
.width = 700,
.height = 500,
},
- .pad_x = 0,
- .pad_y = 0,
+ .pad_left = 0,
+ .pad_top = 0,
+ .pad_right = 0,
+ .pad_bottom = 0,
.center_when = CENTER_MAXIMIZED_AND_FULLSCREEN,
.resize_by_cells = true,
.resize_keep_grid = true,