From: Jiri Olsa <jolsa@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Jiri Olsa <jolsa@kernel.org>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Corey Ashford <cjashfor@linux.vnet.ibm.com>,
David Ahern <dsahern@gmail.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Ingo Molnar <mingo@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Paul Mackerras <paulus@samba.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [PATCH 4/4] perf tools tui: Display columns header text on 'H' press
Date: Sun, 15 Jun 2014 18:53:23 +0200 [thread overview]
Message-ID: <1402851203-3083-5-git-send-email-jolsa@kernel.org> (raw)
In-Reply-To: <1402851203-3083-1-git-send-email-jolsa@kernel.org>
Displaying columns header text whenever 'H' is pressed,
and hiding it on on another press.
Note I removed the original width setup pcode code in
hist_browser__refresh_dimensions function, because it
was never used and overwritten by ui_browser setup.
Also all the TUI output expect width ot be the current
terminal width.
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/ui/browsers/hists.c | 78 ++++++++++++++++++++++++++++++++++++++++--
1 file changed, 75 insertions(+), 3 deletions(-)
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 6aeed29..88adbbe 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -26,6 +26,7 @@ struct hist_browser {
struct map_symbol *selection;
int print_seq;
bool show_dso;
+ bool show_headers;
float min_pcnt;
u64 nr_non_filtered_entries;
u64 nr_callchain_rows;
@@ -58,9 +59,13 @@ static u32 hist_browser__nr_entries(struct hist_browser *hb)
static void hist_browser__refresh_dimensions(struct hist_browser *browser)
{
- /* 3 == +/- toggle symbol before actual hist_entry rendering */
- browser->b.width = 3 + (hists__sort_list_width(browser->hists) +
- sizeof("[k]"));
+ u16 header = browser->show_headers ? 1 : 0;
+
+ ui_browser__refresh_dimensions(&browser->b);
+
+ /* shrink view size if there are headers displayed */
+ browser->b.height = SLtt_Screen_Rows - 2 - header;
+ browser->b.y = 1 + header;
}
static void hist_browser__reset(struct hist_browser *browser)
@@ -409,6 +414,10 @@ static int hist_browser__run(struct hist_browser *browser,
/* Expand the whole world. */
hist_browser__set_folding(browser, true);
break;
+ case 'H':
+ browser->show_headers = !browser->show_headers;
+ hist_browser__refresh_dimensions(browser);
+ continue;
case K_ENTER:
if (hist_browser__toggle_fold(browser))
break;
@@ -787,6 +796,65 @@ static int hist_browser__show_entry(struct hist_browser *browser,
return printed;
}
+static int advance_hpp_check(struct perf_hpp *hpp, int inc)
+{
+ advance_hpp(hpp, inc);
+ return hpp->size <= 0;
+}
+
+static int hists__scnprintf_headers(char *buf, size_t size, struct hists *hists)
+{
+ struct perf_hpp dummy_hpp = {
+ .buf = buf,
+ .size = size,
+ };
+ struct perf_hpp_fmt *fmt;
+ size_t ret = 0;
+
+ if (symbol_conf.use_callchain) {
+ ret = scnprintf(buf, size, " ");
+ if (advance_hpp_check(&dummy_hpp, ret))
+ return ret;
+ }
+
+ perf_hpp__for_each_format(fmt) {
+ if (perf_hpp__should_skip(fmt))
+ continue;
+
+ /* We need to add the length of the columns header. */
+ perf_hpp__reset_width(fmt, hists);
+
+ ret = fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists));
+ if (advance_hpp_check(&dummy_hpp, ret))
+ break;
+
+ ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, " ");
+ if (advance_hpp_check(&dummy_hpp, ret))
+ break;
+ }
+
+ return ret;
+}
+
+static void ui_browser__show_headers(struct ui_browser *b, char *headers)
+{
+ SLsmg_gotorc(1, 0);
+ ui_browser__set_color(b, HE_COLORSET_ROOT);
+ slsmg_write_nstring(headers, b->width + 1);
+}
+
+static void hist_browser__show_headers(struct hist_browser *hb)
+{
+ static char buf[1024], *headers;
+
+ if (!headers) {
+ hists__scnprintf_headers(buf, sizeof(buf), hb->hists);
+ headers = buf;
+ }
+
+ ui_browser__show_headers(&hb->b, headers);
+}
+
static void ui_browser__hists_init_top(struct ui_browser *browser)
{
if (browser->top == NULL) {
@@ -803,6 +871,9 @@ static unsigned int hist_browser__refresh(struct ui_browser *browser)
struct rb_node *nd;
struct hist_browser *hb = container_of(browser, struct hist_browser, b);
+ if (hb->show_headers)
+ hist_browser__show_headers(hb);
+
ui_browser__hists_init_top(browser);
for (nd = browser->top; nd; nd = rb_next(nd)) {
@@ -1421,6 +1492,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
"d Zoom into current DSO\n" \
"E Expand all callchains\n" \
"F Toggle percentage of filtered entries\n" \
+ "H Display column headers\n" \
/* help messages are sorted by lexical order of the hotkey */
const char report_help[] = HIST_BROWSER_HELP_COMMON
--
1.8.3.1
next prev parent reply other threads:[~2014-06-15 16:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-15 16:53 [PATCH 0/4] perf tools tui: Display columns headers Jiri Olsa
2014-06-15 16:53 ` [PATCH 1/4] perf tools: Factor ui_browser ops out of ui_browser struct Jiri Olsa
2014-06-15 16:53 ` [PATCH 2/4] perf tools: Remove ev_name argument from perf_evsel__hists_browse Jiri Olsa
2014-06-15 16:53 ` [PATCH 3/4] perf tools: Fix scrollbar refresh row index Jiri Olsa
2014-06-15 16:53 ` Jiri Olsa [this message]
2014-06-19 5:18 ` [PATCH 0/4] perf tools tui: Display columns headers Namhyung Kim
2014-06-19 10:41 ` Jiri Olsa
2014-06-19 15:36 ` Arnaldo Carvalho de Melo
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=1402851203-3083-5-git-send-email-jolsa@kernel.org \
--to=jolsa@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=cjashfor@linux.vnet.ibm.com \
--cc=dsahern@gmail.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=paulus@samba.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.