public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [RFC 3/8] Add output styles to gdb
Date: Sat, 06 Oct 2018 15:53:00 -0000	[thread overview]
Message-ID: <c8c21df4-5ce3-2bec-72cb-bb14255d31ae@simark.ca> (raw)
In-Reply-To: <20180906211303.11029-4-tom@tromey.com>

On 2018-09-06 5:12 p.m., Tom Tromey wrote:
> This adds some output styling to the CLI.
> 
> A style is currently a foreground color, a background color, and an
> intensity (dim or bold).  (This list could be expanded depending on
> terminal capabilities.)
> 
> A style can be applied while printing.  This patch changes cli-out.c
> to apply styles just to certain fields, recognized by name.  In
> particular, function names and file names are stylized.
> 
> This seemed like a reasonable approach, because the names are fixed
> due to their use in MI.  That is, the CLI is just as exposed to future
> changes as MI is.
> 
> Users can control the style via a number of new set/show commands.  In
> the interest of not typing many nearly-identical documentation
> strings, I automated this.  On the down side, this is not very
> i18n-friendly.
> 
> I've chose some default colors to use.  I think it would be good to
> enable this by default, so that when users start the new gdb, they
> will see the new feature.
> 
> Stylizing is done if TERM is set and is not "dumb".  This could be
> improved when the TUI is available by using the curses has_colors
> call.  That is, the lowest layer could call this without committing to
> using curses everywhere; see my other patch for TUI colorizing.
> 
> I considered adding a new "set_style" method to ui_file.  However,
> because the implementation had to interact with the pager code, I
> didn't take this approach.  But, one idea might be to put the isatty
> check there and then have it defer to the lower layers.

Hi Tom,

Overall this looks great.  I'm not too worried about internationalization.
I think in this case for example:

  _("The \"%s\" display intensity is: %s\n"), name, value

If "name" corresponds to a field name or sub-command name (like "filename"),
it's probably better to leave it in english.  If it refers to the concept
of a filename, then we would want to translate it.

In the latter case, I guess we could do it in two steps, and also pass the value
through gettext:

  std::string tmpl = string_printf ("The %s display intensity is: %%s\n", name);
  printf (_(tmpl.c_str ()), _(value));

So tmpl would contain "The filename display intensity is: %s\n", which could be
looked up by gettext to something that has the proper translation for "filename".
Then, the color name would be translated too.

Or maybe I don't understand how gettext works.


I'm just not sure about choosing styles using the field name.  For a filename, you could
have a bunch of different field names, file filename, original_filename, absolute_filename,
etc.  So it can quickly become a bit crowded here.

Could we pass an additional enum parameter to do_field_string to indicate the type of
element this field represents?  If this parameter has a default value of "NOTHING",
then we can add then incrementally.  Or it can even be an hybrid approach, where we
try to match field names, which works 95% of the time, and then have this enum parameter
to override the auto-detection if needed.

Simon

  reply	other threads:[~2018-10-06 15:53 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-06 21:13 [RFC 0/8] add terminal styling " Tom Tromey
2018-09-06 21:13 ` [RFC 4/8] Add variable name styling Tom Tromey
2018-10-06 16:34   ` Simon Marchi
2018-09-06 21:13 ` [RFC 6/8] Style print_address_symbolic Tom Tromey
2018-09-06 21:13 ` [RFC 2/8] Add a "context" argument to add_setshow_enum_cmd Tom Tromey
2018-09-06 21:13 ` [RFC 1/8] Change wrap buffering to use a std::string Tom Tromey
2018-10-06 15:19   ` Simon Marchi
2018-10-08 22:04     ` Tom Tromey
2018-10-18 22:16       ` Tom Tromey
2018-09-06 21:13 ` [RFC 7/8] Style the gdb welcome message Tom Tromey
2018-09-06 21:13 ` [RFC 3/8] Add output styles to gdb Tom Tromey
2018-10-06 15:53   ` Simon Marchi [this message]
2018-10-06 19:06     ` Tom Tromey
2018-10-07 21:58       ` Simon Marchi
2018-10-08  0:23         ` Tom Tromey
2018-10-08  2:02           ` Simon Marchi
2018-10-08  2:49             ` Tom Tromey
2018-10-08 11:10               ` Simon Marchi
2018-10-08 22:17                 ` Tom Tromey
2018-09-06 21:14 ` [RFC 5/8] Style locations when setting a breakpoint Tom Tromey
2018-10-06 16:36   ` Simon Marchi
2018-09-06 21:14 ` [RFC 8/8] Style the "Reading symbols" message Tom Tromey
2018-09-07  6:23 ` [RFC 0/8] add terminal styling to gdb Eli Zaretskii
2018-09-07 14:36   ` Tom Tromey
2018-09-07 14:56     ` Eli Zaretskii
2018-09-07 15:01       ` Eli Zaretskii
2018-09-07  7:25 ` Joel Brobecker
2018-10-04 13:11 ` Tom Tromey

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=c8c21df4-5ce3-2bec-72cb-bb14255d31ae@simark.ca \
    --to=simark@simark.ca \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).