diff options
author | Jannik Hartung <peacemakerctf@gmail.com> | 2025-08-05 13:50:58 +0200 |
---|---|---|
committer | Jannik Hartung <peacemakerctf@gmail.com> | 2025-08-05 13:52:15 +0200 |
commit | 64917bab3caa10d89cb5ed160d20801065b7440b (patch) | |
tree | 6f03532f2d0bd7c8f017aeb147bab94b7e500cf6 /gdb/testsuite/lib | |
parent | 2df2e47c5ae84fce2a51cd3d05abbd09f8a752c3 (diff) | |
download | binutils-64917bab3caa10d89cb5ed160d20801065b7440b.zip binutils-64917bab3caa10d89cb5ed160d20801065b7440b.tar.gz binutils-64917bab3caa10d89cb5ed160d20801065b7440b.tar.bz2 |
[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>
Diffstat (limited to 'gdb/testsuite/lib')
-rw-r--r-- | gdb/testsuite/lib/gdb-utils.exp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/gdb/testsuite/lib/gdb-utils.exp b/gdb/testsuite/lib/gdb-utils.exp index fe2cfca..c24e7ed 100644 --- a/gdb/testsuite/lib/gdb-utils.exp +++ b/gdb/testsuite/lib/gdb-utils.exp @@ -70,6 +70,8 @@ proc style {str style} { set fg 39 set bg 49 set intensity 22 + set italic 23 + set underline 24 set reverse 27 switch -exact -- $style { title { set intensity 1 } @@ -84,7 +86,7 @@ proc style {str style} { line-number { set intensity 2 } none { return $str } } - return "\033\\\[${fg};${bg};${intensity};${reverse}m${str}\033\\\[m" + return "\033\\\[${fg};${bg};${intensity};${italic};${underline};${reverse}m${str}\033\\\[m" } # gdb_get_bp_addr num |