diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-10-18 13:50:51 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-10-18 15:03:32 -0400 |
commit | e039fc727c40c5541bb22aed7f7030dea3e6fb7a (patch) | |
tree | 60b810a64a5acb68e5b37b375de08918f7cd6d3e | |
parent | cc6e7aa0afae3034c9b909b378394e757225e401 (diff) |
perf ui browser: Make the colors configurable and change the defaults
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>
-rw-r--r-- | tools/perf/Documentation/perfconfig.example | 20 | ||||
-rw-r--r-- | tools/perf/util/ui/browser.c | 99 |
2 files changed, 101 insertions, 18 deletions
diff --git a/tools/perf/Documentation/perfconfig.example b/tools/perf/Documentation/perfconfig.example new file mode 100644 index 000000000000..d1448668f4d4 --- /dev/null +++ b/tools/perf/Documentation/perfconfig.example | |||
@@ -0,0 +1,20 @@ | |||
1 | [colors] | ||
2 | |||
3 | # These were the old defaults | ||
4 | top = red, lightgray | ||
5 | medium = green, lightgray | ||
6 | normal = black, lightgray | ||
7 | selected = lightgray, magenta | ||
8 | code = blue, lightgray | ||
9 | |||
10 | [tui] | ||
11 | |||
12 | # Defaults if linked with libslang | ||
13 | report = on | ||
14 | annotate = on | ||
15 | top = on | ||
16 | |||
17 | [buildid] | ||
18 | |||
19 | # Default, disable using /dev/null | ||
20 | dir = /root/.debug | ||
diff --git a/tools/perf/util/ui/browser.c b/tools/perf/util/ui/browser.c index dce16ee43645..976b957f87c3 100644 --- a/tools/perf/util/ui/browser.c +++ b/tools/perf/util/ui/browser.c | |||
@@ -1,4 +1,5 @@ | |||
1 | #include "../util.h" | 1 | #include "../util.h" |
2 | #include "../cache.h" | ||
2 | #include "../../perf.h" | 3 | #include "../../perf.h" |
3 | #include "libslang.h" | 4 | #include "libslang.h" |
4 | #include <newt.h> | 5 | #include <newt.h> |
@@ -430,27 +431,89 @@ unsigned int ui_browser__list_head_refresh(struct ui_browser *self) | |||
430 | return row; | 431 | return row; |
431 | } | 432 | } |
432 | 433 | ||
433 | static struct ui_browser__colors { | 434 | static struct ui_browser__colorset { |
434 | const char *topColorFg, *topColorBg; | 435 | const char *name, *fg, *bg; |
435 | const char *mediumColorFg, *mediumColorBg; | 436 | int colorset; |
436 | const char *normalColorFg, *normalColorBg; | 437 | } ui_browser__colorsets[] = { |
437 | const char *selColorFg, *selColorBg; | 438 | { |
438 | const char *codeColorFg, *codeColorBg; | 439 | .colorset = HE_COLORSET_TOP, |
439 | } ui_browser__default_colors = { | 440 | .name = "top", |
440 | "red", "lightgray", | 441 | .fg = "red", |
441 | "green", "lightgray", | 442 | .bg = "black", |
442 | "black", "lightgray", | 443 | }, |
443 | "lightgray", "magenta", | 444 | { |
444 | "blue", "lightgray", | 445 | .colorset = HE_COLORSET_MEDIUM, |
446 | .name = "medium", | ||
447 | .fg = "green", | ||
448 | .bg = "black", | ||
449 | }, | ||
450 | { | ||
451 | .colorset = HE_COLORSET_NORMAL, | ||
452 | .name = "normal", | ||
453 | .fg = "brightgreen", | ||
454 | .bg = "black", | ||
455 | }, | ||
456 | { | ||
457 | .colorset = HE_COLORSET_SELECTED, | ||
458 | .name = "selected", | ||
459 | .fg = "black", | ||
460 | .bg = "lightgray", | ||
461 | }, | ||
462 | { | ||
463 | .colorset = HE_COLORSET_CODE, | ||
464 | .name = "code", | ||
465 | .fg = "blue", | ||
466 | .bg = "black", | ||
467 | }, | ||
468 | { | ||
469 | .name = NULL, | ||
470 | } | ||
445 | }; | 471 | }; |
446 | 472 | ||
473 | |||
474 | static int ui_browser__color_config(const char *var, const char *value, | ||
475 | void *data __used) | ||
476 | { | ||
477 | char *fg = NULL, *bg; | ||
478 | int i; | ||
479 | |||
480 | /* same dir for all commands */ | ||
481 | if (prefixcmp(var, "colors.") != 0) | ||
482 | return 0; | ||
483 | |||
484 | for (i = 0; ui_browser__colorsets[i].name != NULL; ++i) { | ||
485 | const char *name = var + 7; | ||
486 | |||
487 | if (strcmp(ui_browser__colorsets[i].name, name) != 0) | ||
488 | continue; | ||
489 | |||
490 | fg = strdup(value); | ||
491 | if (fg == NULL) | ||
492 | break; | ||
493 | |||
494 | bg = strchr(fg, ','); | ||
495 | if (bg == NULL) | ||
496 | break; | ||
497 | |||
498 | *bg = '\0'; | ||
499 | while (isspace(*++bg)); | ||
500 | ui_browser__colorsets[i].bg = bg; | ||
501 | ui_browser__colorsets[i].fg = fg; | ||
502 | return 0; | ||
503 | } | ||
504 | |||
505 | free(fg); | ||
506 | return -1; | ||
507 | } | ||
508 | |||
447 | void ui_browser__init(void) | 509 | void ui_browser__init(void) |
448 | { | 510 | { |
449 | struct ui_browser__colors *c = &ui_browser__default_colors; | 511 | int i = 0; |
450 | 512 | ||
451 | sltt_set_color(HE_COLORSET_TOP, NULL, c->topColorFg, c->topColorBg); | 513 | perf_config(ui_browser__color_config, NULL); |
452 | sltt_set_color(HE_COLORSET_MEDIUM, NULL, c->mediumColorFg, c->mediumColorBg); | 514 | |
453 | sltt_set_color(HE_COLORSET_NORMAL, NULL, c->normalColorFg, c->normalColorBg); | 515 | while (ui_browser__colorsets[i].name) { |
454 | sltt_set_color(HE_COLORSET_SELECTED, NULL, c->selColorFg, c->selColorBg); | 516 | struct ui_browser__colorset *c = &ui_browser__colorsets[i++]; |
455 | sltt_set_color(HE_COLORSET_CODE, NULL, c->codeColorFg, c->codeColorBg); | 517 | sltt_set_color(c->colorset, c->name, c->fg, c->bg); |
518 | } | ||
456 | } | 519 | } |