Arnaldo Carvalho de Melo | 1e6dd07 | 2010-08-10 15:58:50 -0300 | [diff] [blame] | 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" |
Arnaldo Carvalho de Melo | 5c35d69 | 2011-02-09 11:38:43 -0200 | [diff] [blame^] | 9 | #include "ui.h" |
| 10 | |
| 11 | pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER; |
Arnaldo Carvalho de Melo | 1e6dd07 | 2010-08-10 15:58:50 -0300 | [diff] [blame] | 12 | |
| 13 | static void newt_suspend(void *d __used) |
| 14 | { |
| 15 | newtSuspend(); |
| 16 | raise(SIGTSTP); |
| 17 | newtResume(); |
| 18 | } |
| 19 | |
Arnaldo Carvalho de Melo | 229ade9 | 2011-01-31 18:08:39 -0200 | [diff] [blame] | 20 | void setup_browser(bool fallback_to_pager) |
Arnaldo Carvalho de Melo | 1e6dd07 | 2010-08-10 15:58:50 -0300 | [diff] [blame] | 21 | { |
| 22 | if (!isatty(1) || !use_browser || dump_trace) { |
| 23 | use_browser = 0; |
Arnaldo Carvalho de Melo | 229ade9 | 2011-01-31 18:08:39 -0200 | [diff] [blame] | 24 | if (fallback_to_pager) |
| 25 | setup_pager(); |
Arnaldo Carvalho de Melo | 1e6dd07 | 2010-08-10 15:58:50 -0300 | [diff] [blame] | 26 | return; |
| 27 | } |
| 28 | |
| 29 | use_browser = 1; |
| 30 | newtInit(); |
| 31 | newtCls(); |
| 32 | newtSetSuspendCallback(newt_suspend, NULL); |
| 33 | ui_helpline__init(); |
| 34 | ui_browser__init(); |
| 35 | } |
| 36 | |
| 37 | void exit_browser(bool wait_for_ok) |
| 38 | { |
| 39 | if (use_browser > 0) { |
| 40 | if (wait_for_ok) { |
| 41 | char title[] = "Fatal Error", ok[] = "Ok"; |
| 42 | newtWinMessage(title, ok, ui_helpline__last_msg); |
| 43 | } |
| 44 | newtFinished(); |
| 45 | } |
| 46 | } |