setup.c 755 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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(bool fallback_to_pager)
  15. {
  16. if (!isatty(1) || !use_browser || dump_trace) {
  17. use_browser = 0;
  18. if (fallback_to_pager)
  19. setup_pager();
  20. return;
  21. }
  22. use_browser = 1;
  23. newtInit();
  24. newtCls();
  25. newtSetSuspendCallback(newt_suspend, NULL);
  26. ui_helpline__init();
  27. ui_browser__init();
  28. }
  29. void exit_browser(bool wait_for_ok)
  30. {
  31. if (use_browser > 0) {
  32. if (wait_for_ok) {
  33. char title[] = "Fatal Error", ok[] = "Ok";
  34. newtWinMessage(title, ok, ui_helpline__last_msg);
  35. }
  36. newtFinished();
  37. }
  38. }