aboutsummaryrefslogtreecommitdiff
path: root/gdb/config.in
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-09-03 12:42:59 -0600
committerTom Tromey <tom@tromey.com>2018-12-28 12:49:53 -0700
commit1d1d0bf76f3bc3056a1456e53c066f40ca4d0837 (patch)
treecbd1ca9662ff81211eeb0c426a36ec8f268e6141 /gdb/config.in
parent35fb8261b95c07e548a0b03f60b6c2cebf83caf8 (diff)
downloadgdb-1d1d0bf76f3bc3056a1456e53c066f40ca4d0837.zip
gdb-1d1d0bf76f3bc3056a1456e53c066f40ca4d0837.tar.gz
gdb-1d1d0bf76f3bc3056a1456e53c066f40ca4d0837.tar.bz2
Make ANSI terminal escape sequences work in TUI
PR tui/14126 notes that ANSI terminal escape sequences don't affect the colors shown in the TUI. A simple way to see this is to try the extended-prompt example from the gdb manual. Curses does not pass escape sequences through to the terminal. Instead, it replaces non-printable characters with a visible representation, for example "^[" for the ESC character. This patch fixes the problem by adding a simple ANSI terminal sequence parser to gdb. These sequences are decoded and those that are recognized are turned into the appropriate curses calls. The curses approach to color handling is unusual and so there are some oddities in the implementation. Standard curses has no notion of the default colors of the terminal. So, if you set the foreground color, it is not possible to reset it -- you have to pick some other color. ncurses provides an extension to handle this, so this patch updates configure and uses it when available. Second, in curses, colors always come in pairs: you cannot set just the foreground. This patch handles this by tracking actually-used pairs of colors and keeping a table of these for reuse. Third, there are a limited number of such pairs available. In this patch, if you try to use too many color combinations, gdb will just ignore some color changes. Finally, in addition to limiting the number of color pairs, curses also limits the number of colors. This means that, when using extended 8- or 24-bit color sequences, it may be possible to exhaust the curses color table. I am very sour on the curses design now. I do not know how to write a test for this, so I did not. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> PR tui/14126: * tui/tui.c (tui_enable): Call start_color and use_default_colors. * tui/tui-io.c (struct color_pair): New. (color_pair_map, last_color_pair, last_style): New globals. (tui_setup_io): Clean up color map when shutting down. (curses_colors): New constant. (get_color_pair, apply_ansi_escape): New functions. (tui_write): Rewrite. (tui_puts_internal): New function, from tui_puts. Add "height" parameter. (tui_puts): Use tui_puts_internal. (tui_redisplay_readline): Use tui_puts_internal. (_initialize_tui_io): New function. (color_map): New globals. (get_color): New function. * configure.ac: Check for use_default_colors. * config.in, configure: Rebuild.
Diffstat (limited to 'gdb/config.in')
-rw-r--r--gdb/config.in3
1 files changed, 3 insertions, 0 deletions
diff --git a/gdb/config.in b/gdb/config.in
index deb9d4a..760db6b 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -543,6 +543,9 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
+/* Define to 1 if you have the `use_default_colors' function. */
+#undef HAVE_USE_DEFAULT_COLORS
+
/* Define to 1 if you have the `vfork' function. */
#undef HAVE_VFORK