aboutsummaryrefslogtreecommitdiffstats
path: root/SwapMeter.c
diff options
context:
space:
mode:
Diffstat (limited to 'SwapMeter.c')
-rw-r--r--SwapMeter.c22
1 files changed, 19 insertions, 3 deletions
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 <math.h>
+#include <stddef.h>
+
#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",

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