This is the mail archive of the
mailing list for the GDB project.
Re: ui_out format strings for fields and styles (Re: [PATCH] Style "pwd" output)
- From: Philippe Waroquiers <philippe dot waroquiers at skynet dot be>
- To: Tom Tromey <tom at tromey dot com>, Pedro Alves <palves at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 01 Jul 2019 21:32:41 +0200
- Subject: Re: ui_out format strings for fields and styles (Re: [PATCH] Style "pwd" output)
- References: <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org>
On Mon, 2019-07-01 at 06:25 -0600, Tom Tromey wrote:
> > > > > > "Pedro" == Pedro Alves <email@example.com> writes:
> Pedro> Do you still see value in keeping %pN? If we make nullptr mean
> Pedro> "keep the default", as you mentioned earlier, then the above can be
> Pedro> rewritten as:
> Pedro> fprintf_filtered (stream, " %pS<repeats %u times>%pS",
> Pedro> metadata_style.style ().ptr (), reps, nullptr);
> I was thinking that we'd change the spelling to some form of brackets,
> in which case it would be good. So like "%p[<repeats %u times>%p]".
> We discussed this before but I don't recall whether there was some
> counter-argument to it.
(Arriving late in the discussion ...)
If we have some markers/brackets in the format string to apply style,
why do we keep the style as an additional parameter of the 'printf' like functions ?
E.g. when looking at pango markup, changing the 'style' is done inside the string,
such as :
"<span foreground=red>some string with red foreground</span>"
So, for GDB, we could have something like:
some_output_function ("The filename is <style=filename>%s</style>.", some_filename);
where the low level of some_output_function would translate the <style=..> into
the real output of the control characters to do the styling.
The advantage of this approach is that the styling can be added for example
in the doc strings either statically and/or built dynamically
(think for example to the new option framework that builds a part of the doc
string: we might e.g. put in bold the part of the option that is 'unique').
> If we're just using letters, then there doesn't seem to be a reason to
> have two %p suffixes.