aboutsummaryrefslogtreecommitdiffstats
path: root/SwapMeter.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2021-09-21 08:35:20 +0200
committerDaniel Lange <DLange@git.local>2021-09-21 08:35:20 +0200
commita2b6942d15d220bb0518003d4f818a922d88e9f9 (patch)
tree7f60a44dec34af24da75b8d5b68c88eca94b9f6a /SwapMeter.c
parent37d8824862a2f6b9375022e1c45ba4548162650f (diff)
parent69f439eff387a6ecb52734e400b297a3c85f2285 (diff)
downloaddebian_htop-a2b6942d15d220bb0518003d4f818a922d88e9f9.tar.gz
debian_htop-a2b6942d15d220bb0518003d4f818a922d88e9f9.tar.bz2
debian_htop-a2b6942d15d220bb0518003d4f818a922d88e9f9.zip
Update upstream source from tag 'upstream/3.1.0'
Update to upstream version '3.1.0' with Debian dir d4ecdd99a38d7105de46689cebcb051bf0046a76
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