summaryrefslogtreecommitdiff
path: root/src/gui/gui-chat.c
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 /src/gui/gui-chat.c
parentbffe879db8a6f53d7f74acbed4c162cab1bca409 (diff)
downloadweechat-a6c4e4ed7644c52cb228cb4aa9b2e6cd6b21883b.zip
Add weechat_highlight signal, sent when a line with highlight is displayed
Diffstat (limited to 'src/gui/gui-chat.c')
-rw-r--r--src/gui/gui-chat.c59
1 files changed, 59 insertions, 0 deletions
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;