Re: [PATCH v2] gdb/tui: Fix unexpected reuse of color pairs

Andrew Burgess <[email protected]>
Newsgroups gmane.comp.gdb.patches
Message-ID <[email protected]>
[email protected] writes:

> From: Jakob Schäffeler <[email protected]>
>
> 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.
> This patch avoids calling COLOR_PAIR(pair) to be able to
> render more than 256 color pairs.
> For this, the wattron call is replaced with wcolor_set.
> This also results in last_color_pair no longer being needed since we
> set the color directly with wcolor_set and do not need
> wattron/off pairs any longer.
> This results in SHRT_MAX different color pairs to be available.
> To get all 65535 color pairs, init_pair is replaced with
> init_extended_pair, which takes an int instead of a short.
> Since this is not available with ncurses versions older than 6.1,
> a configure check was added.
> This patch was tested with make check-gdb TESTS="gdb.tui/*.exp"
> Additionally, I tested this with the python extension from the
> bug report.

Thank you for the revisions.  I fixed a trailing white space issue in
the code, and reworded the commit message a bit to (I think) make some
things clearer.  I then pushed this patch.

I did look at possibly using the Python code from the bug to create a
test case, but that will require extending GDB's terminal emulation to
support the extended set of colours, which feels like a big task, so I
left that for now.

Thanks,
Andrew
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.