From 69f439eff387a6ecb52734e400b297a3c85f2285 Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Tue, 21 Sep 2021 08:35:19 +0200 Subject: New upstream version 3.1.0 --- SwapMeter.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'SwapMeter.c') diff --git a/SwapMeter.c b/SwapMeter.c index e39cfd9..63f58c5 100644 --- a/SwapMeter.c +++ b/SwapMeter.c @@ -5,8 +5,13 @@ Released under the GNU GPLv2, see the COPYING file in the source distribution for its full text. */ +#include "config.h" // IWYU pragma: keep + #include "SwapMeter.h" +#include +#include + #include "CRT.h" #include "Object.h" #include "Platform.h" @@ -14,11 +19,16 @@ in the source distribution for its full text. static const int SwapMeter_attributes[] = { - SWAP + SWAP, + SWAP_CACHE }; -static void SwapMeter_updateValues(Meter* this, char* buffer, size_t size) { +static void SwapMeter_updateValues(Meter* this) { + char* buffer = this->txtBuffer; + size_t size = sizeof(this->txtBuffer); int written; + + this->values[1] = NAN; /* 'cached' not present on all platforms */ Platform_setSwapValues(this); written = Meter_humanUnit(buffer, this->values[0], size); @@ -38,6 +48,12 @@ static void SwapMeter_display(const Object* cast, RichString* out) { Meter_humanUnit(buffer, this->values[0], sizeof(buffer)); RichString_appendAscii(out, CRT_colors[METER_TEXT], " used:"); RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer); + + if (!isnan(this->values[1])) { + Meter_humanUnit(buffer, this->values[1], sizeof(buffer)); + RichString_appendAscii(out, CRT_colors[METER_TEXT], " cache:"); + RichString_appendAscii(out, CRT_colors[SWAP_CACHE], buffer); + } } const MeterClass SwapMeter_class = { @@ -48,7 +64,7 @@ const MeterClass SwapMeter_class = { }, .updateValues = SwapMeter_updateValues, .defaultMode = BAR_METERMODE, - .maxItems = 1, + .maxItems = 2, .total = 100.0, .attributes = SwapMeter_attributes, .name = "Swap", -- cgit v1.2.3