aboutsummaryrefslogtreecommitdiffstats
path: root/SwapMeter.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2016-04-11 13:00:33 +0200
committerDaniel Lange <DLange@git.local>2016-04-11 13:00:33 +0200
commitf75ab6d2c11e8a8e18191b087564aedebbeb96c5 (patch)
tree2a046e11678e798f3f9c7f7af4f9ac205c8d2731 /SwapMeter.c
parent2004bbc3ef28ada3acca05f5d5fa9108121a6784 (diff)
downloaddebian_htop-f75ab6d2c11e8a8e18191b087564aedebbeb96c5.tar.gz
debian_htop-f75ab6d2c11e8a8e18191b087564aedebbeb96c5.tar.bz2
debian_htop-f75ab6d2c11e8a8e18191b087564aedebbeb96c5.zip
Imported Upstream version 1.0.3upstream/1.0.3
Diffstat (limited to 'SwapMeter.c')
-rw-r--r--SwapMeter.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/SwapMeter.c b/SwapMeter.c
index 48a7dae..2cb86d5 100644
--- a/SwapMeter.c
+++ b/SwapMeter.c
@@ -11,7 +11,6 @@ in the source distribution for its full text.
#include "ProcessList.h"
#include <stdlib.h>
-#include <curses.h>
#include <string.h>
#include <math.h>
#include <sys/param.h>
@@ -31,18 +30,14 @@ int SwapMeter_attributes[] = {
/* NOTE: Value is in kilobytes */
static void SwapMeter_humanNumber(char* buffer, const long int* value) {
- if (*value >= 10*GIGABYTE)
- sprintf(buffer, "%ldG ", *value / GIGABYTE);
- else if (*value >= 10*MEGABYTE)
- sprintf(buffer, "%ldM ", *value / MEGABYTE);
- else
- sprintf(buffer, "%ldK ", *value);
+ sprintf(buffer, "%ldM ", *value / MEGABYTE);
}
static void SwapMeter_setValues(Meter* this, char* buffer, int len) {
long int usedSwap = this->pl->usedSwap;
this->total = this->pl->totalSwap;
this->values[0] = usedSwap;
+
snprintf(buffer, len, "%ld/%ldMB", (long int) usedSwap / MEGABYTE, (long int) this->total / MEGABYTE);
}
@@ -59,11 +54,14 @@ static void SwapMeter_display(Object* cast, RichString* out) {
RichString_append(out, CRT_colors[METER_VALUE], buffer);
}
-MeterType SwapMeter = {
+MeterClass SwapMeter_class = {
+ .super = {
+ .extends = Class(Meter),
+ .delete = Meter_delete,
+ .display = SwapMeter_display,
+ },
.setValues = SwapMeter_setValues,
- .display = SwapMeter_display,
- .mode = BAR_METERMODE,
- .items = 1,
+ .defaultMode = BAR_METERMODE,
.total = 100.0,
.attributes = SwapMeter_attributes,
.name = "Swap",

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