summaryrefslogtreecommitdiffstats
path: root/linux/ZramMeter.c
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2023-04-03 20:30:20 +0200
committerBenBE <BenBE@geshi.org>2023-04-11 23:09:10 +0200
commit467bb78bb1cedc1709216ef38424ecb3928263ea (patch)
treed2e6f731a8ed0b9560fe8664b1c8e4d9820fefe6 /linux/ZramMeter.c
parentccf745ee7ea017230827ad0c5332d1e14fa3ee10 (diff)
ZramMeter: update bar mode
Show both compressed and uncompressed bars. Closes: #1216
Diffstat (limited to 'linux/ZramMeter.c')
-rw-r--r--linux/ZramMeter.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/linux/ZramMeter.c b/linux/ZramMeter.c
index e1e27b71..6e80eb1a 100644
--- a/linux/ZramMeter.c
+++ b/linux/ZramMeter.c
@@ -7,10 +7,12 @@
#include "Object.h"
#include "Platform.h"
#include "RichString.h"
+#include "ZramMeter.h"
-static const int ZramMeter_attributes[] = {
- ZRAM
+static const int ZramMeter_attributes[ZRAM_METER_ITEMCOUNT] = {
+ [ZRAM_METER_COMPRESSED] = ZRAM_COMPRESSED,
+ [ZRAM_METER_UNCOMPRESSED] = ZRAM_UNCOMPRESSED,
};
static void ZramMeter_updateValues(Meter* this) {
@@ -20,15 +22,12 @@ static void ZramMeter_updateValues(Meter* this) {
Platform_setZramValues(this);
- /* on print bar for compressed data size, not uncompressed */
- this->curItems = 1;
-
- written = Meter_humanUnit(buffer, this->values[0], size);
+ written = Meter_humanUnit(buffer, this->values[ZRAM_METER_COMPRESSED], size);
METER_BUFFER_CHECK(buffer, size, written);
METER_BUFFER_APPEND_CHR(buffer, size, '(');
- written = Meter_humanUnit(buffer, this->values[1], size);
+ written = Meter_humanUnit(buffer, this->values[ZRAM_METER_UNCOMPRESSED], size);
METER_BUFFER_CHECK(buffer, size, written);
METER_BUFFER_APPEND_CHR(buffer, size, ')');
@@ -47,11 +46,11 @@ static void ZramMeter_display(const Object* cast, RichString* out) {
Meter_humanUnit(buffer, this->total, sizeof(buffer));
RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer);
- Meter_humanUnit(buffer, this->values[0], sizeof(buffer));
+ Meter_humanUnit(buffer, this->values[ZRAM_METER_COMPRESSED], sizeof(buffer));
RichString_appendAscii(out, CRT_colors[METER_TEXT], " used:");
RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer);
- Meter_humanUnit(buffer, this->values[1], sizeof(buffer));
+ Meter_humanUnit(buffer, this->values[ZRAM_METER_UNCOMPRESSED], sizeof(buffer));
RichString_appendAscii(out, CRT_colors[METER_TEXT], " uncompressed:");
RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer);
}
@@ -64,7 +63,8 @@ const MeterClass ZramMeter_class = {
},
.updateValues = ZramMeter_updateValues,
.defaultMode = BAR_METERMODE,
- .maxItems = 2,
+ .maxItems = ZRAM_METER_ITEMCOUNT,
+ .comprisedValues = true,
.total = 100.0,
.attributes = ZramMeter_attributes,
.name = "Zram",

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