Skip to contentSkip to conversation

perf ui browser: Move the extra title lines from the hists browser

tip:perf/urgent tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Apr 4, 2018 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  ef9ff6017e3c4593f3efa5776784cb417c58ad6c
Gitweb:     https://git.kernel.org/tip/ef9ff6017e3c4593f3efa5776784cb417c58ad6c
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Mon, 2 Apr 2018 15:48:18 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 3 Apr 2018 10:24:26 -0300

perf ui browser: Move the extra title lines from the hists browser

This will be useful for the annotate browser as well, that wants to have extra title lines, i.e. the current ui_browser unconditionally reserves the first line for a browser title and the last one for status messages.

But some browsers, like the buckets one (hists browser) needs extra lines to show headers, allowing it to be shown or not, press 'H' in 'perf top' or 'perf report' to see this feature.

So move that logic to the core ui_browser used by the hists_browser ('perf top' and 'perf report' main interface) so that it can be used by the annotate browser too.

Cc: Adrian Hunter <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Martin Liška <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Wang Nan <[email protected]>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196935

---
 tools/perf/ui/browser.c        |  8 +++++++-
 tools/perf/ui/browser.h        |  2 ++
 tools/perf/ui/browsers/hists.c | 43 +++++++++++++++++++++++-------------------
 3 files changed, 33 insertions(+), 20 deletions(-)
tools/perf/ui/browser.c +7 -1
index 9f6ce29b83b4..d7bb2591838e 100644
@@ -45,11 +45,16 @@ void ui_browser__set_percent_color(struct ui_browser *browser,
 	 ui_browser__set_color(browser, color);
 }
 
-void ui_browser__gotorc(struct ui_browser *browser, int y, int x)
+void ui_browser__gotorc_title(struct ui_browser *browser, int y, int x)
 {
 	SLsmg_gotorc(browser->y + y, browser->x + x);
 }
 
+void ui_browser__gotorc(struct ui_browser *browser, int y, int x)
+{
+	SLsmg_gotorc(browser->y + y + browser->extra_title_lines, browser->x + x);
+}
+
 void ui_browser__write_nstring(struct ui_browser *browser __maybe_unused, const char *msg,
 			       unsigned int width)
 {
@@ -191,6 +196,7 @@ void ui_browser__refresh_dimensions(struct ui_browser *browser)
 {
 	browser->width = SLtt_Screen_Cols - 1;
 	browser->height = browser->rows = SLtt_Screen_Rows - 2;
+	browser->rows -= browser->extra_title_lines;
 	browser->y = 1;
 	browser->x = 0;
 }
tools/perf/ui/browser.h +2 -0
index 70057178ee34..aa5932e1d62e 100644
@@ -17,6 +17,7 @@ struct ui_browser {
 	u64	      index, top_idx;
 	void	      *top, *entries;
 	u16	      y, x, width, height, rows, columns, horiz_scroll;
+	u8	      extra_title_lines;
 	int	      current_color;
 	void	      *priv;
 	const char    *title;
@@ -38,6 +39,7 @@ bool ui_browser__is_current_entry(struct ui_browser *browser, unsigned row);
 void ui_browser__refresh_dimensions(struct ui_browser *browser);
 void ui_browser__reset_index(struct ui_browser *browser);
 
+void ui_browser__gotorc_title(struct ui_browser *browser, int y, int x);
 void ui_browser__gotorc(struct ui_browser *browser, int y, int x);
 void ui_browser__write_nstring(struct ui_browser *browser, const char *msg,
 			       unsigned int width);
tools/perf/ui/browsers/hists.c +24 -19

98 lines not on this page · raw message