diff options
author | Andrew Burgess <aburgess@redhat.com> | 2025-04-29 17:57:06 +0100 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2025-05-06 11:24:28 +0100 |
commit | 41b0ab843fb8f1639c34776512f0886af96a36a9 (patch) | |
tree | 55a6a3281d6d41bb1aa510552361959d2fb92d75 /gdb/python/python.c | |
parent | 4dd03f30caa7cae1d41ff070e7519b09d5d95648 (diff) | |
download | binutils-41b0ab843fb8f1639c34776512f0886af96a36a9.zip binutils-41b0ab843fb8f1639c34776512f0886af96a36a9.tar.gz binutils-41b0ab843fb8f1639c34776512f0886af96a36a9.tar.bz2 |
gdb/python/guile: check if styling is disabled in Color.escape_sequence
I noticed that the gdb.Color.escape_sequence() method would produce an
escape sequence even when styling is disabled.
I think this is the wrong choice. Ideally, when styling is
disabled (e.g. with 'set style enabled off'), GDB should not be
producing styled output.
If a GDB extension is using gdb.Color to apply styling to the output,
then currently, the extension should be checking 'show style enabled'
any time Color.escape_sequence() is used. This means lots of code
duplication, and the possibility that some locations will be missed,
which means disabling styling no longer does what it says.
I propose that Color.escape_sequence() should return the empty string
if styling is disabled. A Python extension can then do:
python
c_none = gdb.Color('none')
c_red = gdb.Color('red')
print(c_red.escape_sequence(True)
+ "Text in red."
+ c_none.escape_sequence(True))
end
If styling is enable this will print some red text. And if styling is
disabled, then it will print text in the terminal's default color.
I have applied the same fix to the guile API.
I have extended the tests to cover this case.
Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/python/python.c')
0 files changed, 0 insertions, 0 deletions