From 55c10aca2e93cc7a4301aa1635ef9d6d73a804b1 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Mon, 18 Mar 2019 14:26:00 +0000 Subject: 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 * 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) : New setter methods. --- gdb/tui/tui-winsource.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gdb/tui/tui-winsource.c') diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index 9925b79..e31a016 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -277,13 +277,13 @@ tui_show_source_line (struct tui_win_info *win_info, int lineno) line = win_info->generic.content[lineno - 1]; if (line->which_element.source.is_exec_point) - wattron (win_info->generic.handle, A_STANDOUT); + tui_set_reverse_mode (win_info->generic.handle, true); wmove (win_info->generic.handle, lineno, 1); tui_puts (line->which_element.source.line, win_info->generic.handle); if (line->which_element.source.is_exec_point) - wattroff (win_info->generic.handle, A_STANDOUT); + tui_set_reverse_mode (win_info->generic.handle, false); /* Clear to end of line but stop before the border. */ x = getcurx (win_info->generic.handle); -- cgit v1.1