diff options
Diffstat (limited to 'tools/perf/util/ui/setup.c')
| -rw-r--r-- | tools/perf/util/ui/setup.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tools/perf/util/ui/setup.c b/tools/perf/util/ui/setup.c new file mode 100644 index 000000000000..662085032eb7 --- /dev/null +++ b/tools/perf/util/ui/setup.c | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | #include <newt.h> | ||
| 2 | #include <signal.h> | ||
| 3 | #include <stdbool.h> | ||
| 4 | |||
| 5 | #include "../cache.h" | ||
| 6 | #include "../debug.h" | ||
| 7 | #include "browser.h" | ||
| 8 | #include "helpline.h" | ||
| 9 | |||
| 10 | static void newt_suspend(void *d __used) | ||
| 11 | { | ||
| 12 | newtSuspend(); | ||
| 13 | raise(SIGTSTP); | ||
| 14 | newtResume(); | ||
| 15 | } | ||
| 16 | |||
| 17 | void setup_browser(void) | ||
| 18 | { | ||
| 19 | if (!isatty(1) || !use_browser || dump_trace) { | ||
| 20 | use_browser = 0; | ||
| 21 | setup_pager(); | ||
| 22 | return; | ||
| 23 | } | ||
| 24 | |||
| 25 | use_browser = 1; | ||
| 26 | newtInit(); | ||
| 27 | newtCls(); | ||
| 28 | newtSetSuspendCallback(newt_suspend, NULL); | ||
| 29 | ui_helpline__init(); | ||
| 30 | ui_browser__init(); | ||
| 31 | } | ||
| 32 | |||
| 33 | void exit_browser(bool wait_for_ok) | ||
| 34 | { | ||
| 35 | if (use_browser > 0) { | ||
| 36 | if (wait_for_ok) { | ||
| 37 | char title[] = "Fatal Error", ok[] = "Ok"; | ||
| 38 | newtWinMessage(title, ok, ui_helpline__last_msg); | ||
| 39 | } | ||
| 40 | newtFinished(); | ||
| 41 | } | ||
| 42 | } | ||
