Skip to content

Commit

Permalink
perf ui stdio: Add way to setup the color output mode selection
Browse files Browse the repository at this point in the history
In --stdio we turn off color output when the output is not a tty,
which is not always desirable, for instance, in:

  perf annotate | more

the 'more' tool is perfectly capable of processing the escape sequences
for colored output.

Allow using the existing logic for .perfconfig's "color.ui" to be used
from the command line by providing a stdio__config_color() helper, that
will be used by annotate and report in follow up patches.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-1u4wjdbcc41dxndsb4klpa9y@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Arnaldo Carvalho de Melo committed Jul 12, 2016
1 parent a505197 commit c09615f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tools/perf/ui/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ static inline int setup_gtk_browser(void) { return -1; }
static inline void exit_gtk_browser(bool wait_for_ok __maybe_unused) {}
#endif

int stdio__config_color(const struct option *opt __maybe_unused,
const char *mode, int unset __maybe_unused)
{
perf_use_color_default = perf_config_colorbool("color.ui", mode, -1);
return 0;
}

void setup_browser(bool fallback_to_pager)
{
if (use_browser < 2 && (!isatty(1) || dump_trace))
Expand Down
4 changes: 4 additions & 0 deletions tools/perf/ui/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ static inline void ui__exit(bool wait_for_ok __maybe_unused) {}

void ui__refresh_dimensions(bool force);

struct option;

int stdio__config_color(const struct option *opt, const char *mode, int unset);

#endif /* _PERF_UI_H_ */

0 comments on commit c09615f

Please sign in to comment.