From: Taeung Song <treeze.taeung@gmail.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
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>,
Masami Hiramatsu <mhiramat@kernel.org>,
Wang Nan <wangnan0@huawei.com>,
Taeung Song <treeze.taeung@gmail.com>
Subject: [PATCH v8 4/7] perf config: Use combined {fore,back}ground colors value instead of each two color
Date: Mon, 5 Sep 2016 14:24:37 +0900 [thread overview]
Message-ID: <1473053080-23461-5-git-send-email-treeze.taeung@gmail.com> (raw)
In-Reply-To: <1473053080-23461-1-git-send-email-treeze.taeung@gmail.com>
To easily set default config values into actual variables for 'colors' config,
it would be better that actual variables for each 'colors' config
have only one value like 'default_config_item' type.
If we use combined {fore,back}ground colors values in ui_browser_colorset,
it smoothly work to initialize default config values for 'colors' config
by 'colors_config_items' array that contains default values for it at util/config.c.
because both actual variable and config item of 'colors_config_items'
are equal in the number of values (as just one).
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
---
tools/perf/ui/browser.c | 53 +++++++++++++++++++++++--------------------------
1 file changed, 25 insertions(+), 28 deletions(-)
diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c
index 3eb3edb..1c80f00 100644
--- a/tools/perf/ui/browser.c
+++ b/tools/perf/ui/browser.c
@@ -503,61 +503,53 @@ unsigned int ui_browser__list_head_refresh(struct ui_browser *browser)
}
static struct ui_browser_colorset {
- const char *name, *fg, *bg;
+ const char *name, *colors;
int colorset;
} ui_browser__colorsets[] = {
{
.colorset = HE_COLORSET_TOP,
.name = "top",
- .fg = "red",
- .bg = "default",
+ .colors = "red, default",
},
{
.colorset = HE_COLORSET_MEDIUM,
.name = "medium",
- .fg = "green",
- .bg = "default",
+ .colors = "green, default",
},
{
.colorset = HE_COLORSET_NORMAL,
.name = "normal",
- .fg = "default",
- .bg = "default",
+ .colors = "default, default",
},
{
.colorset = HE_COLORSET_SELECTED,
.name = "selected",
- .fg = "black",
- .bg = "yellow",
+ .colors = "black, yellow",
},
{
.colorset = HE_COLORSET_JUMP_ARROWS,
.name = "jump_arrows",
- .fg = "blue",
- .bg = "default",
+ .colors = "blue, default",
},
{
.colorset = HE_COLORSET_ADDR,
.name = "addr",
- .fg = "magenta",
- .bg = "default",
+ .colors = "magenta, default",
},
{
.colorset = HE_COLORSET_ROOT,
.name = "root",
- .fg = "white",
- .bg = "blue",
+ .colors = "white, blue",
},
{
.name = NULL,
}
};
-
static int ui_browser__color_config(const char *var, const char *value,
void *data __maybe_unused)
{
- char *fg = NULL, *bg;
+ char *colors;
int i;
/* same dir for all commands */
@@ -570,22 +562,18 @@ static int ui_browser__color_config(const char *var, const char *value,
if (strcmp(ui_browser__colorsets[i].name, name) != 0)
continue;
- fg = strdup(value);
- if (fg == NULL)
- break;
+ if (strstr(value, ",") == NULL)
+ return -1;
- bg = strchr(fg, ',');
- if (bg == NULL)
+ colors = strdup(value);
+ if (colors == NULL)
break;
+ ui_browser__colorsets[i].colors = colors;
- *bg = '\0';
- while (isspace(*++bg));
- ui_browser__colorsets[i].bg = bg;
- ui_browser__colorsets[i].fg = fg;
return 0;
}
- free(fg);
+ free(colors);
return -1;
}
@@ -743,8 +731,17 @@ void ui_browser__init(void)
perf_config(ui_browser__color_config, NULL);
while (ui_browser__colorsets[i].name) {
+ char *colors, *fg, *bg;
struct ui_browser_colorset *c = &ui_browser__colorsets[i++];
- sltt_set_color(c->colorset, c->name, c->fg, c->bg);
+
+ colors = strdup(c->colors);
+ if (colors == NULL)
+ break;
+ fg = strtok(colors, ",");
+ bg = strtok(NULL, ",");
+ bg = ltrim(bg);
+ sltt_set_color(c->colorset, c->name, fg, bg);
+ free(colors);
}
annotate_browser__init();
--
2.7.4
next prev parent reply other threads:[~2016-09-05 5:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-05 5:24 [PATCH v8 0/7] perf config: Introduce default config key-value pairs arrays Taeung Song
2016-09-05 5:24 ` [PATCH v8 1/7] perf config: Introduce default_config_section and default_config_item for default config key-value pairs Taeung Song
2016-09-05 5:24 ` [PATCH v8 2/7] perf config: Add macros assigning key-value pairs to default_config_item Taeung Song
2016-09-05 5:24 ` [PATCH v8 3/7] perf config: Add default section and item arrays for 'colors' config Taeung Song
2016-09-05 5:24 ` Taeung Song [this message]
2016-09-05 5:24 ` [PATCH v8 5/7] perf config: Initialize ui_browser__colorsets with default config items Taeung Song
2016-09-05 5:24 ` [PATCH v8 6/7] perf config: Add default section and item arrays for 'annotate' config Taeung Song
2016-09-05 5:24 ` [PATCH v8 7/7] perf config: Initialize annotate_browser__opts with default config items 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=1473053080-23461-5-git-send-email-treeze.taeung@gmail.com \
--to=treeze.taeung@gmail.com \
--cc=acme@kernel.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=wangnan0@huawei.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 NNTP newsgroup(s).