linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH/RFC] perf ui/tui: Show column header in hist browser
@ 2014-01-15  5:08 Namhyung Kim
  2014-01-15 12:10 ` Jiri Olsa
  0 siblings, 1 reply; 5+ messages in thread
From: Namhyung Kim @ 2014-01-15  5:08 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, Namhyung Kim, LKML,
	Jiri Olsa, David Ahern

Add a line for showing column headers like --stdio.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/ui/browser.c        |  4 +--
 tools/perf/ui/browsers/hists.c | 55 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c
index d11541d4d7d7..441470ba8d2c 100644
--- a/tools/perf/ui/browser.c
+++ b/tools/perf/ui/browser.c
@@ -278,8 +278,8 @@ void ui_browser__hide(struct ui_browser *browser)
 static void ui_browser__scrollbar_set(struct ui_browser *browser)
 {
 	int height = browser->height, h = 0, pct = 0,
-	    col = browser->width,
-	    row = browser->y - 1;
+	    col = browser->width, row = 0;
+
 
 	if (browser->nr_entries > 1) {
 		pct = ((browser->index * (browser->height - 1)) /
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index e0ab399d431d..5b94de48f23c 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -25,6 +25,7 @@ struct hist_browser {
 	struct map_symbol   *selection;
 	int		     print_seq;
 	bool		     show_dso;
+	bool		     show_column_header;
 	float		     min_pcnt;
 	u64		     nr_pcnt_entries;
 };
@@ -312,6 +313,57 @@ static void ui_browser__warn_lost_events(struct ui_browser *browser)
 
 static void hist_browser__update_pcnt_entries(struct hist_browser *hb);
 
+static void hist_browser__column_header(struct hist_browser *browser)
+{
+	struct perf_hpp_fmt *fmt;
+	struct sort_entry *se;
+	struct hists *hists = browser->hists;
+	bool show = browser->show_column_header;
+	unsigned int width;
+
+	pthread_mutex_lock(&ui__lock);
+
+	if (!show)
+		goto out;
+
+	ui_browser__gotorc(&browser->b, 0, 0);
+
+	perf_hpp__for_each_format(fmt) {
+		char buf[128];
+		struct perf_hpp hpp = {
+			.buf	= buf,
+			.size	= sizeof(buf),
+			.ptr	= hists_to_evsel(hists),
+		};
+
+		width = fmt->width(fmt, &hpp);
+		fmt->header(fmt, &hpp);
+
+		slsmg_printf(" %-*s", width, hpp.buf);
+	}
+
+	list_for_each_entry(se, &hist_entry__sort_list, list) {
+		if (se->elide)
+			continue;
+
+		width = strlen(se->se_header);
+		if (!hists__new_col_len(hists, se->se_width_idx, width))
+			width = hists__col_len(hists, se->se_width_idx);
+
+		slsmg_printf("  %-*s", width, se->se_header);
+	}
+
+	/*
+	 * We just called ui_browser__refresh_dimensions().
+	 * Update it to honor a new column header line.
+	 */
+	browser->b.y++;
+	browser->b.height--;
+
+out:
+	pthread_mutex_unlock(&ui__lock);
+}
+
 static int hist_browser__run(struct hist_browser *browser, const char *ev_name,
 			     struct hist_browser_timer *hbt)
 {
@@ -331,6 +383,8 @@ static int hist_browser__run(struct hist_browser *browser, const char *ev_name,
 			     "Press '?' for help on key bindings") < 0)
 		return -1;
 
+	hist_browser__column_header(browser);
+
 	while (1) {
 		key = ui_browser__run(&browser->b, delay_secs);
 
@@ -1198,6 +1252,7 @@ static struct hist_browser *hist_browser__new(struct hists *hists)
 		browser->b.refresh = hist_browser__refresh;
 		browser->b.seek = ui_browser__hists_seek;
 		browser->b.use_navkeypressed = true;
+		browser->show_column_header = true;
 	}
 
 	return browser;
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-01-16  8:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-15  5:08 [PATCH/RFC] perf ui/tui: Show column header in hist browser Namhyung Kim
2014-01-15 12:10 ` Jiri Olsa
2014-01-15 14:13   ` Arnaldo Carvalho de Melo
2014-01-16  0:42     ` Namhyung Kim
2014-01-16  8:24       ` Jiri Olsa

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).