aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/newt.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/newt.c')
-rw-r--r--tools/perf/util/newt.c56
1 files changed, 37 insertions, 19 deletions
diff --git a/tools/perf/util/newt.c b/tools/perf/util/newt.c
index c65838c99354..ffd04720b754 100644
--- a/tools/perf/util/newt.c
+++ b/tools/perf/util/newt.c
@@ -235,6 +235,15 @@ static bool dialog_yesno(const char *msg)
235 return newtWinChoice(NULL, yes, no, (char *)msg) == 1; 235 return newtWinChoice(NULL, yes, no, (char *)msg) == 1;
236} 236}
237 237
238static void ui__error_window(const char *fmt, ...)
239{
240 va_list ap;
241
242 va_start(ap, fmt);
243 newtWinMessagev((char *)"Error", (char *)"Ok", (char *)fmt, ap);
244 va_end(ap);
245}
246
238#define HE_COLORSET_TOP 50 247#define HE_COLORSET_TOP 50
239#define HE_COLORSET_MEDIUM 51 248#define HE_COLORSET_MEDIUM 51
240#define HE_COLORSET_NORMAL 52 249#define HE_COLORSET_NORMAL 52
@@ -386,6 +395,8 @@ static int ui_browser__run(struct ui_browser *self, const char *title,
386 newtFormAddHotKey(self->form, ' '); 395 newtFormAddHotKey(self->form, ' ');
387 newtFormAddHotKey(self->form, NEWT_KEY_HOME); 396 newtFormAddHotKey(self->form, NEWT_KEY_HOME);
388 newtFormAddHotKey(self->form, NEWT_KEY_END); 397 newtFormAddHotKey(self->form, NEWT_KEY_END);
398 newtFormAddHotKey(self->form, NEWT_KEY_TAB);
399 newtFormAddHotKey(self->form, NEWT_KEY_RIGHT);
389 400
390 if (ui_browser__refresh_entries(self) < 0) 401 if (ui_browser__refresh_entries(self) < 0)
391 return -1; 402 return -1;
@@ -398,6 +409,8 @@ static int ui_browser__run(struct ui_browser *self, const char *title,
398 409
399 if (es->reason != NEWT_EXIT_HOTKEY) 410 if (es->reason != NEWT_EXIT_HOTKEY)
400 break; 411 break;
412 if (is_exit_key(es->u.key))
413 return es->u.key;
401 switch (es->u.key) { 414 switch (es->u.key) {
402 case NEWT_KEY_DOWN: 415 case NEWT_KEY_DOWN:
403 if (self->index == self->nr_entries - 1) 416 if (self->index == self->nr_entries - 1)
@@ -471,12 +484,10 @@ static int ui_browser__run(struct ui_browser *self, const char *title,
471 } 484 }
472 } 485 }
473 break; 486 break;
474 case NEWT_KEY_ESCAPE: 487 case NEWT_KEY_RIGHT:
475 case NEWT_KEY_LEFT: 488 case NEWT_KEY_LEFT:
476 case CTRL('c'): 489 case NEWT_KEY_TAB:
477 case 'Q': 490 return es->u.key;
478 case 'q':
479 return 0;
480 default: 491 default:
481 continue; 492 continue;
482 } 493 }
@@ -668,18 +679,24 @@ static size_t hist_entry__append_browser(struct hist_entry *self,
668 return ret; 679 return ret;
669} 680}
670 681
671static void hist_entry__annotate_browser(struct hist_entry *self) 682int hist_entry__tui_annotate(struct hist_entry *self)
672{ 683{
673 struct ui_browser browser; 684 struct ui_browser browser;
674 struct newtExitStruct es; 685 struct newtExitStruct es;
675 struct objdump_line *pos, *n; 686 struct objdump_line *pos, *n;
676 LIST_HEAD(head); 687 LIST_HEAD(head);
688 int ret;
677 689
678 if (self->ms.sym == NULL) 690 if (self->ms.sym == NULL)
679 return; 691 return -1;
680 692
681 if (hist_entry__annotate(self, &head) < 0) 693 if (self->ms.map->dso->annotate_warned)
682 return; 694 return -1;
695
696 if (hist_entry__annotate(self, &head) < 0) {
697 ui__error_window(browser__last_msg);
698 return -1;
699 }
683 700
684 ui_helpline__push("Press <- or ESC to exit"); 701 ui_helpline__push("Press <- or ESC to exit");
685 702
@@ -694,7 +711,7 @@ static void hist_entry__annotate_browser(struct hist_entry *self)
694 } 711 }
695 712
696 browser.width += 18; /* Percentage */ 713 browser.width += 18; /* Percentage */
697 ui_browser__run(&browser, self->ms.sym->name, &es); 714 ret = ui_browser__run(&browser, self->ms.sym->name, &es);
698 newtFormDestroy(browser.form); 715 newtFormDestroy(browser.form);
699 newtPopWindow(); 716 newtPopWindow();
700 list_for_each_entry_safe(pos, n, &head, node) { 717 list_for_each_entry_safe(pos, n, &head, node) {
@@ -702,6 +719,7 @@ static void hist_entry__annotate_browser(struct hist_entry *self)
702 objdump_line__free(pos); 719 objdump_line__free(pos);
703 } 720 }
704 ui_helpline__pop(); 721 ui_helpline__pop();
722 return ret;
705} 723}
706 724
707static const void *newt__symbol_tree_get_current(newtComponent self) 725static const void *newt__symbol_tree_get_current(newtComponent self)
@@ -935,14 +953,14 @@ do_help:
935 continue; 953 continue;
936 default:; 954 default:;
937 } 955 }
938 if (toupper(es.u.key) == 'Q' || 956 if (is_exit_key(es.u.key)) {
939 es.u.key == CTRL('c')) 957 if (es.u.key == NEWT_KEY_ESCAPE) {
940 break; 958 if (dialog_yesno("Do you really want to exit?"))
941 if (es.u.key == NEWT_KEY_ESCAPE) { 959 break;
942 if (dialog_yesno("Do you really want to exit?")) 960 else
961 continue;
962 } else
943 break; 963 break;
944 else
945 continue;
946 } 964 }
947 965
948 if (es.u.key == NEWT_KEY_LEFT) { 966 if (es.u.key == NEWT_KEY_LEFT) {
@@ -1006,7 +1024,7 @@ do_annotate:
1006 if (he == NULL) 1024 if (he == NULL)
1007 continue; 1025 continue;
1008 1026
1009 hist_entry__annotate_browser(he); 1027 hist_entry__tui_annotate(he);
1010 } else if (choice == zoom_dso) { 1028 } else if (choice == zoom_dso) {
1011zoom_dso: 1029zoom_dso:
1012 if (dso_filter) { 1030 if (dso_filter) {
@@ -1074,7 +1092,7 @@ void setup_browser(void)
1074{ 1092{
1075 struct newtPercentTreeColors *c = &defaultPercentTreeColors; 1093 struct newtPercentTreeColors *c = &defaultPercentTreeColors;
1076 1094
1077 if (!isatty(1) || !use_browser) { 1095 if (!isatty(1) || !use_browser || dump_trace) {
1078 setup_pager(); 1096 setup_pager();
1079 return; 1097 return;
1080 } 1098 }