diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index 8f664db88..5302686f8 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -492,9 +492,29 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property, long number; char *error; - if (!buffer || !property || !value) + if (!property || !value) return; + /* properties that does NOT need a buffer */ + if (string_strcasecmp (property, "hotlist") == 0) + { + if (strcmp (value, "-") == 0) + gui_add_hotlist = 0; + else if (strcmp (value, "+") == 0) + gui_add_hotlist = 1; + else + { + error = NULL; + number = strtol (value, &error, 10); + if (error && !error[0]) + gui_hotlist_add (buffer, number, NULL, 1); + } + } + + if (!buffer) + return; + + /* properties that need a buffer */ if (string_strcasecmp (property, "display") == 0) { gui_window_switch_to_buffer (gui_current_window, buffer); @@ -557,20 +577,6 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property, { gui_buffer_set_nick (buffer, value); } - else if (string_strcasecmp (property, "hotlist") == 0) - { - if (strcmp (value, "-") == 0) - gui_add_hotlist = 0; - else if (strcmp (value, "+") == 0) - gui_add_hotlist = 1; - else - { - error = NULL; - number = strtol (value, &error, 10); - if (error && !error[0]) - gui_hotlist_add (buffer, number, NULL, 1); - } - } else if (string_strcasecmp (property, "highlight_words") == 0) { gui_buffer_set_highlight_words (buffer, value); diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c index 3becf4af1..ecf81991a 100644 --- a/src/gui/gui-chat.c +++ b/src/gui/gui-chat.c @@ -666,6 +666,27 @@ gui_chat_line_free_all (struct t_gui_buffer *buffer) } } +/* + * gui_chat_line_get_notify_level: get notify level for a line + */ + +int +gui_chat_line_get_notify_level (struct t_gui_line *line) +{ + int i; + + for (i = 0; i < line->tags_count; i++) + { + if (string_strcasecmp (line->tags_array[i], "notify_highlight") == 0) + return GUI_HOTLIST_HIGHLIGHT; + if (string_strcasecmp (line->tags_array[i], "notify_private") == 0) + return GUI_HOTLIST_PRIVATE; + if (string_strcasecmp (line->tags_array[i], "notify_message") == 0) + return GUI_HOTLIST_MESSAGE; + } + return GUI_HOTLIST_LOW; +} + /* * gui_chat_line_add: add a new line for a buffer */ @@ -707,8 +728,6 @@ gui_chat_line_add (struct t_gui_buffer *buffer, time_t date, gui_chat_strlen_screen (prefix) : 0; new_line->message = (message) ? strdup (message) : strdup (""); new_line->highlight = gui_chat_line_has_highlight (buffer, new_line); - if (new_line->highlight) - gui_hotlist_add (buffer, GUI_HOTLIST_HIGHLIGHT, NULL, 0); /* add line to lines list */ if (!buffer->lines) @@ -726,6 +745,14 @@ 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, 0); + else + { + gui_hotlist_add (buffer, + gui_chat_line_get_notify_level (new_line), + NULL, 0); + } } else { @@ -942,16 +969,7 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date, } if (gui_init_ok) - { gui_buffer_ask_chat_refresh (buffer, 1); - if (gui_add_hotlist - && ((buffer->num_displayed == 0) - || (gui_buffer_is_scrolled (buffer)))) - { - gui_hotlist_add (buffer, 0, NULL, 1); - gui_status_refresh_needed = 1; - } - } free (buf); } diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index ed400f85a..87fc8524e 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -384,9 +384,9 @@ irc_command_away (void *data, struct t_gui_buffer *buffer, int argc, /* make C compiler happy */ (void) data; - (void) argv; weechat_buffer_set (NULL, "hotlist", "-"); + if ((argc > 2) && (weechat_strcasecmp (argv[1], "-all") == 0)) { for (ptr_server = irc_servers; ptr_server; diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index c7b1f16b1..fc8c1c194 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -230,7 +230,7 @@ irc_protocol_cmd_invite (struct t_irc_server *server, const char *command, (void) argv_eol; weechat_printf_tags (server->buffer, - "irc_invite", + "irc_invite,notify_highlight", _("%sYou have been invited to %s%s%s by " "%s%s"), weechat_prefix ("network"), @@ -239,8 +239,6 @@ irc_protocol_cmd_invite (struct t_irc_server *server, const char *command, IRC_COLOR_CHAT, IRC_COLOR_CHAT_NICK, irc_protocol_get_nick_from_host (argv[0])); - weechat_buffer_set (server->buffer, "hotlist", - WEECHAT_HOTLIST_HIGHLIGHT); return WEECHAT_RC_OK; } @@ -635,7 +633,7 @@ int irc_protocol_cmd_notice (struct t_irc_server *server, const char *command, int argc, char **argv, char **argv_eol) { - char *nick, *host, *pos_args, *pos_end, *pos_usec; + char *nick, *host, *pos_args, *pos_end, *pos_usec, tags[128]; struct timeval tv; long sec1, usec1, sec2, usec2, difftime; struct t_irc_channel *ptr_channel; @@ -728,6 +726,19 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command, } else { + if (nick + && (weechat_strcasecmp (nick, "nickserv") != 0) + && (weechat_strcasecmp (nick, "chanserv") != 0) + && (weechat_strcasecmp (nick, "memoserv") != 0)) + { + snprintf (tags, sizeof (tags), + "%s", "irc_notice,notify_private"); + } + else + { + snprintf (tags, sizeof (tags), + "%s", "irc_notice"); + } if (nick && weechat_config_boolean (irc_config_look_notice_as_pv)) { ptr_channel = irc_channel_search (server, nick); @@ -754,7 +765,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command, } weechat_printf_tags (ptr_channel->buffer, - "irc_notice", + tags, "%s%s", irc_nick_as_prefix (NULL, nick, IRC_COLOR_CHAT_NICK_OTHER), @@ -765,7 +776,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command, if (host && host[0]) { weechat_printf_tags (server->buffer, - "irc_notice", + tags, "%s%s%s %s(%s%s%s)%s: %s", weechat_prefix ("network"), IRC_COLOR_CHAT_NICK, @@ -782,7 +793,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command, if (nick && nick[0]) { weechat_printf_tags (server->buffer, - "irc_notice", + tags, "%s%s%s%s: %s", weechat_prefix ("network"), IRC_COLOR_CHAT_NICK, @@ -793,22 +804,13 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command, else { weechat_printf_tags (server->buffer, - "irc_notice", + tags, "%s%s", weechat_prefix ("network"), pos_args); } } } - - if (nick - && (weechat_strcasecmp (nick, "nickserv") != 0) - && (weechat_strcasecmp (nick, "chanserv") != 0) - && (weechat_strcasecmp (nick, "memoserv") != 0)) - { - weechat_buffer_set (server->buffer, "hotlist", - WEECHAT_HOTLIST_PRIVATE); - } } } @@ -1092,7 +1094,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, pos_end_01[0] = '\0'; weechat_printf_tags (ptr_channel->buffer, - "irc_privmsg,irc_action", + "irc_privmsg,irc_action,notify_message", "%s%s%s %s%s", weechat_prefix ("action"), IRC_COLOR_CHAT_NICK, @@ -1235,14 +1237,12 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, ptr_nick = irc_nick_search (ptr_channel, nick); weechat_printf_tags (ptr_channel->buffer, - "irc_privmsg", + "irc_privmsg,notify_message", "%s%s", irc_nick_as_prefix (ptr_nick, (ptr_nick) ? NULL : nick, NULL), pos_args); - weechat_buffer_set (ptr_channel->buffer, "hotlist", - WEECHAT_HOTLIST_MESSAGE); irc_channel_add_nick_speaking (ptr_channel, nick); } @@ -1782,7 +1782,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, pos_end_01[0] = '\0'; weechat_printf_tags (ptr_channel->buffer, - "irc_privmsg,irc_action", + "irc_privmsg,irc_action,notify_private", "%s%s%s %s%s", weechat_prefix ("action"), IRC_COLOR_CHAT_NICK, @@ -1792,8 +1792,6 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, weechat_hook_signal_send ("irc_pv", WEECHAT_HOOK_SIGNAL_STRING, argv_eol[0]); - weechat_buffer_set (ptr_channel->buffer, "hotlist", - WEECHAT_HOTLIST_MESSAGE); if (pos_end_01) pos_end_01[0] = '\01'; @@ -1886,7 +1884,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, ptr_channel->topic); weechat_printf_tags (ptr_channel->buffer, - "irc_privmsg", + "irc_privmsg,notify_private", "%s%s", irc_nick_as_prefix (NULL, nick, @@ -1896,9 +1894,6 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, weechat_hook_signal_send ("irc_pv", WEECHAT_HOOK_SIGNAL_STRING, argv_eol[0]); - - weechat_buffer_set (ptr_channel->buffer, - "hotlist", WEECHAT_HOTLIST_PRIVATE); } } }