summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2008-11-05 12:37:04 +0100
committerSebastien Helleu <flashcode@flashtux.org>2008-11-05 12:37:04 +0100
commita6c4e4ed7644c52cb228cb4aa9b2e6cd6b21883b (patch)
tree1bd44992e7ba8227ea8109cf7623c35e73f5478e
parentbffe879db8a6f53d7f74acbed4c162cab1bca409 (diff)
downloadweechat-a6c4e4ed7644c52cb228cb4aa9b2e6cd6b21883b.zip
Add weechat_highlight signal, sent when a line with highlight is displayed
-rw-r--r--src/core/weechat.c7
-rw-r--r--src/core/weechat.h1
-rw-r--r--src/gui/curses/gui-curses-main.c3
-rw-r--r--src/gui/gui-chat.c59
4 files changed, 67 insertions, 3 deletions
diff --git a/src/core/weechat.c b/src/core/weechat.c
index 59d727de0..e50f1f740 100644
--- a/src/core/weechat.c
+++ b/src/core/weechat.c
@@ -71,9 +71,9 @@
int weechat_debug_core = 0; /* debug level for core */
char *weechat_argv0 = NULL; /* WeeChat binary file name (argv[0])*/
-int weechat_upgrading; /* =1 if WeeChat is upgrading */
-time_t weechat_start_time; /* start time (used by /uptime cmd) */
-int weechat_quit; /* = 1 if quit request from user */
+int weechat_upgrading = 0; /* =1 if WeeChat is upgrading */
+time_t weechat_start_time = 0; /* start time (used by /uptime cmd) */
+int weechat_quit = 0; /* = 1 if quit request from user */
int weechat_sigsegv = 0; /* SIGSEGV received? */
char *weechat_home = NULL; /* home dir. (default: ~/.weechat) */
char *weechat_local_charset = NULL; /* example: ISO-8859-1, UTF-8 */
@@ -400,6 +400,7 @@ main (int argc, char *argv[])
argc, argv);
command_startup (1); /* command executed after plugins */
gui_layout_window_apply (); /* apply saved layout for windows */
+ weechat_upgrading = 0;
gui_main_loop (); /* WeeChat main loop */
diff --git a/src/core/weechat.h b/src/core/weechat.h
index 760d63214..95c6c25f4 100644
--- a/src/core/weechat.h
+++ b/src/core/weechat.h
@@ -100,6 +100,7 @@
extern int weechat_debug_core;
extern char *weechat_argv0;
+extern int weechat_upgrading;
extern time_t weechat_start_time;
extern int weechat_quit;
extern char *weechat_home;
diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c
index 9c065889b..986725e73 100644
--- a/src/gui/curses/gui-curses-main.c
+++ b/src/gui/curses/gui-curses-main.c
@@ -346,6 +346,9 @@ gui_main_end (int clean_exit)
gui_buffer_close (gui_buffers, 0);
}
+ gui_ok = 0;
+ gui_init_ok = 0;
+
/* delete global history */
gui_history_global_free ();
diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c
index 8701436dd..2eea85ad7 100644
--- a/src/gui/gui-chat.c
+++ b/src/gui/gui-chat.c
@@ -760,6 +760,48 @@ gui_chat_line_get_notify_level (struct t_gui_line *line)
}
/*
+ * gui_chat_build_string_prefix_message: build a string with prefix and message
+ */
+
+char *
+gui_chat_build_string_prefix_message (struct t_gui_line *line)
+{
+ char *string, *string_without_colors;
+ int length;
+
+ length = 0;
+ if (line->prefix)
+ length += strlen (line->prefix);
+ length++;
+ if (line->message)
+ length += strlen (line->message);
+ length++;
+
+ string = malloc (length);
+ if (string)
+ {
+ string[0] = '\0';
+ if (line->prefix)
+ strcat (string, line->prefix);
+ strcat (string, "\t");
+ if (line->message)
+ strcat (string, line->message);
+ }
+
+ if (string)
+ {
+ string_without_colors = (char *)gui_color_decode ((unsigned char *)string);
+ if (string_without_colors)
+ {
+ free (string);
+ string = string_without_colors;
+ }
+ }
+
+ return string;
+}
+
+/*
* gui_chat_line_add: add a new line for a buffer
*/
@@ -770,6 +812,7 @@ gui_chat_line_add (struct t_gui_buffer *buffer, time_t date,
{
struct t_gui_line *new_line;
struct t_gui_window *ptr_win;
+ char *message_for_signal;
new_line = malloc (sizeof (*new_line));
if (!new_line)
@@ -819,7 +862,20 @@ gui_chat_line_add (struct t_gui_buffer *buffer, time_t date,
if (new_line->prefix_length > buffer->prefix_max_length)
buffer->prefix_max_length = new_line->prefix_length;
if (new_line->highlight)
+ {
gui_hotlist_add (buffer, GUI_HOTLIST_HIGHLIGHT, NULL, 1);
+ if (!weechat_upgrading)
+ {
+ message_for_signal = gui_chat_build_string_prefix_message (new_line);
+ if (message_for_signal)
+ {
+ hook_signal_send ("weechat_highlight",
+ WEECHAT_HOOK_SIGNAL_STRING,
+ message_for_signal);
+ free (message_for_signal);
+ }
+ }
+ }
else
{
gui_hotlist_add (buffer,
@@ -974,6 +1030,9 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
{
if (!buffer)
buffer = gui_buffer_search_main ();
+
+ if (!buffer)
+ return;
if (buffer->type != GUI_BUFFER_TYPE_FORMATED)
buffer = gui_buffers;