diff options
Diffstat (limited to 'SwapMeter.c')
-rw-r--r-- | SwapMeter.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/SwapMeter.c b/SwapMeter.c index c0f4820..1055a6e 100644 --- a/SwapMeter.c +++ b/SwapMeter.c @@ -13,6 +13,7 @@ in the source distribution for its full text. #include <stddef.h> #include "CRT.h" +#include "Macros.h" #include "Object.h" #include "Platform.h" #include "RichString.h" @@ -20,7 +21,8 @@ in the source distribution for its full text. static const int SwapMeter_attributes[] = { SWAP, - SWAP_CACHE + SWAP_CACHE, + SWAP_FRONTSWAP, }; static void SwapMeter_updateValues(Meter* this) { @@ -28,10 +30,11 @@ static void SwapMeter_updateValues(Meter* this) { size_t size = sizeof(this->txtBuffer); int written; - this->values[1] = NAN; /* 'cached' not present on all platforms */ + this->values[SWAP_METER_CACHE] = NAN; /* 'cached' not present on all platforms */ + this->values[SWAP_METER_FRONTSWAP] = NAN; /* 'frontswap' not present on all platforms */ Platform_setSwapValues(this); - written = Meter_humanUnit(buffer, this->values[0], size); + written = Meter_humanUnit(buffer, this->values[SWAP_METER_USED], size); METER_BUFFER_CHECK(buffer, size, written); METER_BUFFER_APPEND_CHR(buffer, size, '/'); @@ -49,11 +52,17 @@ static void SwapMeter_display(const Object* cast, RichString* out) { RichString_appendAscii(out, CRT_colors[METER_TEXT], " used:"); RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer); - if (!isnan(this->values[SWAP_METER_CACHE])) { + if (isNonnegative(this->values[SWAP_METER_CACHE])) { Meter_humanUnit(buffer, this->values[SWAP_METER_CACHE], sizeof(buffer)); RichString_appendAscii(out, CRT_colors[METER_TEXT], " cache:"); RichString_appendAscii(out, CRT_colors[SWAP_CACHE], buffer); } + + if (isNonnegative(this->values[SWAP_METER_FRONTSWAP])) { + Meter_humanUnit(buffer, this->values[SWAP_METER_FRONTSWAP], sizeof(buffer)); + RichString_appendAscii(out, CRT_colors[METER_TEXT], " frontswap:"); + RichString_appendAscii(out, CRT_colors[SWAP_FRONTSWAP], buffer); + } } const MeterClass SwapMeter_class = { @@ -64,7 +73,7 @@ const MeterClass SwapMeter_class = { }, .updateValues = SwapMeter_updateValues, .defaultMode = BAR_METERMODE, - .maxItems = 2, + .maxItems = SWAP_METER_ITEMCOUNT, .total = 100.0, .attributes = SwapMeter_attributes, .name = "Swap", |