diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-05-16 20:04:27 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-05-16 20:04:27 -0400 |
commit | a9a4ab747e2d45bf08fddbc1568f080091486af9 (patch) | |
tree | d6a1815e5a0775210bf23d611f849749a1ed2772 /tools | |
parent | a308f3a868185d4f804fe71d0400e2b058c6d9af (diff) |
perf tui: Add help window to show key associations
Suggested-by: Ingo 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: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/newt.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tools/perf/util/newt.c b/tools/perf/util/newt.c index 59a63e4405fc..2001d26a5579 100644 --- a/tools/perf/util/newt.c +++ b/tools/perf/util/newt.c | |||
@@ -167,6 +167,48 @@ out_destroy_form: | |||
167 | return rc; | 167 | return rc; |
168 | } | 168 | } |
169 | 169 | ||
170 | static int ui__help_window(const char *text) | ||
171 | { | ||
172 | struct newtExitStruct es; | ||
173 | newtComponent tb, form = newt_form__new(); | ||
174 | int rc = -1; | ||
175 | int max_len = 0, nr_lines = 0; | ||
176 | const char *t; | ||
177 | |||
178 | if (form == NULL) | ||
179 | return -1; | ||
180 | |||
181 | t = text; | ||
182 | while (1) { | ||
183 | const char *sep = strchr(t, '\n'); | ||
184 | int len; | ||
185 | |||
186 | if (sep == NULL) | ||
187 | sep = strchr(t, '\0'); | ||
188 | len = sep - t; | ||
189 | if (max_len < len) | ||
190 | max_len = len; | ||
191 | ++nr_lines; | ||
192 | if (*sep == '\0') | ||
193 | break; | ||
194 | t = sep + 1; | ||
195 | } | ||
196 | |||
197 | tb = newtTextbox(0, 0, max_len, nr_lines, 0); | ||
198 | if (tb == NULL) | ||
199 | goto out_destroy_form; | ||
200 | |||
201 | newtTextboxSetText(tb, text); | ||
202 | newtFormAddComponent(form, tb); | ||
203 | newtCenteredWindow(max_len, nr_lines, NULL); | ||
204 | newtFormRun(form, &es); | ||
205 | newtPopWindow(); | ||
206 | rc = 0; | ||
207 | out_destroy_form: | ||
208 | newtFormDestroy(form); | ||
209 | return rc; | ||
210 | } | ||
211 | |||
170 | static bool dialog_yesno(const char *msg) | 212 | static bool dialog_yesno(const char *msg) |
171 | { | 213 | { |
172 | /* newtWinChoice should really be accepting const char pointers... */ | 214 | /* 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 | newtFormAddHotKey(self->form, 'd'); | 798 | newtFormAddHotKey(self->form, 'd'); |
757 | newtFormAddHotKey(self->form, 'T'); | 799 | newtFormAddHotKey(self->form, 'T'); |
758 | newtFormAddHotKey(self->form, 't'); | 800 | newtFormAddHotKey(self->form, 't'); |
801 | newtFormAddHotKey(self->form, '?'); | ||
802 | newtFormAddHotKey(self->form, 'H'); | ||
803 | newtFormAddHotKey(self->form, 'h'); | ||
804 | newtFormAddHotKey(self->form, NEWT_KEY_F1); | ||
759 | newtFormAddHotKey(self->form, NEWT_KEY_RIGHT); | 805 | newtFormAddHotKey(self->form, NEWT_KEY_RIGHT); |
760 | newtFormAddComponents(self->form, self->tree, NULL); | 806 | newtFormAddComponents(self->form, self->tree, NULL); |
761 | self->selection = newt__symbol_tree_get_current(self->tree); | 807 | 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 | dso = browser->selection->map ? browser->selection->map->dso : NULL; | 888 | dso = browser->selection->map ? browser->selection->map->dso : NULL; |
843 | 889 | ||
844 | if (es.reason == NEWT_EXIT_HOTKEY) { | 890 | if (es.reason == NEWT_EXIT_HOTKEY) { |
891 | if (es.u.key == NEWT_KEY_F1) | ||
892 | goto do_help; | ||
893 | |||
845 | switch (toupper(es.u.key)) { | 894 | switch (toupper(es.u.key)) { |
846 | case 'A': | 895 | case 'A': |
847 | goto do_annotate; | 896 | goto do_annotate; |
@@ -849,6 +898,17 @@ int hists__browse(struct hists *self, const char *helpline, const char *input_na | |||
849 | goto zoom_dso; | 898 | goto zoom_dso; |
850 | case 'T': | 899 | case 'T': |
851 | goto zoom_thread; | 900 | goto zoom_thread; |
901 | case 'H': | ||
902 | case '?': | ||
903 | do_help: | ||
904 | ui__help_window("-> Zoom into DSO/Threads & Annotate current symbol\n" | ||
905 | "<- Zoom out\n" | ||
906 | "a Annotate current symbol\n" | ||
907 | "h/?/F1 Show this window\n" | ||
908 | "d Zoom into current DSO\n" | ||
909 | "t Zoom into current Thread\n" | ||
910 | "q/CTRL+C Exit browser"); | ||
911 | continue; | ||
852 | default:; | 912 | default:; |
853 | } | 913 | } |
854 | if (toupper(es.u.key) == 'Q' || | 914 | if (toupper(es.u.key) == 'Q' || |