1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-29 22:36:38 +02:00

core: display lines waiting for buffer on exit (in case of early exit)

This commit is contained in:
Sebastien Helleu
2013-11-09 08:55:57 +01:00
parent 05e1e31072
commit cce23613a7
3 changed files with 20 additions and 9 deletions
+7 -5
View File
@@ -390,6 +390,8 @@ weechat_welcome_message ()
void
weechat_shutdown (int return_code, int crash)
{
gui_chat_print_lines_waiting_buffer (stderr);
if (weechat_argv0)
free (weechat_argv0);
if (weechat_home)
@@ -444,16 +446,16 @@ main (int argc, char *argv[])
gui_key_init (); /* init keys */
network_init_gcrypt (); /* init gcrypt */
if (!secure_init ()) /* init secured data options (sec.*)*/
exit (EXIT_FAILURE);
weechat_shutdown (EXIT_FAILURE, 0);
if (!config_weechat_init ()) /* init WeeChat options (weechat.*) */
exit (EXIT_FAILURE);
weechat_shutdown (EXIT_FAILURE, 0);
weechat_parse_args (argc, argv); /* parse command line args */
weechat_create_home_dir (); /* create WeeChat home directory */
log_init (); /* init log file */
if (secure_read () < 0) /* read secured data options */
exit (EXIT_FAILURE);
weechat_shutdown (EXIT_FAILURE, 0);
if (config_weechat_read () < 0) /* read WeeChat options */
exit (EXIT_FAILURE);
weechat_shutdown (EXIT_FAILURE, 0);
network_init_gnutls (); /* init GnuTLS */
gui_main_init (); /* init WeeChat interface */
if (weechat_upgrading)
@@ -462,7 +464,7 @@ main (int argc, char *argv[])
weechat_upgrade_count++; /* increase /upgrade count */
}
weechat_welcome_message (); /* display WeeChat welcome message */
gui_chat_print_lines_waiting_buffer (); /* print lines waiting for buf. */
gui_chat_print_lines_waiting_buffer (NULL); /* display lines waiting */
command_startup (0); /* command executed before plugins */
plugin_init (weechat_auto_load_plugins, /* init plugin interface(s) */
argc, argv);
+12 -3
View File
@@ -24,6 +24,7 @@
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <ctype.h>
@@ -907,11 +908,16 @@ gui_chat_printf_y (struct t_gui_buffer *buffer, int y, const char *message, ...)
}
/*
* Prints lines that are waiting for buffer.
* Displays lines that are waiting for buffer.
*
* If "f" is not NULL, the lines are written in this file (which is commonly
* stdout or stderr).
* If "f" is NULL, the lines are displayed in core buffer if the GUI is
* initialized (gui_init_ok == 1), otherwise on stdout.
*/
void
gui_chat_print_lines_waiting_buffer ()
gui_chat_print_lines_waiting_buffer (FILE *f)
{
char **lines;
int num_lines, i;
@@ -924,7 +930,10 @@ gui_chat_print_lines_waiting_buffer ()
{
for (i = 0; i < num_lines; i++)
{
gui_chat_printf (NULL, "%s", lines[i]);
if (!f && gui_init_ok)
gui_chat_printf (NULL, "%s", lines[i]);
else
string_iconv_fprintf ((f) ? f : stdout, "%s\n", lines[i]);
}
string_free_split (lines);
}
+1 -1
View File
@@ -87,7 +87,7 @@ extern void gui_chat_printf_date_tags (struct t_gui_buffer *buffer,
const char *message, ...);
extern void gui_chat_printf_y (struct t_gui_buffer *buffer, int y,
const char *message, ...);
extern void gui_chat_print_lines_waiting_buffer ();
extern void gui_chat_print_lines_waiting_buffer (FILE *f);
extern int gui_chat_hsignal_quote_line_cb (void *data, const char *signal,
struct t_hashtable *hashtable);
extern void gui_chat_end ();