Skip to content

Commit

Permalink
Process: Show only integer value when CPU% more than 99.9%
Browse files Browse the repository at this point in the history
When we run a process which utilizes CPU between 100.0% and 999.9%, htop
shows an unnecessary decimal character at the end of the value. For
example, '100.x' and '247.x' become '100.' and '247.' respectively.

When CPU utilization is less than and equal to '99.9%', show the result
with single digit precision and if result is less than four characters,
pad it with the blank space. When CPU utilization is greater than
'99.9%', show only integral part of the result and if it's less than
four characters, pad it with the blank space.

Closes: hishamhm#946
  • Loading branch information
etanot authored and BenBE committed Feb 19, 2022
1 parent d35db47 commit da653f8
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions Process.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,9 +739,6 @@ void Process_printPercentage(float val, char* buffer, int n, int* attr) {
*attr = CRT_colors[PROCESS_SHADOW];
}
xSnprintf(buffer, n, "%4.1f ", val);
} else if (val < 999) {
*attr = CRT_colors[PROCESS_MEGABYTES];
xSnprintf(buffer, n, "%3d. ", (int)val);
} else {
*attr = CRT_colors[PROCESS_MEGABYTES];
xSnprintf(buffer, n, "%4d ", (int)val);
Expand Down

0 comments on commit da653f8

Please sign in to comment.