[PATCH] perf hists browser: Move to prev/next column start by '<' or '>' keys
From: Namhyung Kim
Date: Sun Aug 09 2015 - 06:25:32 EST
Jiri said that it'd be more eye-friendly if it can move by column
widths. So change the keys to do it rather than jumping 10 characters.
Also add ',' and '.' keys which reside same position in the keyboard to
move by 1 characters.
Requested-by: Jiri Olsa <jolsa@xxxxxxxxxx>
Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
tools/perf/ui/browsers/hists.c | 53 +++++++++++++++++++++++++++++++++++++++---
1 file changed, 50 insertions(+), 3 deletions(-)
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 10af42f5283e..d62815965b50 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -20,7 +20,7 @@
#include "map.h"
#include "annotate.h"
-#define SKIP_COLS_STEP 10
+#define SKIP_COLS_STEP 1
struct hist_browser {
struct ui_browser b;
@@ -427,6 +427,45 @@ static void ui_browser__warn_lost_events(struct ui_browser *browser)
"Or reduce the sampling frequency.");
}
+static void hist_browser__prev_skip_cols(struct hist_browser *browser)
+{
+ int cols = 0;
+ int curr = 0;
+ struct perf_hpp_fmt *fmt;
+ struct perf_evsel *evsel = hists_to_evsel(browser->hists);
+
+ perf_hpp__for_each_format(fmt) {
+ if (perf_hpp__should_skip(fmt))
+ continue;
+
+ curr = fmt->width(fmt, NULL, evsel);
+ if (cols + curr + 2 >= browser->skip_cols) {
+ browser->skip_cols = cols;
+ break;
+ }
+
+ cols += curr + 2;
+ }
+}
+
+static void hist_browser__next_skip_cols(struct hist_browser *browser)
+{
+ int cols = 0;
+ struct perf_hpp_fmt *fmt;
+ struct perf_evsel *evsel = hists_to_evsel(browser->hists);
+
+ perf_hpp__for_each_format(fmt) {
+ if (perf_hpp__should_skip(fmt))
+ continue;
+
+ cols += fmt->width(fmt, NULL, evsel) + 2;
+ if (cols > browser->skip_cols) {
+ browser->skip_cols = cols;
+ break;
+ }
+ }
+}
+
static int hist_browser__run(struct hist_browser *browser, const char *help)
{
int key;
@@ -494,17 +533,25 @@ static int hist_browser__run(struct hist_browser *browser, const char *help)
browser->show_headers = !browser->show_headers;
hist_browser__update_rows(browser);
break;
- case '>':
+ case '.':
browser->skip_cols += SKIP_COLS_STEP;
browser->b.navkeypressed = true;
break;
- case '<':
+ case ',':
if (browser->skip_cols > SKIP_COLS_STEP)
browser->skip_cols -= SKIP_COLS_STEP;
else
browser->skip_cols = 0;
browser->b.navkeypressed = true;
break;
+ case '>':
+ hist_browser__next_skip_cols(browser);
+ browser->b.navkeypressed = true;
+ break;
+ case '<':
+ hist_browser__prev_skip_cols(browser);
+ browser->b.navkeypressed = true;
+ break;
case K_ENTER:
if (hist_browser__toggle_fold(browser))
break;
--
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/