Package: htop
Version: 2.0.2-1
Followup-For: Bug #793106
Dear Maintainer,
I just hit this myself, and narrowed down the cause to running with
TERM=linux-16color.
$ infocmp linux linux-16color
comparing linux to linux-16color.
comparing booleans.
comparing numbers.
colors: 8, 16.
ncv: 18, 42.
pairs: 64, 256.
comparing strings.
setab: '\E[4%p1%dm', '\E[4%p1%{8}%m%d%?%p1%{7}%>%t;5%e;25%;m'.
setaf: '\E[3%p1%dm', '\E[3%p1%{8}%m%d%?%p1%{7}%>%t;1%e;21%;m'.
In particular, `ncv` for linux-16color includes `A_BOLD` and `A_BLINK`.
(It is, buggily, missing `A_DIM` since the termianal includes the `dim`
capability, but it correctly lacks `A_ITALIC` since it doesn't have `stitm`).
From terminfo(5):
On some color terminals, colors collide with highlights. You can reg‐
ister these collisions with the ncv capability. This is a bit-mask of
attributes not to be used when colors are enabled. The correspondence
with the attributes understood by curses is as follows:
Attribute Bit Decimal Set by
A_STANDOUT 0 1 sgr
A_UNDERLINE 1 2 sgr
A_REVERSE 2 4 sgr
A_BLINK 3 8 sgr
A_DIM 4 16 sgr
A_BOLD 5 32 sgr
A_INVIS 6 64 sgr
A_PROTECT 7 128 sgr
A_ALTCHARSET 8 256 sgr
A_HORIZONTAL 9 512 sgr1
A_LEFT 10 1024 sgr1
A_LOW 11 2048 sgr1
A_RIGHT 12 4096 sgr1
A_TOP 13 8192 sgr1
A_VERTICAL 14 16384 sgr1
A_ITALIC 15 32768 sitm
For example, on many IBM PC consoles, the underline attribute collides
with the foreground color blue and is not available in color mode.
These should have an ncv capability of 2.
SVr4 curses does nothing with ncv, ncurses recognizes it and optimizes
the output in favor of colors.
When TERM=linux, htop is *manually* assuming it can get 16 colors on an
8-color terminal using bold/blink (which happens to work on some terminals,
but is generally *not* reliable).
The correct thing to do is to use native support for 16 colors when
available, and fall back to 8 colors *without* bold/blink otherwise
(making sure to adjust the foreground if it matches the background -
dark blue is a common choice for black-on-black).
If you want to assume that everybody claiming they're TERM=linux really
supports 16 colors (remember that lots of terminal emulators lie! But -C
mode should suffice for liars), you should unconditionally change the
TERM=linux to TERM=linux-16color in the environment at startup.
As a short-term workaround (to avoid fixing all the buggy calls), do the
opposite: change TERM=linux-16color to TERM=linux during startup.
If there are any terminal entries which claim to only support 8 colors
but can actually support 16, they should have a similar terminfo entry
written if one doesn't already exist.
-Ben
-- System Information:
Debian Release: stretch/sid
APT prefers unstable-debug
APT policy: (500, 'unstable-debug'), (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386, x32, arm64
Kernel: Linux 4.8.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages htop depends on:
ii libc6 2.24-8
ii libncursesw5 6.0+20161126-1
ii libtinfo5 6.0+20161126-1
htop recommends no packages.
Versions of packages htop suggests:
ii lsof 4.89+dfsg-0.1
ii strace 4.15-2
-- no debconf information