aboutsummaryrefslogtreecommitdiff
path: root/gdb/ui-style.h
AgeCommit message (Collapse)AuthorFilesLines
2019-06-14Do not emit style escape sequences to log fileTom Tromey1-2/+2
PR gdb/24502 requests that the "set logging" log file not contain style escape sequences emitted by gdb. This seemed like a reasonable request to me, so this patch implements filtering for the log file. This also updates a comment in ui-style.h that I noticed while writing the patch. Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-06-14 Tom Tromey <tromey@adacore.com> PR gdb/24502: * ui-style.h (skip_ansi_escape): Update comment. * ui-file.h (class no_terminal_escape_file): New class. * ui-file.c (no_terminal_escape_file::write) (no_terminal_escape_file::puts): New methods. * cli/cli-logging.c (handle_redirections): Use no_terminal_escape_file. gdb/testsuite/ChangeLog 2019-06-14 Tom Tromey <tromey@adacore.com> PR gdb/24502: * gdb.base/style-logging.exp: New file.
2019-03-18Improve/fix the TUI's current source line highlightPedro Alves1-0/+18
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.
2019-02-17Fix pager bugs with style outputTom Tromey1-0/+10
I believe this fixes all the pager output problems with styling that Philippe pointed out, plus at least one more. The patch is somewhat hard to reason about, so you may wish to give it a try. Even writing the tests was hard. This removes the style caching, because it was difficult to keep the style cache correct in all cases. Since this would cause more style escapes to be emitted, instead it changes fputs_styled to try to avoid unnecessary changes. Another bug was that the wrap buffer was not flushed in the case where wrap_column==0. In the old (pre-patch series) code, characters were directly emitted in this case; so flushing the wrap buffer here restores this behavior. On error the wrap buffer must be emptied. Otherwise, interrupting output can leave characters in the buffer that will be emitted later. As discussed on gdb-patches, this fixes the ada-lang.c problem where filtered and unfiltered printing were mixed. Now user_select_syms uses filtered printing, which is what its callees were already doing. Finally, it was possible for source line highlighting to be garbled (and invalid escape sequences emitted) if the pager was invoked at the wrong spot. To fix this, the patch arranges for source line escapes to always be emitted as a unit. gdb/ChangeLog 2019-02-17 Tom Tromey <tom@tromey.com> * ada-lang.c (user_select_syms): Use filtered printing. * utils.c (wrap_style): New global. (desired_style): Remove. (emit_style_escape): Add stream parameter. (set_output_style, reset_terminal_style, prompt_for_continue): Update. (flush_wrap_buffer): Only flush gdb_stdout. (wrap_here): Set wrap_style. (fputs_maybe_filtered): Clear the wrap buffer on exception. Don't treat escape sequences as a character. Change when wrap buffer is flushed. (fputs_styled): Do not set the output style when the default is requested. * ui-style.h (struct ui_file_style) <is_default>: New method. * source.c (print_source_lines_base): Emit escape sequences in one piece. gdb/testsuite/ChangeLog 2019-02-17 Tom Tromey <tom@tromey.com> * gdb.base/style.exp: Add line-wrapping tests. * gdb.base/page.exp: Add test for quitting during pagination.
2019-01-01Update copyright year range in all GDB files.Joel Brobecker1-1/+1
This commit applies all changes made after running the gdb/copyright.py script. Note that one file was flagged by the script, due to an invalid copyright header (gdb/unittests/basic_string_view/element_access/char/empty.cc). As the file was copied from GCC's libstdc++-v3 testsuite, this commit leaves this file untouched for the time being; a patch to fix the header was sent to gcc-patches first. gdb/ChangeLog: Update copyright year range in all GDB files.
2018-12-28Introduce ui_file_styleTom Tromey1-0/+213
This introduces the new ui_file_style class and various helpers. This class represents a terminal style and provides methods for parsing and emitting the corresponding ANSI terminal escape sequences. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * unittests/style-selftests.c: New file. * ui-style.c: New file. * ui-style.h: New file. * ui-file.h: Include ui-style.h. * Makefile.in (COMMON_SFILES): Add ui-style.c. (HFILES_NO_SRCDIR): Add ui-style.h. (SUBDIR_UNITTESTS_SRCS): Add style-selftests.c.