diff options
author | Eugene V. Lyubimkin <jackyf@debian.org> | 2014-05-01 13:16:56 +0300 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2016-04-11 13:00:34 +0200 |
commit | 43997d37137cc1e4a1a5be654aa16d4992045e34 (patch) | |
tree | b89a3360498e310adb64b337d849ea25aa0e51f0 /SwapMeter.c | |
parent | 51516557d375ac91e0a1a6f0525c3def1d3d79b0 (diff) | |
parent | f75ab6d2c11e8a8e18191b087564aedebbeb96c5 (diff) | |
download | debian_htop-43997d37137cc1e4a1a5be654aa16d4992045e34.tar.gz debian_htop-43997d37137cc1e4a1a5be654aa16d4992045e34.tar.bz2 debian_htop-43997d37137cc1e4a1a5be654aa16d4992045e34.zip |
Imported Debian patch 1.0.3-1debian/1.0.3-1
Diffstat (limited to 'SwapMeter.c')
-rw-r--r-- | SwapMeter.c | 20 |
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", |