mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-11 05:33:55 -04:00
config: add optional ‘center’ argument to ‘pad’
When set, the grid contents is centered in the window. I.e. the left/right and top/bottom margins are equal (+- 1px). This causes the content to “jump” while doing an interactive resize, but may still be preferred in e.g. a tiling WM. Closes #273
This commit is contained in:
parent
21dbb44a30
commit
e14c592f39
6 changed files with 44 additions and 8 deletions
11
config.c
11
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue