Skip to content

Commit 5410df8

Browse files
Daniel LangeDaniel Lange
authored andcommitted
Merge branch 'main' of batk0/htop
2 parents 9ce887b + 83739b7 commit 5410df8

4 files changed

Lines changed: 12 additions & 1 deletion

File tree

DisplayOptionsPanel.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager*
149149
&(settings->showCPUTemperature)));
150150
Panel_add(super, (Object*) CheckItem_newByRef("- Show temperature in degree Fahrenheit instead of Celsius", &(settings->degreeFahrenheit)));
151151
#endif
152+
Panel_add(super, (Object*) CheckItem_newByRef("Show cached memory in graph", &(settings->showCachedMemory)));
152153
#ifdef HAVE_GETMOUSE
153154
Panel_add(super, (Object*) CheckItem_newByRef("Enable the mouse", &(settings->enableMouse)));
154155
#endif

MemoryMeter.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,17 @@ static void MemoryMeter_updateValues(Meter* this) {
3333
size_t size = sizeof(this->txtBuffer);
3434
int written;
3535

36+
Settings *settings = this->host->settings;
37+
3638
/* shared, compressed and available memory are not supported on all platforms */
3739
this->values[MEMORY_METER_SHARED] = NAN;
3840
this->values[MEMORY_METER_COMPRESSED] = NAN;
3941
this->values[MEMORY_METER_AVAILABLE] = NAN;
4042
Platform_setMemoryValues(this);
41-
43+
if ((this->mode == GRAPH_METERMODE || this->mode == BAR_METERMODE) && !settings->showCachedMemory) {
44+
this->values[MEMORY_METER_BUFFERS] = 0;
45+
this->values[MEMORY_METER_CACHE] = 0;
46+
}
4247
/* Do not print available memory in bar mode */
4348
static_assert(MEMORY_METER_AVAILABLE + 1 == MEMORY_METER_ITEMCOUNT,
4449
"MEMORY_METER_AVAILABLE is not the last item in MemoryMeterValues");

Settings.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,8 @@ static bool Settings_read(Settings* this, const char* fileName, const Machine* h
466466
this->showCPUUsage = atoi(option[1]);
467467
} else if (String_eq(option[0], "show_cpu_frequency")) {
468468
this->showCPUFrequency = atoi(option[1]);
469+
} else if (String_eq(option[0], "show_cached_memory")) {
470+
this->showCachedMemory = atoi(option[1]);
469471
#ifdef BUILD_WITH_CPU_TEMP
470472
} else if (String_eq(option[0], "show_cpu_temperature")) {
471473
this->showCPUTemperature = atoi(option[1]);
@@ -701,6 +703,7 @@ int Settings_write(const Settings* this, bool onCrash) {
701703
printSettingInteger("show_cpu_temperature", this->showCPUTemperature);
702704
printSettingInteger("degree_fahrenheit", this->degreeFahrenheit);
703705
#endif
706+
printSettingInteger("show_cached_memory", this->showCachedMemory);
704707
printSettingInteger("update_process_names", this->updateProcessNames);
705708
printSettingInteger("account_guest_in_cpu_meter", this->accountGuestInCPUMeter);
706709
printSettingInteger("color_scheme", this->colorScheme);
@@ -805,6 +808,7 @@ Settings* Settings_new(const Machine* host, Hashtable* dynamicMeters, Hashtable*
805808
this->showCPUTemperature = false;
806809
this->degreeFahrenheit = false;
807810
#endif
811+
this->showCachedMemory = true;
808812
this->updateProcessNames = false;
809813
this->showProgramPath = true;
810814
this->highlightThreads = true;

Settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ typedef struct Settings_ {
101101
bool accountGuestInCPUMeter;
102102
bool headerMargin;
103103
bool screenTabs;
104+
bool showCachedMemory;
104105
#ifdef HAVE_GETMOUSE
105106
bool enableMouse;
106107
#endif

0 commit comments

Comments
 (0)