[Bug 280679] [termcap] [patch] bold colors broken in ncurses apps for xterm-256color

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 21 Nov 2024 22:09:47 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=280679

Jan Beich <jbeich@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bapt@FreeBSD.org

--- Comment #5 from Jan Beich <jbeich@FreeBSD.org> ---
(In reply to Cullum Smith from comment #4)
> FreeBSD's terminfo seems to have a termcap compatibility layer

ncurses in FreeBSD >= 14 enabled terminfo support (base 61f66a1f4403) but due
to POLA (backlash?) still uses homegrown termcap database by default. Users
seeking advanced terminfo-only features (or Linux-style defaults) are expected
(base b75fb12b6827) to install misc/terminfo-db.

CC @bapt as misc/terminfo-db looks barely documented anywhere.

> special handling in 256-color mode.

0-7 are regular colors, compatible with vt100-color.
8-15 are bright colors, compatible with xterm-16color.

From xterm-256color source:

# This implementation uses a 256-element color map where the first 16 entries
# are shared with the aixterm-compatible colors (and in turn the first 8 are
# shared with the ANSI colors).  The three levels (256, 16, 8) account for the
# use of a conditional expression in setaf/setab which reduces the number of
# characters sent to the screen for typical applications.

From xterm(1) manpage:

       boldColors (class ColorMode)
               Specifies whether to combine bold attribute with colors like
               the IBM PC, i.e., map colors 0 through 7 to colors 8 through
               15.  These normally are the brighter versions of the first 8
               colors, hence bold.  The default is "true".

> setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m,

terminfo(5) manpage explains the syntax. Basically, 0-7 colors use \E[3<arg>m,
8-15 colors use \E[9<arg-8>m while the rest use \E[38;5;<arg>m

$ tput setaf 6 | od -a
0000000  esc   [   3   6   m
0000005
$ tput setaf 14 | od -a
0000000  esc   [   9   6   m
0000005
$ tput setaf 22 | od -a
0000000  esc   [   3   8   ;   5   ;   2   2   m
0000012

-- 
You are receiving this mail because:
You are the assignee for the bug.