aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/ui/browser.c
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/perf/util/ui/browser.c
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/perf/util/ui/browser.c')
-rw-r--r--tools/perf/util/ui/browser.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/tools/perf/util/ui/browser.c b/tools/perf/util/ui/browser.c
index a54b926efe2..dce16ee4364 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)