setup.c 711 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include <newt.h>
  2. #include <signal.h>
  3. #include <stdbool.h>
  4. #include "../cache.h"
  5. #include "../debug.h"
  6. #include "browser.h"
  7. #include "helpline.h"
  8. static void newt_suspend(void *d __used)
  9. {
  10. newtSuspend();
  11. raise(SIGTSTP);
  12. newtResume();
  13. }
  14. void setup_browser(void)
  15. {
  16. if (!isatty(1) || !use_browser || dump_trace) {
  17. use_browser = 0;
  18. setup_pager();
  19. return;
  20. }
  21. use_browser = 1;
  22. newtInit();
  23. newtCls();
  24. newtSetSuspendCallback(newt_suspend, NULL);
  25. ui_helpline__init();
  26. ui_browser__init();
  27. }
  28. void exit_browser(bool wait_for_ok)
  29. {
  30. if (use_browser > 0) {
  31. if (wait_for_ok) {
  32. char title[] = "Fatal Error", ok[] = "Ok";
  33. newtWinMessage(title, ok, ui_helpline__last_msg);
  34. }
  35. newtFinished();
  36. }
  37. }