public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Taeung Song <treeze.taeung@gmail.com>
Cc: linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>
Subject: Re: [PATCH 3/4] perf config: Initialize ui_browser__colorsets with default config items
Date: Mon, 9 May 2016 14:19:43 -0300	[thread overview]
Message-ID: <20160509171943.GC13209@kernel.org> (raw)
In-Reply-To: <1462794109-14652-4-git-send-email-treeze.taeung@gmail.com>

Em Mon, May 09, 2016 at 08:41:48PM +0900, Taeung Song escreveu:
> Set default config values for 'colors' section with 'colors_config_items[]'
> instead of actual const char * type values.
> (e.g. using colors_config_item[CONFIG_COLORS_TOP].value
> instead of "red, default" string value for 'colors.top')

looks ok
 
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Jiri Olsa <jolsa@kernel.org>
> Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
> ---
>  tools/perf/ui/browser.c   | 46 ++++++++++++++++++++++++++++++++--------------
>  tools/perf/ui/browser.h   |  1 +
>  tools/perf/ui/tui/setup.c |  1 +
>  tools/perf/util/cache.h   |  1 +
>  tools/perf/util/config.h  | 12 ++++++++++++
>  5 files changed, 47 insertions(+), 14 deletions(-)
> 
> diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c
> index a477867..385d0de 100644
> --- a/tools/perf/ui/browser.c
> +++ b/tools/perf/ui/browser.c
> @@ -509,44 +509,30 @@ static struct ui_browser_colorset {
>  	{
>  		.colorset = HE_COLORSET_TOP,
>  		.name	  = "top",
> -		.fg	  = "red",
> -		.bg	  = "default",
>  	},
>  	{
>  		.colorset = HE_COLORSET_MEDIUM,
>  		.name	  = "medium",
> -		.fg	  = "green",
> -		.bg	  = "default",
>  	},
>  	{
>  		.colorset = HE_COLORSET_NORMAL,
>  		.name	  = "normal",
> -		.fg	  = "default",
> -		.bg	  = "default",
>  	},
>  	{
>  		.colorset = HE_COLORSET_SELECTED,
>  		.name	  = "selected",
> -		.fg	  = "black",
> -		.bg	  = "yellow",
>  	},
>  	{
>  		.colorset = HE_COLORSET_JUMP_ARROWS,
>  		.name	  = "jump_arrows",
> -		.fg	  = "blue",
> -		.bg	  = "default",
>  	},
>  	{
>  		.colorset = HE_COLORSET_ADDR,
>  		.name	  = "addr",
> -		.fg	  = "magenta",
> -		.bg	  = "default",
>  	},
>  	{
>  		.colorset = HE_COLORSET_ROOT,
>  		.name	  = "root",
> -		.fg	  = "white",
> -		.bg	  = "blue",
>  	},
>  	{
>  		.name = NULL,
> @@ -591,6 +577,7 @@ static int ui_browser__color_config(const char *var, const char *value,
>  		if (strcmp(ui_browser__colorsets[i].name, name) != 0)
>  			continue;
>  
> +		zfree((char **)&ui_browser__colorsets[i].fg);
>  		ret = ui_browser__config_gcolors(&ui_browser__colorsets[i], value);
>  		break;
>  	}
> @@ -745,10 +732,41 @@ void __ui_browser__line_arrow(struct ui_browser *browser, unsigned int column,
>  		__ui_browser__line_arrow_down(browser, column, start, end);
>  }
>  
> +static void ui_browser__free_color_configs(void)
> +{
> +	int i;
> +
> +	for (i = 0; ui_browser__colorsets[i].name != NULL; ++i)
> +		zfree((char **)&ui_browser__colorsets[i].fg);
> +}
> +
> +void ui_browser__free(void)
> +{
> +	ui_browser__free_color_configs();
> +}
> +
> +static void ui_browser__init_colorsets(void)
> +{
> +	int i, j;
> +
> +	for (i = 0; ui_browser__colorsets[i].name != NULL; ++i) {
> +		const char *name = ui_browser__colorsets[i].name;
> +
> +		for (j = 0; colors_config_items[j].name != NULL; j++) {
> +			if (!strcmp(name, colors_config_items[j].name)) {
> +				ui_browser__config_gcolors(&ui_browser__colorsets[i],
> +							   colors_config_items[j].value.s);
> +				break;
> +			}
> +		}
> +	}
> +}
> +
>  void ui_browser__init(void)
>  {
>  	int i = 0;
>  
> +	ui_browser__init_colorsets();
>  	perf_config(ui_browser__color_config, NULL);
>  
>  	while (ui_browser__colorsets[i].name) {
> diff --git a/tools/perf/ui/browser.h b/tools/perf/ui/browser.h
> index be3b70e..7a83a1a 100644
> --- a/tools/perf/ui/browser.h
> +++ b/tools/perf/ui/browser.h
> @@ -74,5 +74,6 @@ void ui_browser__list_head_seek(struct ui_browser *browser, off_t offset, int wh
>  unsigned int ui_browser__list_head_refresh(struct ui_browser *browser);
>  
>  void ui_browser__init(void);
> +void ui_browser__free(void);
>  void annotate_browser__init(void);
>  #endif /* _PERF_UI_BROWSER_H_ */
> diff --git a/tools/perf/ui/tui/setup.c b/tools/perf/ui/tui/setup.c
> index 7dfeba0..7999a57 100644
> --- a/tools/perf/ui/tui/setup.c
> +++ b/tools/perf/ui/tui/setup.c
> @@ -171,4 +171,5 @@ void ui__exit(bool wait_for_ok)
>  	SLang_reset_tty();
>  
>  	perf_error__unregister(&perf_tui_eops);
> +	ui_browser__free();
>  }
> diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h
> index 1f5a93c..8eab653 100644
> --- a/tools/perf/util/cache.h
> +++ b/tools/perf/util/cache.h
> @@ -7,6 +7,7 @@
>  #include <subcmd/pager.h>
>  #include "../perf.h"
>  #include "../ui/ui.h"
> +#include "config.h"
>  
>  #include <linux/string.h>
>  
> diff --git a/tools/perf/util/config.h b/tools/perf/util/config.h
> index 84414af..e0c8392 100644
> --- a/tools/perf/util/config.h
> +++ b/tools/perf/util/config.h
> @@ -44,6 +44,16 @@ struct perf_config_set {
>  	struct list_head sections;
>  };
>  
> +enum colors_config_items_idx {
> +	CONFIG_COLORS_TOP,
> +	CONFIG_COLORS_MEDIUM,
> +	CONFIG_COLORS_NORMAL,
> +	CONFIG_COLORS_SELECTED,
> +	CONFIG_COLORS_JUMP_ARROWS,
> +	CONFIG_COLORS_ADDR,
> +	CONFIG_COLORS_ROOT,
> +};
> +
>  #define CONF_VAR(_name, _field, _val, _type)			\
>  	{ .name = _name, .value._field = _val, .type = _type }
>  
> @@ -64,6 +74,8 @@ struct perf_config_set {
>  #define CONF_END()					\
>  	{ .name = NULL }
>  
> +extern const struct default_config_item colors_config_items[];
> +
>  struct perf_config_set *perf_config_set__new(void);
>  void perf_config_set__delete(struct perf_config_set *set);
>  
> -- 
> 2.5.0

  reply	other threads:[~2016-05-09 17:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-09 11:41 [PATCH 0/4] perf config: Introduce default config key-value pairs arrays Taeung Song
2016-05-09 11:41 ` [PATCH 1/4] perf config: Introduce default_config_item for all default config key-value pairs Taeung Song
2016-05-09 17:17   ` Arnaldo Carvalho de Melo
2016-05-10 11:49     ` Taeung Song
2016-05-10 15:05       ` Arnaldo Carvalho de Melo
2016-05-11 10:30         ` Taeung Song
2016-05-09 11:41 ` [PATCH 2/4] perf tools: Separate out code setting ground colors from ui_browser__color_config Taeung Song
2016-05-09 17:17   ` Arnaldo Carvalho de Melo
2016-05-10 11:33     ` Taeung Song
2016-05-09 11:41 ` [PATCH 3/4] perf config: Initialize ui_browser__colorsets with default config items Taeung Song
2016-05-09 17:19   ` Arnaldo Carvalho de Melo [this message]
2016-05-10 11:57     ` Taeung Song
2016-05-09 11:41 ` [PATCH 4/4] perf config: Initialize annotate_browser__opts " Taeung Song

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=20160509171943.GC13209@kernel.org \
    --to=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=treeze.taeung@gmail.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