diff options
author | Andrew Burgess <aburgess@redhat.com> | 2025-02-17 10:21:12 +0000 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2025-02-24 17:03:18 +0000 |
commit | 431b369e1cb963b221345991a25f901a0b58d91a (patch) | |
tree | 1e4aa1aac3df3cd25628ce8b04088260d3d06fdd /libctf/ctf-link.c | |
parent | dbfac07a71613288529d4b40c9a48ad76c19b360 (diff) | |
download | binutils-431b369e1cb963b221345991a25f901a0b58d91a.zip binutils-431b369e1cb963b221345991a25f901a0b58d91a.tar.gz binutils-431b369e1cb963b221345991a25f901a0b58d91a.tar.bz2 |
gdb/styling: only check TERM environment once, during initialisation
We currently check the TERM environment variable any time we call one
of the ui_file::can_emit_style_escape() functions. This seems
excessive.
During GDB's startup we also check for the NO_COLOR environment
variable and disable styling if this is set.
I propose that we combine these two checks, and perform them just once
during startup (as the current NO_COLOR check is currently done). As
with the NO_COLOR check, if the TERM variable is set to "dumb"
indicating that styling is not supported then we should just set
cli_styling to false.
This does mean that the user can then 'set style enabled on', even for
a dumb terminal, which was not possible previously. Before this
commit the "dumb" terminal check was separate and would prevent
styling even if 'set style enabled on' was in effect.
Of course, trying to turn on styling in a dumb terminal might not give
the results that a user hope for. And so, I have implemented a check
in `set_style_enabled`, so in a dumb terminal a user will see this:
(gdb) set style enabled on
warning: The current terminal doesn't support styling. Styled output might not appear as expected.
After which GDB will try to emit styling. We could, potentially,
prevent styling being enabled instead of emitting a warning, but I'm
inclined to let the user turn on styling if they really want to.
Approved-By: Kevin Buettner <kevinb@redhat.com>
Acked-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'libctf/ctf-link.c')
0 files changed, 0 insertions, 0 deletions