| 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" | 
|  | 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 | } |