aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-10-18 12:31:35 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-10-18 15:02:56 -0400
commitc172f7422c03463a7177e268ffe625c41c42c179 (patch)
tree5c07c77cf5b8b0176723b499ddcf1d9f4e54d6c9 /tools
parent3f7247e0725de9643ce5a02b082c81c617476fd5 (diff)
perf ui browser: Allow initial use without navigation UI elements
The selection and scroll bar are really needed only when the user starts navigating, before that it just provide distractions. This also brings the initial screen to look more like the stdio UI, which more people are used to. The new code is flexible enough that menu like browsers can opt out and start with those UI elements. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-jfgok30kkerpfw8wtcltgy6z@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/ui/browser.c28
-rw-r--r--tools/perf/util/ui/browser.h2
-rw-r--r--tools/perf/util/ui/browsers/annotate.c6
-rw-r--r--tools/perf/util/ui/browsers/hists.c20
4 files changed, 39 insertions, 17 deletions
diff --git a/tools/perf/util/ui/browser.c b/tools/perf/util/ui/browser.c
index a54b926efe2b..dce16ee43645 100644
--- a/tools/perf/util/ui/browser.c
+++ b/tools/perf/util/ui/browser.c
@@ -14,9 +14,10 @@
14 14
15int newtGetKey(void); 15int newtGetKey(void);
16 16
17static int ui_browser__percent_color(double percent, bool current) 17static int ui_browser__percent_color(struct ui_browser *browser,
18 double percent, bool current)
18{ 19{
19 if (current) 20 if (current && (!browser->use_navkeypressed || browser->navkeypressed))
20 return HE_COLORSET_SELECTED; 21 return HE_COLORSET_SELECTED;
21 if (percent >= MIN_RED) 22 if (percent >= MIN_RED)
22 return HE_COLORSET_TOP; 23 return HE_COLORSET_TOP;
@@ -33,7 +34,7 @@ void ui_browser__set_color(struct ui_browser *self __used, int color)
33void ui_browser__set_percent_color(struct ui_browser *self, 34void ui_browser__set_percent_color(struct ui_browser *self,
34 double percent, bool current) 35 double percent, bool current)
35{ 36{
36 int color = ui_browser__percent_color(percent, current); 37 int color = ui_browser__percent_color(self, percent, current);
37 ui_browser__set_color(self, color); 38 ui_browser__set_color(self, color);
38} 39}
39 40
@@ -241,12 +242,18 @@ static void ui_browser__scrollbar_set(struct ui_browser *browser)
241static int __ui_browser__refresh(struct ui_browser *browser) 242static int __ui_browser__refresh(struct ui_browser *browser)
242{ 243{
243 int row; 244 int row;
245 int width = browser->width;
244 246
245 row = browser->refresh(browser); 247 row = browser->refresh(browser);
246 ui_browser__set_color(browser, HE_COLORSET_NORMAL); 248 ui_browser__set_color(browser, HE_COLORSET_NORMAL);
249
250 if (!browser->use_navkeypressed || browser->navkeypressed)
251 ui_browser__scrollbar_set(browser);
252 else
253 width += 1;
254
247 SLsmg_fill_region(browser->y + row, browser->x, 255 SLsmg_fill_region(browser->y + row, browser->x,
248 browser->height - row, browser->width, ' '); 256 browser->height - row, width, ' ');
249 ui_browser__scrollbar_set(browser);
250 257
251 return 0; 258 return 0;
252} 259}
@@ -326,6 +333,17 @@ int ui_browser__run(struct ui_browser *self, int delay_secs)
326 continue; 333 continue;
327 } 334 }
328 335
336 if (self->use_navkeypressed && !self->navkeypressed) {
337 if (key == NEWT_KEY_DOWN || key == NEWT_KEY_UP ||
338 key == NEWT_KEY_PGDN || key == NEWT_KEY_PGUP ||
339 key == NEWT_KEY_HOME || key == NEWT_KEY_END ||
340 key == ' ') {
341 self->navkeypressed = true;
342 continue;
343 } else
344 return key;
345 }
346
329 switch (key) { 347 switch (key) {
330 case NEWT_KEY_DOWN: 348 case NEWT_KEY_DOWN:
331 if (self->index == self->nr_entries - 1) 349 if (self->index == self->nr_entries - 1)
diff --git a/tools/perf/util/ui/browser.h b/tools/perf/util/ui/browser.h
index 351c006dd4b5..a2c707d33c5e 100644
--- a/tools/perf/util/ui/browser.h
+++ b/tools/perf/util/ui/browser.h
@@ -23,6 +23,8 @@ struct ui_browser {
23 void (*seek)(struct ui_browser *self, off_t offset, int whence); 23 void (*seek)(struct ui_browser *self, off_t offset, int whence);
24 bool (*filter)(struct ui_browser *self, void *entry); 24 bool (*filter)(struct ui_browser *self, void *entry);
25 u32 nr_entries; 25 u32 nr_entries;
26 bool navkeypressed;
27 bool use_navkeypressed;
26}; 28};
27 29
28void ui_browser__set_color(struct ui_browser *self, int color); 30void ui_browser__set_color(struct ui_browser *self, int color);
diff --git a/tools/perf/util/ui/browsers/annotate.c b/tools/perf/util/ui/browsers/annotate.c
index eb2712ecb601..a2c351cf23eb 100644
--- a/tools/perf/util/ui/browsers/annotate.c
+++ b/tools/perf/util/ui/browsers/annotate.c
@@ -69,6 +69,11 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
69 69
70 SLsmg_write_char(':'); 70 SLsmg_write_char(':');
71 slsmg_write_nstring(" ", 8); 71 slsmg_write_nstring(" ", 8);
72
73 /* The scroll bar isn't being used */
74 if (!self->navkeypressed)
75 width += 1;
76
72 if (!*ol->line) 77 if (!*ol->line)
73 slsmg_write_nstring(" ", width - 18); 78 slsmg_write_nstring(" ", width - 18);
74 else 79 else
@@ -386,6 +391,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
386 .write = annotate_browser__write, 391 .write = annotate_browser__write,
387 .filter = objdump_line__filter, 392 .filter = objdump_line__filter,
388 .priv = &ms, 393 .priv = &ms,
394 .use_navkeypressed = true,
389 }, 395 },
390 }; 396 };
391 int ret; 397 int ret;
diff --git a/tools/perf/util/ui/browsers/hists.c b/tools/perf/util/ui/browsers/hists.c
index 873b852e914e..2d390b9cb63e 100644
--- a/tools/perf/util/ui/browsers/hists.c
+++ b/tools/perf/util/ui/browsers/hists.c
@@ -547,7 +547,7 @@ static int hist_browser__show_entry(struct hist_browser *self,
547 char s[256]; 547 char s[256];
548 double percent; 548 double percent;
549 int printed = 0; 549 int printed = 0;
550 int color, width = self->b.width; 550 int width = self->b.width;
551 char folded_sign = ' '; 551 char folded_sign = ' ';
552 bool current_entry = ui_browser__is_current_entry(&self->b, row); 552 bool current_entry = ui_browser__is_current_entry(&self->b, row);
553 off_t row_offset = entry->row_offset; 553 off_t row_offset = entry->row_offset;
@@ -567,22 +567,17 @@ static int hist_browser__show_entry(struct hist_browser *self,
567 0, false, self->hists->stats.total_period); 567 0, false, self->hists->stats.total_period);
568 percent = (entry->period * 100.0) / self->hists->stats.total_period; 568 percent = (entry->period * 100.0) / self->hists->stats.total_period;
569 569
570 color = HE_COLORSET_SELECTED; 570 ui_browser__set_percent_color(&self->b, percent, current_entry);
571 if (!current_entry) {
572 if (percent >= MIN_RED)
573 color = HE_COLORSET_TOP;
574 else if (percent >= MIN_GREEN)
575 color = HE_COLORSET_MEDIUM;
576 else
577 color = HE_COLORSET_NORMAL;
578 }
579
580 ui_browser__set_color(&self->b, color);
581 ui_browser__gotorc(&self->b, row, 0); 571 ui_browser__gotorc(&self->b, row, 0);
582 if (symbol_conf.use_callchain) { 572 if (symbol_conf.use_callchain) {
583 slsmg_printf("%c ", folded_sign); 573 slsmg_printf("%c ", folded_sign);
584 width -= 2; 574 width -= 2;
585 } 575 }
576
577 /* The scroll bar isn't being used */
578 if (!self->b.navkeypressed)
579 width += 1;
580
586 slsmg_write_nstring(s, width); 581 slsmg_write_nstring(s, width);
587 ++row; 582 ++row;
588 ++printed; 583 ++printed;
@@ -787,6 +782,7 @@ static struct hist_browser *hist_browser__new(struct hists *hists)
787 self->hists = hists; 782 self->hists = hists;
788 self->b.refresh = hist_browser__refresh; 783 self->b.refresh = hist_browser__refresh;
789 self->b.seek = ui_browser__hists_seek; 784 self->b.seek = ui_browser__hists_seek;
785 self->b.use_navkeypressed = true,
790 self->has_symbols = sort_sym.list.next != NULL; 786 self->has_symbols = sort_sym.list.next != NULL;
791 } 787 }
792 788