TUI translates ANSI styling sequences to curses color pairs.
Currently, this process uses COLOR_PAIR, which only returns values
from 0 to 255 which results in unexpected reuse of color pairs.
Replacing wattron/wattroff with wcolor_set avoids the 256 color pair
limit imposed by the COLOR_PAIR macro. However, wcolor_set takes a
short for the pair index, limiting pairs to SHRT_MAX.
To support the full range of COLOR_PAIRS (up to 65536 with ncurses
6.1+), init_pair is replaced with init_extended_pair, and the pair
index is passed to wcolor_set via the opts parameter as an extended
color pair, a documented ncurses extension.
This also results in last_color_pair no longer being needed, and so it
is removed.
The extended color pair extension requires ncurses 6.1+, so a
configure check has been added. The fallback path uses the older
color pair API which limits GDB to SHRT_MAX (32767) color pairs.
This patch was tested with make check-gdb TESTS="gdb.tui/*.exp"
Additionally, I tested this with the python extension from the bug
report.