diff options
author | Kumar <kumar@onenetbeyond.org> | 2022-04-14 16:35:02 +0530 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2022-05-26 15:03:39 +0200 |
commit | 0af08bcfc99e9533e84b84e374ce17a3c01b81e1 (patch) | |
tree | 9e5f1e7293fd78068daaf7fe6ed5d8e70a455900 /ProcessList.c | |
parent | e053446cbd52d422cb4be4876a64e184adfde5c7 (diff) |
Process: Display single digit precision for CPU% greater than 99.9%
Since commit edf319e[1], we're dynamically adjusting column width of
"CPU%", showing single digit precision also for values greater than
"99.9%" makes "CPU%" column consistent with all other values.
[1]: edf319e53d1fb77546505e238d75160a3febe56e
Change "Process_printPercentage()" function's logic to always display
value (i.e. "val") with single precision. Except when value is greater
than "99.9%" for columns like "MEM%", whose width is fixed to "4" and
value cannot go beyond "100%".
Credits: @Explorer09, thanks for the patch[2] to fix title alignment
issue.
[2]: https://github.com/htop-dev/htop/pull/959#issuecomment-1092480951
Closes: #957
Diffstat (limited to 'ProcessList.c')
-rw-r--r-- | ProcessList.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/ProcessList.c b/ProcessList.c index f71619f6..705786f6 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -116,7 +116,10 @@ static const char* alignedProcessFieldTitle(const ProcessList* this, ProcessFiel if (Process_fields[field].autoWidth) { static char titleBuffer[UINT8_MAX + 1]; - xSnprintf(titleBuffer, sizeof(titleBuffer), "%-*.*s ", Process_fieldWidths[field], Process_fieldWidths[field], title); + if (field == PERCENT_CPU) + xSnprintf(titleBuffer, sizeof(titleBuffer), "%*s ", Process_fieldWidths[field], title); + else + xSnprintf(titleBuffer, sizeof(titleBuffer), "%-*.*s ", Process_fieldWidths[field], Process_fieldWidths[field], title); return titleBuffer; } |