perf tui: Add help window to show key associations

Suggested-by: default avatarIngo Molnar <mingo@elte.hu>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent a308f3a8
...@@ -167,6 +167,48 @@ static int popup_menu(int argc, char * const argv[]) ...@@ -167,6 +167,48 @@ static int popup_menu(int argc, char * const argv[])
return rc; return rc;
} }
static int ui__help_window(const char *text)
{
struct newtExitStruct es;
newtComponent tb, form = newt_form__new();
int rc = -1;
int max_len = 0, nr_lines = 0;
const char *t;
if (form == NULL)
return -1;
t = text;
while (1) {
const char *sep = strchr(t, '\n');
int len;
if (sep == NULL)
sep = strchr(t, '\0');
len = sep - t;
if (max_len < len)
max_len = len;
++nr_lines;
if (*sep == '\0')
break;
t = sep + 1;
}
tb = newtTextbox(0, 0, max_len, nr_lines, 0);
if (tb == NULL)
goto out_destroy_form;
newtTextboxSetText(tb, text);
newtFormAddComponent(form, tb);
newtCenteredWindow(max_len, nr_lines, NULL);
newtFormRun(form, &es);
newtPopWindow();
rc = 0;
out_destroy_form:
newtFormDestroy(form);
return rc;
}
static bool dialog_yesno(const char *msg) static bool dialog_yesno(const char *msg)
{ {
/* newtWinChoice should really be accepting const char pointers... */ /* newtWinChoice should really be accepting const char pointers... */
...@@ -756,6 +798,10 @@ static int hist_browser__populate(struct hist_browser *self, struct hists *hists ...@@ -756,6 +798,10 @@ static int hist_browser__populate(struct hist_browser *self, struct hists *hists
newtFormAddHotKey(self->form, 'd'); newtFormAddHotKey(self->form, 'd');
newtFormAddHotKey(self->form, 'T'); newtFormAddHotKey(self->form, 'T');
newtFormAddHotKey(self->form, 't'); newtFormAddHotKey(self->form, 't');
newtFormAddHotKey(self->form, '?');
newtFormAddHotKey(self->form, 'H');
newtFormAddHotKey(self->form, 'h');
newtFormAddHotKey(self->form, NEWT_KEY_F1);
newtFormAddHotKey(self->form, NEWT_KEY_RIGHT); newtFormAddHotKey(self->form, NEWT_KEY_RIGHT);
newtFormAddComponents(self->form, self->tree, NULL); newtFormAddComponents(self->form, self->tree, NULL);
self->selection = newt__symbol_tree_get_current(self->tree); self->selection = newt__symbol_tree_get_current(self->tree);
...@@ -842,6 +888,9 @@ int hists__browse(struct hists *self, const char *helpline, const char *input_na ...@@ -842,6 +888,9 @@ int hists__browse(struct hists *self, const char *helpline, const char *input_na
dso = browser->selection->map ? browser->selection->map->dso : NULL; dso = browser->selection->map ? browser->selection->map->dso : NULL;
if (es.reason == NEWT_EXIT_HOTKEY) { if (es.reason == NEWT_EXIT_HOTKEY) {
if (es.u.key == NEWT_KEY_F1)
goto do_help;
switch (toupper(es.u.key)) { switch (toupper(es.u.key)) {
case 'A': case 'A':
goto do_annotate; goto do_annotate;
...@@ -849,6 +898,17 @@ int hists__browse(struct hists *self, const char *helpline, const char *input_na ...@@ -849,6 +898,17 @@ int hists__browse(struct hists *self, const char *helpline, const char *input_na
goto zoom_dso; goto zoom_dso;
case 'T': case 'T':
goto zoom_thread; goto zoom_thread;
case 'H':
case '?':
do_help:
ui__help_window("-> Zoom into DSO/Threads & Annotate current symbol\n"
"<- Zoom out\n"
"a Annotate current symbol\n"
"h/?/F1 Show this window\n"
"d Zoom into current DSO\n"
"t Zoom into current Thread\n"
"q/CTRL+C Exit browser");
continue;
default:; default:;
} }
if (toupper(es.u.key) == 'Q' || if (toupper(es.u.key) == 'Q' ||
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment