diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2023-05-31 14:17:10 +0200 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2023-12-31 21:35:57 +0100 |
commit | 955208569cc2ede37de15172fab8cdb7bfbe80fb (patch) | |
tree | c22777e279d624dd2de4030165c5b48c1d2c1402 /Settings.c | |
parent | 887c4eaff35cf123f7c2bd891bf91e163db41700 (diff) |
Settings: preserve empty header
If the user removes all meters from the header on exit htop will write
no values for the settings column_meters_X and column_meter_modes_X.
The parser skips all configuration settings with no value, so on the
next start no header meter related key is processed and htop will add a
set of default meters to the header.
Write instead an invalid value of `!`, so the keys are parsed and htop
will not add the default meters back.
Closes: #1248
Diffstat (limited to 'Settings.c')
-rw-r--r-- | Settings.c | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -592,15 +592,25 @@ static void writeList(FILE* fd, char** list, int len, char separator) { } static void writeMeters(const Settings* this, FILE* fd, char separator, unsigned int column) { - writeList(fd, this->hColumns[column].names, this->hColumns[column].len, separator); + if (this->hColumns[column].len) { + writeList(fd, this->hColumns[column].names, this->hColumns[column].len, separator); + } else { + fputc('!', fd); + fputc(separator, fd); + } } static void writeMeterModes(const Settings* this, FILE* fd, char separator, unsigned int column) { - const char* sep = ""; - for (size_t i = 0; i < this->hColumns[column].len; i++) { - fprintf(fd, "%s%d", sep, this->hColumns[column].modes[i]); - sep = " "; + if (this->hColumns[column].len) { + const char* sep = ""; + for (size_t i = 0; i < this->hColumns[column].len; i++) { + fprintf(fd, "%s%d", sep, this->hColumns[column].modes[i]); + sep = " "; + } + } else { + fputc('!', fd); } + fputc(separator, fd); } |