Improve/fix the TUI's current source line highlight
authorPedro Alves <palves@redhat.com>
Mon, 18 Mar 2019 14:29:44 +0000 (14:29 +0000)
committerPedro Alves <palves@redhat.com>
Mon, 18 Mar 2019 14:29:44 +0000 (14:29 +0000)
commit77b66be9699f4800e169acb5cba6c96bd9cb327b
treeb00dc210519cdda9d7f4d7cae044f4f37e292267
parent6885905d1da17780b3f00f90e9b56340a7f239e8
Improve/fix the TUI's current source line highlight

With styling enabled, I think the way we display the TUI's
highlighted/current line is very ugly and distracting.  The problem in
my view is that we reverse foreground/background in colored text as
well, leading to rainbow of background colors.

This patch changes that to something that I find much more sensible --
only reverse the default foreground/background colors, leave styled
text colors alone.  If the foreground color is not the default
(because the text was styled), leave the foreground color as is.  If
e.g., the terminal is fg=BLACK, and bg=WHITE, and the style wants to
print text in RED, reverse the background color (print in BLACK), but
still print the text in RED.

Note: The new ui_file_style::set_fg method isn't called set_foreground
instead, because set_foreground is a macro in /usr/lib/term.h (ncurses).

gdb/ChangeLog:
2019-03-18  Pedro Alves  <palves@redhat.com>

* tui/tui-io.c (reverse_mode_p, reverse_save_bg, reverse_save_fg):
New globals.
(apply_style): New, factored out from ...
(apply_ansi_escape): ... this.  Handle reverse video mode.
(tui_set_reverse_mode): New function.
* tui/tui-io.h (tui_set_reverse_mode): New declaration.
* tui/tui-winsource.c (tui_show_source_line): Use
tui_set_reverse_mode instead of setting A_STANDOUT.
* ui-style.h (struct ui_file_style) <set_reverse, set_fg, set_bg>:
New setter methods.
gdb/ChangeLog
gdb/tui/tui-io.c
gdb/tui/tui-io.h
gdb/tui/tui-winsource.c
gdb/ui-style.h