5 #include "../../util/cache.h"
6 #include "../../util/debug.h"
7 #include "../browser.h"
8 #include "../helpline.h"
11 #include "../libslang.h"
12 #include "../keysyms.h"
14 pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
16 static volatile int ui__need_resize;
18 void ui__refresh_dimensions(bool force)
20 if (force || ui__need_resize) {
22 pthread_mutex_lock(&ui__lock);
23 SLtt_get_screen_size();
25 pthread_mutex_unlock(&ui__lock);
29 static void ui__sigwinch(int sig __used)
34 static void ui__setup_sigwinch(void)
42 pthread__unblock_sigwinch();
43 signal(SIGWINCH, ui__sigwinch);
46 int ui__getch(int delay_secs)
48 struct timeval timeout, *ptimeout = delay_secs ? &timeout : NULL;
58 timeout.tv_sec = delay_secs;
62 err = select(1, &read_set, NULL, NULL, ptimeout);
81 err = select(1, &read_set, NULL, NULL, &timeout);
89 static void newt_suspend(void *d __used)
96 static void ui__signal(int sig)
110 pr_err("TUI initialization failed.\n");
114 SLkp_define_keysym((char *)"^(kB)", SL_KEY_UNTAB);
116 newtSetSuspendCallback(newt_suspend, NULL);
120 signal(SIGSEGV, ui__signal);
121 signal(SIGFPE, ui__signal);
122 signal(SIGINT, ui__signal);
123 signal(SIGQUIT, ui__signal);
124 signal(SIGTERM, ui__signal);
129 void ui__exit(bool wait_for_ok)
132 ui__question_window("Fatal Error",
133 ui_helpline__last_msg,
134 "Press any key...", 0);
136 SLtt_set_cursor_visibility(1);