From: Andrew Burgess Date: Sun, 30 Mar 2025 09:25:18 +0000 (+0100) Subject: gdb: allow selecting default fg/bg colors in tui mode X-Git-Tag: gdb-16.3-release~22 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a2c8f78df57338aafb891df68102aff1b12f54f8;p=thirdparty%2Fbinutils-gdb.git gdb: allow selecting default fg/bg colors in tui mode This commit fixes PR gdb/32797, and pulls in just part of commit: commit 6447969d0ac774b6dec0f95a0d3d27c27d158690 Date: Sat Oct 5 22:27:44 2024 +0300 Add an option with a color type. to the gdb-16-branch. This commit allows the escape sequences \x1b[39m and \x1b[49m, which select the default foreground and background colours respectively, to work correctly. This fix is just a small part of the above commit. Only these two changes are required to fix this bug. As we are currently preparing for a 16.3 release, I don't think we should be pulling in the whole of the above commit. You can test this commit using: export TERM=xterm-256color gdb -q -tui -ex 'py print("normal\n\x1b[39mforeground default\n\x1b[0mnormal\n\x1b[49mbackground default\n\x1b[0mnormal\n")' All of the output text should use the default foreground and background colors. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32797 Approved-By: Tom Tromey --- diff --git a/gdb/ui-style.c b/gdb/ui-style.c index 952102e30c3..be4c7aca046 100644 --- a/gdb/ui-style.c +++ b/gdb/ui-style.c @@ -315,9 +315,11 @@ ui_file_style::parse (const char *buf, size_t *n_read) case 35: case 36: case 37: + m_foreground = color (value - 30); + break; /* Note: not 38. */ case 39: - m_foreground = color (value - 30); + m_foreground = NONE; break; case 40: @@ -328,9 +330,11 @@ ui_file_style::parse (const char *buf, size_t *n_read) case 45: case 46: case 47: + m_background = color (value - 40); + break; /* Note: not 48. */ case 49: - m_background = color (value - 40); + m_background = NONE; break; case 90: