1
/* ##########################################################################
2
* ##########################################################################
2
3
* ## ___ __ ______________ _____ ##
3
4
* ## __ | / /___________ ____/__ /_______ __ /_ ##
4
5
* ## __ | /| / /_ _ \ _ \ / __ __ \ __ `/ __/ ##
389
* Displays warnings about $TERM if it is detected as wrong.
391
* If $TERM is different from "screen" or "screen-256color" and that $STY is
392
* set (GNU screen) or $TMUX is set (tmux), then a warning is displayed.
396
weechat_term_check ()
398
char *term, *sty, *tmux;
399
int is_term_ok, is_screen, is_tmux;
401
term = getenv ("TERM");
402
sty = getenv ("STY");
403
tmux = getenv ("TMUX");
405
is_term_ok = (term && (strncmp (term, "screen", 6) == 0));
406
is_screen = (sty && sty[0]);
407
is_tmux = (tmux && tmux[0]);
409
if ((is_screen || is_tmux) && !is_term_ok)
413
/* TRANSLATORS: the "under %s" can be "under screen" or "under tmux" */
414
_("%sWarning: WeeChat is running under %s and $TERM is \"%s\", "
415
"which can cause display bugs; $TERM should be set to "
416
"\"screen-256color\" or \"screen\""),
417
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
418
(is_screen) ? "screen" : "tmux",
422
_("%sYou should add this line in the file %s: %s"),
423
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
424
(is_screen) ? "~/.screenrc" : "~/.tmux.conf",
426
"term screen-256color" :
427
"set -g default-terminal \"screen-256color\"");
432
* Callback for system signal SIGHUP: quits WeeChat.
438
log_printf (_("Signal %s received, exiting WeeChat..."), "SIGHUP");
439
(void) hook_signal_send ("quit", WEECHAT_HOOK_SIGNAL_STRING, NULL);
444
* Callback for system signal SIGQUIT: quits WeeChat.
450
log_printf (_("Signal %s received, exiting WeeChat..."), "SIGQUIT");
451
(void) hook_signal_send ("quit", WEECHAT_HOOK_SIGNAL_STRING, NULL);
456
* Callback for system signal SIGTERM: quits WeeChat.
462
log_printf (_("Signal %s received, exiting WeeChat..."), "SIGTERM");
463
(void) hook_signal_send ("quit", WEECHAT_HOOK_SIGNAL_STRING, NULL);
388
468
* Shutdowns WeeChat.
488
else if (return_code >= 0)
409
489
exit (return_code);
413
* Entry point for WeeChat.
493
* Initializes WeeChat.
417
main (int argc, char *argv[])
497
weechat_init (int argc, char *argv[], void (*gui_init_cb)())
419
499
weechat_first_start_time = time (NULL); /* initialize start time */
420
500
gettimeofday (&weechat_current_start_timeval, NULL);
436
util_catch_signal (SIGINT, SIG_IGN); /* ignore SIGINT signal */
437
util_catch_signal (SIGQUIT, SIG_IGN); /* ignore SIGQUIT signal */
438
util_catch_signal (SIGPIPE, SIG_IGN); /* ignore SIGPIPE signal */
439
util_catch_signal (SIGSEGV,
440
&debug_sigsegv); /* crash dump for SIGSEGV signal */
517
util_catch_signal (SIGINT, SIG_IGN); /* signal ignored */
518
util_catch_signal (SIGQUIT, SIG_IGN); /* signal ignored */
519
util_catch_signal (SIGPIPE, SIG_IGN); /* signal ignored */
520
util_catch_signal (SIGSEGV, &debug_sigsegv); /* crash dump */
521
util_catch_signal (SIGHUP, &weechat_sighup); /* exit WeeChat */
522
util_catch_signal (SIGQUIT, &weechat_sigquit); /* exit WeeChat */
523
util_catch_signal (SIGTERM, &weechat_sigterm); /* exit WeeChat */
441
525
hdata_init (); /* initialize hdata */
442
526
hook_init (); /* initialize hooks */
443
527
debug_init (); /* hook signals for debug */
444
gui_main_pre_init (&argc, &argv); /* pre-initialize interface */
528
gui_color_init (); /* initialize colors */
529
gui_chat_init (); /* initialize chat */
445
530
command_init (); /* initialize WeeChat commands */
446
531
completion_init (); /* add core completion hooks */
447
532
gui_key_init (); /* init keys */
457
542
secure_read (); /* read secured data options */
458
543
config_weechat_read (); /* read WeeChat options */
459
544
network_init_gnutls (); /* init GnuTLS */
460
gui_main_init (); /* init WeeChat interface */
547
(*gui_init_cb) (); /* init WeeChat interface */
461
549
if (weechat_upgrading)
463
551
upgrade_weechat_load (); /* upgrade with session file */
466
554
weechat_welcome_message (); /* display WeeChat welcome message */
467
555
gui_chat_print_lines_waiting_buffer (NULL); /* display lines waiting */
556
weechat_term_check (); /* warnings about $TERM (if wrong) */
468
557
command_startup (0); /* command executed before plugins */
469
558
plugin_init (weechat_auto_load_plugins, /* init plugin interface(s) */
473
562
gui_layout_window_apply (gui_layout_current, -1);
474
563
if (weechat_upgrading)
475
564
upgrade_weechat_end (); /* remove .upgrade files + signal */
477
gui_main_loop (); /* WeeChat main loop */
572
weechat_end (void (*gui_end_cb)(int clean_exit))
479
574
gui_layout_store_on_exit (); /* store layout */
480
575
plugin_end (); /* end plugin interface(s) */
481
576
if (CONFIG_BOOLEAN(config_look_save_config_on_exit))
482
577
(void) config_weechat_write (); /* save WeeChat config file */
483
578
(void) secure_write (); /* save secured data */
484
gui_main_end (1); /* shut down WeeChat GUI */
581
(*gui_end_cb) (1); /* shut down WeeChat GUI */
485
583
proxy_free_all (); /* free all proxies */
486
584
config_weechat_free (); /* free WeeChat options */
487
585
secure_free (); /* free secured data options */
489
587
gui_key_end (); /* remove all keys */
490
588
unhook_all (); /* remove all hooks */
491
589
hdata_end (); /* end hdata */
492
eval_end (); /* end eval */
493
590
secure_end (); /* end secured data */
494
591
string_end (); /* end string */
495
weechat_shutdown (EXIT_SUCCESS, 0); /* quit WeeChat (oh no, why?) */
497
return EXIT_SUCCESS; /* make C compiler happy */
592
weechat_shutdown (-1, 0); /* end other things */