]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: allow selecting default fg/bg colors in tui mode
authorAndrew Burgess <aburgess@redhat.com>
Sun, 30 Mar 2025 09:25:18 +0000 (10:25 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Wed, 2 Apr 2025 15:11:24 +0000 (16:11 +0100)
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 <tom@tromey.com>
gdb/ui-style.c

index 952102e30c3266e636194221ab4eedbf7cde4e26..be4c7aca0460335dbe93f7b9658476f949462fd7 100644 (file)
@@ -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: