blob: ee46d671db5990a9c453447e065bf95864943385 [file] [log] [blame]
Arnaldo Carvalho de Melo1e6dd072010-08-10 15:58:50 -03001#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 Melo5c35d692011-02-09 11:38:43 -02009#include "ui.h"
10
11pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
Arnaldo Carvalho de Melo1e6dd072010-08-10 15:58:50 -030012
13static void newt_suspend(void *d __used)
14{
15 newtSuspend();
16 raise(SIGTSTP);
17 newtResume();
18}
19
Arnaldo Carvalho de Melo229ade92011-01-31 18:08:39 -020020void setup_browser(bool fallback_to_pager)
Arnaldo Carvalho de Melo1e6dd072010-08-10 15:58:50 -030021{
22 if (!isatty(1) || !use_browser || dump_trace) {
23 use_browser = 0;
Arnaldo Carvalho de Melo229ade92011-01-31 18:08:39 -020024 if (fallback_to_pager)
25 setup_pager();
Arnaldo Carvalho de Melo1e6dd072010-08-10 15:58:50 -030026 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
37void 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}