diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2021-08-24 17:40:22 +0200 |
---|---|---|
committer | Christian Göttsche <cgzones@googlemail.com> | 2021-08-24 20:27:59 +0200 |
commit | db076b9c8e01e3e92340712a29d269c464bcf9f3 (patch) | |
tree | f274ed4eaebdeb51e857f0faffb93fb6da712ca6 /Settings.c | |
parent | 0679e9f45e8e5524702b0cb0a2a8cfdcdb31b372 (diff) |
HeaderLayout: save name in configuration
Use a name in the user configuration file instead of the compile
time enum value, so that future reorderings or insertions do not change
the user selected layout.
Diffstat (limited to 'Settings.c')
-rw-r--r-- | Settings.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -7,6 +7,7 @@ in the source distribution for its full text. #include "Settings.h" +#include <ctype.h> #include <errno.h> #include <limits.h> #include <stdio.h> @@ -266,7 +267,7 @@ static bool Settings_read(Settings* this, const char* fileName, unsigned int ini this->enableMouse = atoi(option[1]); #endif } else if (String_eq(option[0], "header_layout")) { - this->hLayout = atoi(option[1]); + this->hLayout = isdigit((unsigned char)option[1][0]) ? ((HeaderLayout) atoi(option[1])) : HeaderLayout_fromName(option[1]); if (this->hLayout < 0 || this->hLayout >= LAST_HEADER_LAYOUT) this->hLayout = HF_TWO_50_50; free(this->hColumns); @@ -394,7 +395,7 @@ int Settings_write(const Settings* this, bool onCrash) { fprintf(fd, "enable_mouse=%d\n", (int) this->enableMouse); #endif fprintf(fd, "delay=%d\n", (int) this->delay); - fprintf(fd, "header_layout=%d\n", (int) this->hLayout); + fprintf(fd, "header_layout=%s\n", HeaderLayout_getName(this->hLayout)); for (unsigned int i = 0; i < HeaderLayout_getColumns(this->hLayout); i++) { fprintf(fd, "column_meters_%u=", i); writeMeters(this, fd, i); |