Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754670AbcK1IwU (ORCPT ); Mon, 28 Nov 2016 03:52:20 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:36239 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754606AbcK1Ivj (ORCPT ); Mon, 28 Nov 2016 03:51:39 -0500 From: Taeung Song To: Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, Jiri Olsa , Namhyung Kim , Ingo Molnar , Peter Zijlstra , Wang Nan , Taeung Song Subject: [PATCH v9 5/7] perf config: Initialize ui_browser__colorsets with default config items Date: Mon, 28 Nov 2016 17:51:16 +0900 Message-Id: <1480323078-15623-6-git-send-email-treeze.taeung@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1480323078-15623-1-git-send-email-treeze.taeung@gmail.com> References: <1480323078-15623-1-git-send-email-treeze.taeung@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2185 Lines: 86 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.s instead of "red, default" string value for 'colors.top') Cc: Namhyung Kim Cc: Jiri Olsa Cc: Wang Nan Signed-off-by: Taeung Song --- tools/perf/ui/browser.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c index 1c80f00..5caa7e4 100644 --- a/tools/perf/ui/browser.c +++ b/tools/perf/ui/browser.c @@ -509,37 +509,30 @@ static struct ui_browser_colorset { { .colorset = HE_COLORSET_TOP, .name = "top", - .colors = "red, default", }, { .colorset = HE_COLORSET_MEDIUM, .name = "medium", - .colors = "green, default", }, { .colorset = HE_COLORSET_NORMAL, .name = "normal", - .colors = "default, default", }, { .colorset = HE_COLORSET_SELECTED, .name = "selected", - .colors = "black, yellow", }, { .colorset = HE_COLORSET_JUMP_ARROWS, .name = "jump_arrows", - .colors = "blue, default", }, { .colorset = HE_COLORSET_ADDR, .name = "addr", - .colors = "magenta, default", }, { .colorset = HE_COLORSET_ROOT, .name = "root", - .colors = "white, blue", }, { .name = NULL, @@ -724,10 +717,28 @@ void __ui_browser__line_arrow(struct ui_browser *browser, unsigned int column, __ui_browser__line_arrow_down(browser, column, start, end); } +static void default_colors_config_init(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__colorsets[i].colors = + colors_config_items[j].value.s; + break; + } + } + } +} + void ui_browser__init(void) { int i = 0; + default_colors_config_init(); perf_config(ui_browser__color_config, NULL); while (ui_browser__colorsets[i].name) { -- 2.7.4