aboutsummaryrefslogtreecommitdiffstats
path: root/Settings.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2016-04-11 13:00:19 +0200
committerDaniel Lange <DLange@git.local>2016-04-11 13:00:19 +0200
commit266ab52b3a741a58fb17c48b0f7939d7c5d266de (patch)
treeb4bccc59b9a35f3acbe7560f3d633940c71aedef /Settings.c
parent2c8c1a156130aa40be7dcaeb3ce2977a03cf50c2 (diff)
downloaddebian_htop-266ab52b3a741a58fb17c48b0f7939d7c5d266de.tar.gz
debian_htop-266ab52b3a741a58fb17c48b0f7939d7c5d266de.tar.bz2
debian_htop-266ab52b3a741a58fb17c48b0f7939d7c5d266de.zip
Imported Upstream version 0.6upstream/0.6
Diffstat (limited to 'Settings.c')
-rw-r--r--Settings.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/Settings.c b/Settings.c
index 0e01999..30b5c54 100644
--- a/Settings.c
+++ b/Settings.c
@@ -21,6 +21,7 @@ typedef struct Settings_ {
ProcessList* pl;
Header* header;
int colorScheme;
+ bool changed;
int delay;
} Settings;
@@ -35,15 +36,19 @@ Settings* Settings_new(ProcessList* pl, Header* header) {
if (!home) home = getenv("HOME");
this->userSettings = String_cat(home, "/.htoprc");
this->colorScheme = 0;
+ this->changed = false;
this->delay = DEFAULT_DELAY;
bool ok = Settings_read(this, this->userSettings);
if (!ok) {
+ this->changed = true;
// TODO: how to get SYSCONFDIR correctly through Autoconf?
char* systemSettings = String_cat(SYSCONFDIR, "/htoprc");
ok = Settings_read(this, systemSettings);
free(systemSettings);
if (!ok) {
Header_defaultMeters(this->header);
+ pl->hideKernelThreads = true;
+ pl->highlightMegabytes = true;
}
}
return this;
@@ -98,14 +103,20 @@ bool Settings_read(Settings* this, char* fileName) {
char* trim = String_trim(option[1]);
char** ids = String_split(trim, ' ');
free(trim);
- int i;
- for (i = 0; ids[i] != NULL; i++) {
- this->pl->fields[i] = atoi(ids[i]);
+ int i, j;
+ for (j = 0, i = 0; i < LAST_PROCESSFIELD && ids[i] != NULL; i++) {
+ // This "+1" is for compatibility with the older enum format.
+ int id = atoi(ids[i]) + 1;
+ if (id > 0 && id < LAST_PROCESSFIELD) {
+ this->pl->fields[j] = id;
+ j++;
+ }
}
- this->pl->fields[i] = LAST_PROCESSFIELD;
+ this->pl->fields[j] = (ProcessField) NULL;
String_freeArray(ids);
} else if (String_eq(option[0], "sort_key")) {
- this->pl->sortKey = atoi(option[1]);
+ // This "+1" is for compatibility with the older enum format.
+ this->pl->sortKey = atoi(option[1]) + 1;
} else if (String_eq(option[0], "sort_direction")) {
this->pl->direction = atoi(option[1]);
} else if (String_eq(option[0], "tree_view")) {
@@ -164,11 +175,13 @@ bool Settings_write(Settings* this) {
fprintf(fd, "# The parser is also very primitive, and not human-friendly.\n");
fprintf(fd, "# (I know, it's in the todo list).\n");
fprintf(fd, "fields=");
- for (int i = 0; this->pl->fields[i] != LAST_PROCESSFIELD; i++) {
- fprintf(fd, "%d ", (int) this->pl->fields[i]);
+ for (int i = 0; this->pl->fields[i]; i++) {
+ // This "-1" is for compatibility with the older enum format.
+ fprintf(fd, "%d ", (int) this->pl->fields[i]-1);
}
fprintf(fd, "\n");
- fprintf(fd, "sort_key=%d\n", (int) this->pl->sortKey);
+ // This "-1" is for compatibility with the older enum format.
+ fprintf(fd, "sort_key=%d\n", (int) this->pl->sortKey-1);
fprintf(fd, "sort_direction=%d\n", (int) this->pl->direction);
fprintf(fd, "hide_threads=%d\n", (int) this->pl->hideThreads);
fprintf(fd, "hide_kernel_threads=%d\n", (int) this->pl->hideKernelThreads);

© 2014-2024 Faster IT GmbH | imprint | privacy policy