diff options
author | Daniel Lange <DLange@git.local> | 2024-01-10 12:40:37 +0100 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2024-01-10 12:40:37 +0100 |
commit | 7271b076b82785ffca73ee9e4ae84cabb77018ee (patch) | |
tree | e8270dd60ec096bee8157dbadf029e15ed584592 /BatteryMeter.c | |
parent | f288666edc9180a2e81e6655951878124f321df6 (diff) | |
download | debian_htop-7271b076b82785ffca73ee9e4ae84cabb77018ee.tar.gz debian_htop-7271b076b82785ffca73ee9e4ae84cabb77018ee.tar.bz2 debian_htop-7271b076b82785ffca73ee9e4ae84cabb77018ee.zip |
New upstream version 3.3.0upstream/3.3.0upstream
Diffstat (limited to 'BatteryMeter.c')
-rw-r--r-- | BatteryMeter.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/BatteryMeter.c b/BatteryMeter.c index 33d17b7..dad7754 100644 --- a/BatteryMeter.c +++ b/BatteryMeter.c @@ -7,11 +7,14 @@ in the source distribution for its full text. This meter written by Ian P. Hands (iphands@gmail.com, ihands@redhat.com). */ +#include "config.h" // IWYU pragma: keep + #include "BatteryMeter.h" #include <math.h> #include "CRT.h" +#include "Macros.h" #include "Object.h" #include "Platform.h" #include "XUtils.h" @@ -27,7 +30,7 @@ static void BatteryMeter_updateValues(Meter* this) { Platform_getBattery(&percent, &isOnAC); - if (isnan(percent)) { + if (!isNonnegative(percent)) { this->values[0] = NAN; xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "N/A"); return; @@ -37,16 +40,16 @@ static void BatteryMeter_updateValues(Meter* this) { const char* text; switch (isOnAC) { - case AC_PRESENT: - text = this->mode == TEXT_METERMODE ? " (Running on A/C)" : "(A/C)"; - break; - case AC_ABSENT: - text = this->mode == TEXT_METERMODE ? " (Running on battery)" : "(bat)"; - break; - case AC_ERROR: - default: - text = ""; - break; + case AC_PRESENT: + text = this->mode == TEXT_METERMODE ? " (Running on A/C)" : "(A/C)"; + break; + case AC_ABSENT: + text = this->mode == TEXT_METERMODE ? " (Running on battery)" : "(bat)"; + break; + case AC_ERROR: + default: + text = ""; + break; } xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%.1f%%%s", percent, text); |