Change the color and total based on the actual 1min load value:
< 1 : green and total of 1.0
< cpu-count : yellow and total of cpu-count
else : red and total of 2*cpu-count
Closes: #32
In case the text is too long for the bar, try to fit by truncating at a
space character.
E.g.
[|24.1% 2000Mhz 40°C]
[24.1% 2000Mhz 40°C]
[||||24.1% 2000Mhz]
[|||24.1% 2000Mhz]
[||24.1% 2000Mhz]
[|24.1% 2000Mhz]
[24.1% 2000Mhz]
[|||| 24.1%]
[|||| 24.1%]
[|||| 24.1%]
[||||24.1%]
[|||24.1%]
[||24.1%]
[|24.1%]
[24.1%]
[24.1]
[24.]
[24]
[2]
RichString_writeFrom takes a top spot during performance analysis due to the
calls to mbstowcs() and iswprint().
Most of the time we know in advance that we are only going to print regular
ASCII characters.
Currently the code does not handle multi-byte characters, so length-
computations take the raw count of C characters and not the to displayed
size into account.
An example is the degree sign for temperatures.
Closes: #329
Allocating zero size memory results in implementation-defined behavior:
man:malloc(3) :
If size is 0, then malloc() returns either NULL, or a unique pointer
value that can later be successfully passed to free().
PR htop-dev/htop#70 got rid of the infrastructure for generating header
files, but it left behind some code duplication.
Some of cases are things that belong in the header file and don't need
to be repeated in the C file. Other cases are things that belong in the
C file and don't need to be in the header file.
In this commit I tried to fix all of these that I could find. When given
a choice I preferred keeping things out of the header file, unless they
were being used by someone else.
The MIN, MAX, CLAMP, MINIMUM, and MAXIMUM macros appear
throughout the codebase with many re-definitions. Make
a single copy of each in a common header file, and use
the BSD variants of MINIMUM/MAXIMUM due to conflicts in
the system <sys/param.h> headers.
Reasoning:
- implementation was unsound -- broke down when I added a fairly
basic macro definition expanding to a struct initializer in a *.c
file.
- made it way too easy (e.g. via otherwise totally innocuous git
commands) to end up with timestamps such that it always ran
MakeHeader.py but never used its output, leading to overbuild noise
when running what should be a null 'make'.
- but mostly: it's just an awkward way of dealing with C code.
Rationale (copied from htop issue #471):
The function name "setValues" is misleading. For most OOP (object-
oriented programming) contexts, setXXX functions mean they will change
some member variables of an object into something specified in
function arguments. But in the *Meter_setValues() case, the new values
are not from the arguments, but from a hard-coded source. The caller
is not supposed to change the values[] to anything it likes, but
rather to "update" the values from the source. Hence, updateValues is
a better name for this family of functions.