linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Ingo Molnar <mingo@elte.hu>,
	linux-kernel@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Mike Galbraith <efault@gmx.de>, Paul Mackerras <paulus@samba.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH 6/7] perf ui browser: Make the colors configurable and change the defaults
Date: Tue, 18 Oct 2011 17:13:49 -0600	[thread overview]
Message-ID: <4E9E082D.8040403@gmail.com> (raw)
In-Reply-To: <1318974247-6683-7-git-send-email-acme@infradead.org>



On 10/18/2011 03:44 PM, Arnaldo Carvalho de Melo wrote:
> From: Arnaldo Carvalho de Melo <acme@redhat.com>
> 
> Just use as a starting point the "[colors]" section of
> tools/perf/Documentation/perfconfig.example.
> 
> Changed the colors to be the ones in the old perf tool if used in a green on
> black xterm.
> 
> The next patches should allow using the colors configured for the xterm.
> 
> Cc: David Ahern <dsahern@gmail.com>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Mike Galbraith <efault@gmx.de>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Stephane Eranian <eranian@google.com>
> Link: http://lkml.kernel.org/n/tip-3vqmyerkaqltqolmnlehonew@git.kernel.org
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> ---
>  tools/perf/Documentation/perfconfig.example |   20 ++++++
>  tools/perf/util/ui/browser.c                |   99 ++++++++++++++++++++++-----
>  2 files changed, 101 insertions(+), 18 deletions(-)
>  create mode 100644 tools/perf/Documentation/perfconfig.example
> 
> diff --git a/tools/perf/Documentation/perfconfig.example b/tools/perf/Documentation/perfconfig.example
> new file mode 100644
> index 0000000..d144866
> --- /dev/null
> +++ b/tools/perf/Documentation/perfconfig.example
> @@ -0,0 +1,20 @@
> +[colors]
> +
> +	# These were the old defaults
> +	top = red, lightgray
> +	medium = green, lightgray
> +	normal = black, lightgray
> +	selected = lightgray, magenta
> +	code = blue, lightgray
> +
> +[tui]
> +
> +	# Defaults if linked with libslang
> +	report = on
> +	annotate = on
> +	top = on
> +
> +[buildid]
> +
> +	# Default, disable using /dev/null
> +	dir = /root/.debug
> diff --git a/tools/perf/util/ui/browser.c b/tools/perf/util/ui/browser.c
> index dce16ee..976b957 100644
> --- a/tools/perf/util/ui/browser.c
> +++ b/tools/perf/util/ui/browser.c
> @@ -1,4 +1,5 @@
>  #include "../util.h"
> +#include "../cache.h"
>  #include "../../perf.h"
>  #include "libslang.h"
>  #include <newt.h>
> @@ -430,27 +431,89 @@ unsigned int ui_browser__list_head_refresh(struct ui_browser *self)
>  	return row;
>  }
>  
> -static struct ui_browser__colors {
> -	const char *topColorFg, *topColorBg;
> -	const char *mediumColorFg, *mediumColorBg;
> -	const char *normalColorFg, *normalColorBg;
> -	const char *selColorFg, *selColorBg;
> -	const char *codeColorFg, *codeColorBg;
> -} ui_browser__default_colors = {
> -	"red",       "lightgray",
> -	"green",     "lightgray",
> -	"black",     "lightgray",
> -	"lightgray", "magenta",
> -	"blue",	     "lightgray",
> +static struct ui_browser__colorset {
> +	const char *name, *fg, *bg;
> +	int colorset;
> +} ui_browser__colorsets[] = {
> +	{
> +		.colorset = HE_COLORSET_TOP,
> +		.name	  = "top",
> +		.fg	  = "red",
> +		.bg	  = "black",
> +	},
> +	{
> +		.colorset = HE_COLORSET_MEDIUM,
> +		.name	  = "medium",
> +		.fg	  = "green",
> +		.bg	  = "black",
> +	},
> +	{
> +		.colorset = HE_COLORSET_NORMAL,
> +		.name	  = "normal",
> +		.fg	  = "brightgreen",
> +		.bg	  = "black",
> +	},

Using gnome3 with Fedora 15 these last 2 color sets don't look so good.
The 'black' background is not really black - more of a gray'ish look and
the green font does not show up well. Yes, I get that they are
configurable, but the defaults should be readable too.

David


> +	{
> +		.colorset = HE_COLORSET_SELECTED,
> +		.name	  = "selected",
> +		.fg	  = "black",
> +		.bg	  = "lightgray",
> +	},
> +	{
> +		.colorset = HE_COLORSET_CODE,
> +		.name	  = "code",
> +		.fg	  = "blue",
> +		.bg	  = "black",
> +	},
> +	{
> +		.name = NULL,
> +	}
>  };
>  
> +
> +static int ui_browser__color_config(const char *var, const char *value,
> +				    void *data __used)
> +{
> +	char *fg = NULL, *bg;
> +	int i;
> +
> +	/* same dir for all commands */
> +	if (prefixcmp(var, "colors.") != 0)
> +		return 0;
> +
> +	for (i = 0; ui_browser__colorsets[i].name != NULL; ++i) {
> +		const char *name = var + 7;
> +
> +		if (strcmp(ui_browser__colorsets[i].name, name) != 0)
> +			continue;
> +
> +		fg = strdup(value);
> +		if (fg == NULL)
> +			break;
> +
> +		bg = strchr(fg, ',');
> +		if (bg == NULL)
> +			break;
> +
> +		*bg = '\0';
> +		while (isspace(*++bg));
> +		ui_browser__colorsets[i].bg = bg;
> +		ui_browser__colorsets[i].fg = fg;
> +		return 0;
> +	}
> +
> +	free(fg);
> +	return -1;
> +}
> +
>  void ui_browser__init(void)
>  {
> -	struct ui_browser__colors *c = &ui_browser__default_colors;
> +	int i = 0;
>  
> -	sltt_set_color(HE_COLORSET_TOP, NULL, c->topColorFg, c->topColorBg);
> -	sltt_set_color(HE_COLORSET_MEDIUM, NULL, c->mediumColorFg, c->mediumColorBg);
> -	sltt_set_color(HE_COLORSET_NORMAL, NULL, c->normalColorFg, c->normalColorBg);
> -	sltt_set_color(HE_COLORSET_SELECTED, NULL, c->selColorFg, c->selColorBg);
> -	sltt_set_color(HE_COLORSET_CODE, NULL, c->codeColorFg, c->codeColorBg);
> +	perf_config(ui_browser__color_config, NULL);
> +
> +	while (ui_browser__colorsets[i].name) {
> +		struct ui_browser__colorset *c = &ui_browser__colorsets[i++];
> +		sltt_set_color(c->colorset, c->name, c->fg, c->bg);
> +	}
>  }

  reply	other threads:[~2011-10-18 23:13 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-18 21:44 [GIT PULL 0/7] perf/core fixes and improvements Arnaldo Carvalho de Melo
2011-10-18 21:44 ` [PATCH 1/7] perf hists browser: Add missing hotkeys to the help window Arnaldo Carvalho de Melo
2011-10-18 21:44 ` [PATCH 2/7] perf tui: Catch signals to exit gracefully Arnaldo Carvalho de Melo
2011-10-18 21:44 ` [PATCH 3/7] perf ui browser: Allow initial use without navigation UI elements Arnaldo Carvalho de Melo
2011-10-18 21:44 ` [PATCH 4/7] perf hists: Don't format the percentage on hist_entry__snprintf Arnaldo Carvalho de Melo
2011-10-18 21:44 ` [PATCH 5/7] perf tui: Remove unneeded call to newtCls on startup Arnaldo Carvalho de Melo
2011-10-18 21:44 ` [PATCH 6/7] perf ui browser: Make the colors configurable and change the defaults Arnaldo Carvalho de Melo
2011-10-18 23:13   ` David Ahern [this message]
2011-10-18 23:51     ` Arnaldo Carvalho de Melo
2011-10-19  1:12       ` Arnaldo Carvalho de Melo
2011-10-19  2:41         ` [PATCH] perf ui browser: Honour the xterm colors Arnaldo Carvalho de Melo
2011-10-19  3:03           ` David Ahern
2011-10-19 13:53             ` Arnaldo Carvalho de Melo
2011-10-18 21:44 ` [PATCH 7/7] perf top tui: Give color hints just on the percentage, like on --stdio Arnaldo Carvalho de Melo
2011-10-19  7:14 ` [GIT PULL 0/7] perf/core fixes and improvements Ingo Molnar
2011-10-19 14:14   ` Arnaldo Carvalho de Melo

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=4E9E082D.8040403@gmail.com \
    --to=dsahern@gmail.com \
    --cc=acme@ghostprotocols.net \
    --cc=acme@redhat.com \
    --cc=efault@gmx.de \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    /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 NNTP newsgroup(s).