aboutsummaryrefslogtreecommitdiffstats
path: root/Settings.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2020-08-27 07:48:10 +0200
committerDaniel Lange <DLange@git.local>2020-08-27 07:48:10 +0200
commitf3147ea2d1598914c2db53e8cfb34c8ff81e2ff4 (patch)
tree3ee82b2af2ab3d38b6e4b07f3994516aac72f742 /Settings.c
parentdf568a576f7b44ac5a2b9b7222c7f39d9932f626 (diff)
downloaddebian_htop-f3147ea2d1598914c2db53e8cfb34c8ff81e2ff4.tar.gz
debian_htop-f3147ea2d1598914c2db53e8cfb34c8ff81e2ff4.tar.bz2
debian_htop-f3147ea2d1598914c2db53e8cfb34c8ff81e2ff4.zip
New upstream version 3.0.0upstream/3.0.0
Diffstat (limited to 'Settings.c')
-rw-r--r--Settings.c48
1 files changed, 40 insertions, 8 deletions
diff --git a/Settings.c b/Settings.c
index db2fa06..81d547b 100644
--- a/Settings.c
+++ b/Settings.c
@@ -31,7 +31,7 @@ typedef struct {
typedef struct Settings_ {
char* filename;
-
+
MeterColumnSettings columns[2];
ProcessField* fields;
@@ -45,6 +45,8 @@ typedef struct Settings_ {
bool countCPUsFromZero;
bool detailedCPUTime;
+ bool showCPUUsage;
+ bool showCPUFrequency;
bool treeView;
bool showProgramPath;
bool hideThreads;
@@ -58,6 +60,11 @@ typedef struct Settings_ {
bool updateProcessNames;
bool accountGuestInCPUMeter;
bool headerMargin;
+ bool enableMouse;
+ bool vimMode;
+ #ifdef HAVE_LIBHWLOC
+ bool topologyAffinity;
+ #endif
bool changed;
} Settings;
@@ -114,7 +121,7 @@ static void Settings_defaultMeters(Settings* this) {
this->columns[i].modes = xCalloc(sizes[i], sizeof(int));
this->columns[i].len = sizes[i];
}
-
+
int r = 0;
if (this->cpuCount > 8) {
this->columns[0].names[0] = xStrdup("LeftCPUs2");
@@ -134,7 +141,7 @@ static void Settings_defaultMeters(Settings* this) {
this->columns[0].modes[1] = BAR_METERMODE;
this->columns[0].names[2] = xStrdup("Swap");
this->columns[0].modes[2] = BAR_METERMODE;
-
+
this->columns[1].names[r] = xStrdup("Tasks");
this->columns[1].modes[r++] = TEXT_METERMODE;
this->columns[1].names[r] = xStrdup("LoadAverage");
@@ -165,13 +172,13 @@ static void readFields(ProcessField* fields, int* flags, const char* line) {
static bool Settings_read(Settings* this, const char* fileName) {
FILE* fd;
-
+
CRT_dropPrivileges();
fd = fopen(fileName, "r");
CRT_restorePrivileges();
if (!fd)
return false;
-
+
bool didReadMeters = false;
bool didReadFields = false;
for (;;) {
@@ -223,6 +230,10 @@ static bool Settings_read(Settings* this, const char* fileName) {
this->detailedCPUTime = atoi(option[1]);
} else if (String_eq(option[0], "cpu_count_from_zero")) {
this->countCPUsFromZero = atoi(option[1]);
+ } else if (String_eq(option[0], "show_cpu_usage")) {
+ this->showCPUUsage = atoi(option[1]);
+ } else if (String_eq(option[0], "show_cpu_frequency")) {
+ this->showCPUFrequency = atoi(option[1]);
} else if (String_eq(option[0], "update_process_names")) {
this->updateProcessNames = atoi(option[1]);
} else if (String_eq(option[0], "account_guest_in_cpu_meter")) {
@@ -232,6 +243,8 @@ static bool Settings_read(Settings* this, const char* fileName) {
} else if (String_eq(option[0], "color_scheme")) {
this->colorScheme = atoi(option[1]);
if (this->colorScheme < 0 || this->colorScheme >= LAST_COLORSCHEME) this->colorScheme = 0;
+ } else if (String_eq(option[0], "enable_mouse")) {
+ this->enableMouse = atoi(option[1]);
} else if (String_eq(option[0], "left_meters")) {
Settings_readMeters(this, option[1], 0);
didReadMeters = true;
@@ -244,6 +257,12 @@ static bool Settings_read(Settings* this, const char* fileName) {
} else if (String_eq(option[0], "right_meter_modes")) {
Settings_readMeterModes(this, option[1], 1);
didReadMeters = true;
+ } else if (String_eq(option[0], "vim_mode")) {
+ this->vimMode = atoi(option[1]);
+ #ifdef HAVE_LIBHWLOC
+ } else if (String_eq(option[0], "topology_affinity")) {
+ this->topologyAffinity = !!atoi(option[1]);
+ #endif
}
String_freeArray(option);
}
@@ -312,20 +331,27 @@ bool Settings_write(Settings* this) {
fprintf(fd, "header_margin=%d\n", (int) this->headerMargin);
fprintf(fd, "detailed_cpu_time=%d\n", (int) this->detailedCPUTime);
fprintf(fd, "cpu_count_from_zero=%d\n", (int) this->countCPUsFromZero);
+ fprintf(fd, "show_cpu_usage=%d\n", (int) this->showCPUUsage);
+ fprintf(fd, "show_cpu_frequency=%d\n", (int) this->showCPUFrequency);
fprintf(fd, "update_process_names=%d\n", (int) this->updateProcessNames);
fprintf(fd, "account_guest_in_cpu_meter=%d\n", (int) this->accountGuestInCPUMeter);
fprintf(fd, "color_scheme=%d\n", (int) this->colorScheme);
+ fprintf(fd, "enable_mouse=%d\n", (int) this->enableMouse);
fprintf(fd, "delay=%d\n", (int) this->delay);
fprintf(fd, "left_meters="); writeMeters(this, fd, 0);
fprintf(fd, "left_meter_modes="); writeMeterModes(this, fd, 0);
fprintf(fd, "right_meters="); writeMeters(this, fd, 1);
fprintf(fd, "right_meter_modes="); writeMeterModes(this, fd, 1);
+ fprintf(fd, "vim_mode=%d\n", (int) this->vimMode);
+ #ifdef HAVE_LIBHWLOC
+ fprintf(fd, "topology_affinity=%d\n", (int) this->topologyAffinity);
+ #endif
fclose(fd);
return true;
}
Settings* Settings_new(int cpuCount) {
-
+
Settings* this = xCalloc(1, sizeof(Settings));
this->sortKey = PERCENT_CPU;
@@ -340,11 +366,16 @@ Settings* Settings_new(int cpuCount) {
this->highlightMegabytes = false;
this->detailedCPUTime = false;
this->countCPUsFromZero = false;
+ this->showCPUUsage = true;
+ this->showCPUFrequency = false;
this->updateProcessNames = false;
this->cpuCount = cpuCount;
this->showProgramPath = true;
this->highlightThreads = true;
-
+ #ifdef HAVE_LIBHWLOC
+ this->topologyAffinity = false;
+ #endif
+
this->fields = xCalloc(Platform_numberOfFields+1, sizeof(ProcessField));
// TODO: turn 'fields' into a Vector,
// (and ProcessFields into proper objects).
@@ -375,7 +406,7 @@ Settings* Settings_new(int cpuCount) {
htopDir = String_cat(home, "/.config/htop");
}
legacyDotfile = String_cat(home, "/.htoprc");
-
+
CRT_dropPrivileges();
(void) mkdir(configDir, 0700);
(void) mkdir(htopDir, 0700);
@@ -390,6 +421,7 @@ Settings* Settings_new(int cpuCount) {
CRT_restorePrivileges();
}
this->colorScheme = 0;
+ this->enableMouse = true;
this->changed = false;
this->delay = DEFAULT_DELAY;
bool ok = false;

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