]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[UI/TUI] Add support for italic and underline ANSI escape sequences
authorJannik Hartung <peacemakerctf@gmail.com>
Tue, 5 Aug 2025 11:50:58 +0000 (13:50 +0200)
committerJannik Hartung <peacemakerctf@gmail.com>
Tue, 5 Aug 2025 11:52:15 +0000 (13:52 +0200)
commit64917bab3caa10d89cb5ed160d20801065b7440b
tree6f03532f2d0bd7c8f017aeb147bab94b7e500cf6
parent2df2e47c5ae84fce2a51cd3d05abbd09f8a752c3
[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 <tom@tromey.com>
gdb/testsuite/gdb.base/style.exp
gdb/testsuite/lib/gdb-utils.exp
gdb/tui/tui-io.c
gdb/ui-style.c
gdb/ui-style.h
gdb/unittests/style-selftests.c