From: Matt Rice <ratmice@gmail.com>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 5/5] Add zebra-striping to CLI table display
Date: Sat, 13 Jun 2026 07:28:01 -0700 [thread overview]
Message-ID: <CACTLOFpRyE5eXtFY-2u=OS4qBAweWJJFR7HEbar5+FJ-91xgJw@mail.gmail.com> (raw)
In-Reply-To: <20260612-submit-zebra-style-v1-5-cfd00b5c984c@tromey.com>
On Fri, Jun 12, 2026 at 7:27 AM Tom Tromey <tom@tromey.com> wrote:
>
> This patch adds two new style settings to gdb. These can be used to
> add "zebra striping" to CLI tables -- that is, change the prevailing
> style of alternating lines of a table.
>
> Modifying the CLI ui-out is sufficient for most tables. However, this
> did not work for stack traces, because those aren't ordinary tables.
> This patch uses the "phony table" support (added earlier in this
> series) to achieve the same effect without otherwise impacting stack
> trace display.
>
> By default, styles are only changed if 256 colors are available. This
> way we can choose a relatively innocuous grey background.
>
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32285
> ---
> gdb/NEWS | 10 +++++
> gdb/cli-out.c | 24 +++++++++--
> gdb/cli-out.h | 10 +++++
> gdb/cli/cli-style.c | 43 +++++++++++++++++-
> gdb/cli/cli-style.h | 6 ++-
> gdb/doc/gdb.texinfo | 8 ++++
> gdb/stack.c | 6 +++
> gdb/testsuite/gdb.base/style.exp | 3 ++
> gdb/testsuite/gdb.base/zebra-style.c | 32 ++++++++++++++
> gdb/testsuite/gdb.base/zebra-style.exp | 79 ++++++++++++++++++++++++++++++++++
> gdb/testsuite/lib/gdb-utils.exp | 14 +++---
> gdb/ui-out.c | 8 +++-
> gdb/ui-out.h | 2 +
> gdb/utils.c | 6 +++
> 14 files changed, 238 insertions(+), 13 deletions(-)
>
> diff --git a/gdb/NEWS b/gdb/NEWS
> index d5214a98a57..99f3eccb11a 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -136,6 +136,16 @@ show progress-bars enabled
> content, to be disabled (the set command), or to see if
> progress-bars are currently enabled or not (the show command).
>
> +set style even-lines foreground COLOR
> +set style even-lines background COLOR
> +set style even-lines intensity VALUE
> +set style odd-lines foreground COLOR
> +set style odd-lines background COLOR
> +set style odd-lines intensity VALUE
> + Control the styling of even and odd lines of tables. These style
> + settings are merged with any other style that would normally be
> + applied when displaying the table.
> +
> info proc environ
> Print the initial environment variables of the specified process.
> Supported on Linux.
I'm kind of hesitant to suggest it, (and only do so because it's easy
to just say please feel free to disregard this in its entirety)
One way I've liked to do this sort of thing rather than having
separate UI for even and odd rows, you can have one command
which sets an array of values. Then rather than alternating on
even/odd you just mod by the array length.
So you can set it to a solid color with one value, even/odd with two,
three, and rainbow if it suits your fancy.
I would suggest using python style arrays of dictionaries.
`set style zebra-table = [{"foreground": COLOR, "background", COLOR,
"intensity": VALUE}, ... ]`
I kind of like this because it turns out to be less UI commands, for a
more flexible effect.
alas, It probably requires some overhead in order to be able to have
UI taking python arrays, (or json values or whatever).
I'll leave it up to you whether you feel it's worth the chew or not, I
figure it doesn't hurt considering it...
prev parent reply other threads:[~2026-06-13 14:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-12 14:25 [PATCH 0/5] Add zebra-striping to CLI tables Tom Tromey
2026-06-12 14:25 ` [PATCH 1/5] Ensure tgetent is called before tgetnum Tom Tromey
2026-06-12 14:25 ` [PATCH 2/5] Make two ui_out methods 'private' Tom Tromey
2026-06-12 14:25 ` [PATCH 3/5] Allow "phony" ui-out tables Tom Tromey
2026-06-12 14:25 ` [PATCH 4/5] Add ui_file_style::merge Tom Tromey
2026-06-12 14:25 ` [PATCH 5/5] Add zebra-striping to CLI table display Tom Tromey
2026-06-12 15:14 ` Eli Zaretskii
2026-06-13 14:28 ` Matt Rice [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CACTLOFpRyE5eXtFY-2u=OS4qBAweWJJFR7HEbar5+FJ-91xgJw@mail.gmail.com' \
--to=ratmice@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox