From 64917bab3caa10d89cb5ed160d20801065b7440b Mon Sep 17 00:00:00 2001 From: Jannik Hartung Date: Tue, 5 Aug 2025 13:50:58 +0200 Subject: [UI/TUI] Add support for italic and underline ANSI escape sequences The ANSI escape sequence translation layer in TUI mode strips italic or underlined text modes silently. You cannot output text formatted like that using `TuiWindow.write` in Python at the moment. Parse the ANSI escape sequences for italic and underlined text into the `ui_file_style` structure and apply it to the TUI window when applying styles, similar to preserving the bold/dim state already. A script like this shows italic and underlined text correctly now. ```python import gdb class TestTUIWindow: _tui_window: gdb.TuiWindow def __init__(self, tui_window: gdb.TuiWindow) -> None: self._tui_window = tui_window self._tui_window.title = "colors test" def render(self) -> None: self._tui_window.write(""" \x1b[4mThis is underlined.\x1b[24m And normal text. \x1b[3mThis is italic.\x1b[23m And normal text. """, True) gdb.register_window_type("colortest", TestTUIWindow) ``` And launching it with ``` source the_above_script.py tui new-layout test colortest 1 cmd 1 layout test ``` Approved-By: Tom Tromey --- gdb/testsuite/gdb.base/style.exp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'gdb/testsuite/gdb.base') diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp index 47efb64..a6c18d3 100644 --- a/gdb/testsuite/gdb.base/style.exp +++ b/gdb/testsuite/gdb.base/style.exp @@ -323,10 +323,10 @@ proc run_style_tests { } { gdb_test_no_output "set style version background 255" gdb_test_no_output "set style version foreground #FED210" gdb_test "show style version background" \ - "The \033\\\[38;2;254;210;16;48;5;255;22;27m.*\".*version.*\".*style.*\033\\\[m background color is: 255" \ + "The \033\\\[38;2;254;210;16;48;5;255;22;23;24;27m.*\".*version.*\".*style.*\033\\\[m background color is: 255" \ "Version's 256-color background style" gdb_test "show style version foreground" \ - "The \033\\\[38;2;254;210;16;48;5;255;22;27m.*\".*version.*\".*style.*\033\\\[m foreground color is: #FED210" \ + "The \033\\\[38;2;254;210;16;48;5;255;22;23;24;27m.*\".*version.*\".*style.*\033\\\[m foreground color is: #FED210" \ "Version's TrueColor foreground style" } @@ -782,7 +782,7 @@ proc test_pagination_cmd_after_quit_styling {} { -re "^apropos time\r\n" { exp_continue } - -re "^\033\\\[39;49;1;27m\[^\r\n\]+\r\n" { + -re "^\033\\\[39;49;1;23;24;27m\[^\r\n\]+\r\n" { exp_continue } -re "^$::pagination_prompt$" { @@ -828,7 +828,7 @@ proc test_pagination_cmd_after_quit_styling {} { # non-default style that was in use when pagination kicked in # above. gdb_test "maintenance time" \ - "^\"\033\\\[39;49;1;27mmaintenance time\033\\\[m\" takes a numeric argument\\." + "^\"\033\\\[39;49;1;23;24;27mmaintenance time\033\\\[m\" takes a numeric argument\\." } # Helper for test_pagination_prompt_styling. Return false if STR, a @@ -995,20 +995,20 @@ proc test_pagination_continue_styling_1 { length } { exp_continue } - -re "^The current logfile is \"\033\\\[32;49;22;27m(?:ax)+\033\\\[m" { + -re "^The current logfile is \"\033\\\[32;49;22;23;24;27m(?:ax)+\033\\\[m" { exp_continue } - -re "^\r\n\033\\\[32;49;22;27m(?:ax)+\033\\\[m(?=--)" { + -re "^\r\n\033\\\[32;49;22;23;24;27m(?:ax)+\033\\\[m(?=--)" { exp_continue } - -re "^\r\n\033\\\[32;49;22;27m(?:ax)+(?=--)" { + -re "^\r\n\033\\\[32;49;22;23;24;27m(?:ax)+(?=--)" { set saw_bad_styling true exp_continue } - -re "^\r\n\033\\\[32;49;22;27m(?:ax)+\033\\\[m\"\\.\r\n" { + -re "^\r\n\033\\\[32;49;22;23;24;27m(?:ax)+\033\\\[m\"\\.\r\n" { exp_continue } -- cgit v1.1