1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-06 14:25:43 +02:00

Reintroduce highlight (move code from irc plugin to core)

This commit is contained in:
Sebastien Helleu
2008-06-01 22:09:12 +02:00
parent 4fa856c773
commit bd436db2bc
26 changed files with 1562 additions and 1700 deletions
+136 -129
View File
File diff suppressed because it is too large Load Diff
+129 -122
View File
File diff suppressed because it is too large Load Diff
+135 -126
View File
File diff suppressed because it is too large Load Diff
+124 -125
View File
File diff suppressed because it is too large Load Diff
+126 -119
View File
File diff suppressed because it is too large Load Diff
+133 -126
View File
File diff suppressed because it is too large Load Diff
+95 -99
View File
File diff suppressed because it is too large Load Diff
+182 -167
View File
File diff suppressed because it is too large Load Diff
+26 -29
View File
@@ -48,51 +48,47 @@
extern struct t_config_file *weechat_config_file;
extern struct t_config_section *weechat_config_section_bar;
extern struct t_config_option *config_startup_command_after_plugins;
extern struct t_config_option *config_startup_command_before_plugins;
extern struct t_config_option *config_startup_display_logo;
extern struct t_config_option *config_startup_display_version;
extern struct t_config_option *config_startup_command_before_plugins;
extern struct t_config_option *config_startup_command_after_plugins;
extern struct t_config_option *config_startup_weechat_slogan;
extern struct t_config_option *config_look_color_real_white;
extern struct t_config_option *config_look_save_on_exit;
extern struct t_config_option *config_look_set_title;
extern struct t_config_option *config_look_one_server_buffer;
extern struct t_config_option *config_look_open_near_server;
extern struct t_config_option *config_look_scroll_amount;
extern struct t_config_option *config_look_buffer_time_format;
extern struct t_config_option *config_look_color_nicks_number;
extern struct t_config_option *config_look_color_actions;
extern struct t_config_option *config_look_color_real_white;
extern struct t_config_option *config_look_day_change;
extern struct t_config_option *config_look_day_change_time_format;
extern struct t_config_option *config_look_highlight;
extern struct t_config_option *config_look_hotlist_names_count;
extern struct t_config_option *config_look_hotlist_names_length;
extern struct t_config_option *config_look_hotlist_names_level;
extern struct t_config_option *config_look_hotlist_sort;
extern struct t_config_option *config_look_infobar;
extern struct t_config_option *config_look_infobar_delay_highlight;
extern struct t_config_option *config_look_infobar_seconds;
extern struct t_config_option *config_look_infobar_time_format;
extern struct t_config_option *config_look_input_format;
extern struct t_config_option *config_look_item_time_format;
extern struct t_config_option *config_look_nick_complete_first;
extern struct t_config_option *config_look_nick_completion_ignore;
extern struct t_config_option *config_look_nick_completor;
extern struct t_config_option *config_look_nicklist;
extern struct t_config_option *config_look_nicklist_position;
extern struct t_config_option *config_look_nicklist_min_size;
extern struct t_config_option *config_look_nicklist_max_size;
extern struct t_config_option *config_look_nicklist_min_size;
extern struct t_config_option *config_look_nicklist_position;
extern struct t_config_option *config_look_nicklist_separator;
extern struct t_config_option *config_look_nickmode;
extern struct t_config_option *config_look_nickmode_empty;
extern struct t_config_option *config_look_no_nickname;
extern struct t_config_option *config_look_paste_max_lines;
extern struct t_config_option *config_look_prefix[];
extern struct t_config_option *config_look_prefix_align;
extern struct t_config_option *config_look_prefix_align_max;
extern struct t_config_option *config_look_prefix_suffix;
extern struct t_config_option *config_look_nick_completor;
extern struct t_config_option *config_look_nick_completion_ignore;
extern struct t_config_option *config_look_nick_complete_first;
extern struct t_config_option *config_look_infobar;
extern struct t_config_option *config_look_infobar_time_format;
extern struct t_config_option *config_look_infobar_seconds;
extern struct t_config_option *config_look_infobar_delay_highlight;
extern struct t_config_option *config_look_item_time_format;
extern struct t_config_option *config_look_hotlist_names_count;
extern struct t_config_option *config_look_hotlist_names_level;
extern struct t_config_option *config_look_hotlist_names_length;
extern struct t_config_option *config_look_hotlist_sort;
extern struct t_config_option *config_look_day_change;
extern struct t_config_option *config_look_day_change_time_format;
extern struct t_config_option *config_look_read_marker;
extern struct t_config_option *config_look_input_format;
extern struct t_config_option *config_look_paste_max_lines;
extern struct t_config_option *config_look_default_msg_quit;
extern struct t_config_option *config_look_save_on_exit;
extern struct t_config_option *config_look_scroll_amount;
extern struct t_config_option *config_look_set_title;
extern struct t_config_option *config_color_separator;
extern struct t_config_option *config_color_title;
@@ -115,6 +111,7 @@ extern struct t_config_option *config_color_chat_nick_colors[];
extern struct t_config_option *config_color_chat_host;
extern struct t_config_option *config_color_chat_delimiters;
extern struct t_config_option *config_color_chat_highlight;
extern struct t_config_option *config_color_chat_highlight_bg;
extern struct t_config_option *config_color_chat_read_marker;
extern struct t_config_option *config_color_chat_read_marker_bg;
extern struct t_config_option *config_color_status;
File diff suppressed because it is too large Load Diff
+1
View File
@@ -33,6 +33,7 @@ extern char *string_replace (char *string, char *search, char *replace);
extern char *string_remove_quotes (char *string, char *quotes);
extern char *string_strip (char *string, int left, int right, char *chars);
extern char *string_convert_hex_chars (char *string);
extern int string_has_highlight (char *string, char *highlight_words);
extern char **string_explode (char *string, char *separators, int keep_eol,
int num_items_max, int *num_items);
extern void string_free_exploded (char **exploded_string);
+19 -4
View File
@@ -566,7 +566,7 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window,
int *lines_displayed,
int simulate)
{
char str_space[] = " ", str_plus[] = "+";
char str_space[] = " ", str_plus[] = "+", *prefix_highlighted;
int i, length_allowed, num_spaces;
/* display time */
@@ -608,14 +608,25 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window,
{
gui_chat_display_word (window, line, str_space,
NULL, 1, num_lines, count,
lines_displayed,simulate);
lines_displayed, simulate);
}
}
prefix_highlighted = NULL;
if (line->highlight)
{
prefix_highlighted = (char *)gui_color_decode ((unsigned char *)line->prefix);
if (!simulate)
gui_window_set_weechat_color (GUI_CURSES(window)->win_chat,
GUI_COLOR_CHAT_HIGHLIGHT);
}
/* not enough space to display full prefix ? => truncate it! */
if ((CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE)
&& (num_spaces < 0))
{
gui_chat_display_word (window, line, line->prefix,
gui_chat_display_word (window, line,
(prefix_highlighted) ? prefix_highlighted : line->prefix,
line->prefix +
gui_chat_string_real_pos (line->prefix,
length_allowed - 1),
@@ -624,11 +635,15 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window,
}
else
{
gui_chat_display_word (window, line, line->prefix,
gui_chat_display_word (window, line,
(prefix_highlighted) ? prefix_highlighted : line->prefix,
NULL, 1, num_lines, count, lines_displayed,
simulate);
}
if (prefix_highlighted)
free (prefix_highlighted);
if (!simulate)
gui_window_reset_style (GUI_CURSES(window)->win_chat, GUI_COLOR_CHAT);
+1 -1
View File
@@ -380,7 +380,7 @@ gui_color_init_weechat ()
}
gui_color[GUI_COLOR_CHAT_HOST] = gui_color_build (GUI_COLOR_CHAT_HOST, CONFIG_COLOR(config_color_chat_host), CONFIG_COLOR(config_color_chat_bg));
gui_color[GUI_COLOR_CHAT_DELIMITERS] = gui_color_build (GUI_COLOR_CHAT_DELIMITERS, CONFIG_COLOR(config_color_chat_delimiters), CONFIG_COLOR(config_color_chat_bg));
gui_color[GUI_COLOR_CHAT_HIGHLIGHT] = gui_color_build (GUI_COLOR_CHAT_HIGHLIGHT, CONFIG_COLOR(config_color_chat_highlight), CONFIG_COLOR(config_color_chat_bg));
gui_color[GUI_COLOR_CHAT_HIGHLIGHT] = gui_color_build (GUI_COLOR_CHAT_HIGHLIGHT, CONFIG_COLOR(config_color_chat_highlight), CONFIG_COLOR(config_color_chat_highlight_bg));
gui_color[GUI_COLOR_CHAT_READ_MARKER] = gui_color_build (GUI_COLOR_CHAT_READ_MARKER, CONFIG_COLOR(config_color_chat_read_marker), CONFIG_COLOR(config_color_chat_read_marker_bg));
gui_color[GUI_COLOR_STATUS] = gui_color_build (GUI_COLOR_STATUS, CONFIG_COLOR(config_color_status), CONFIG_COLOR(config_color_status_bg));
+60 -1
View File
File diff suppressed because it is too large Load Diff
+7
View File
@@ -49,6 +49,7 @@ struct t_gui_line
int tags_count; /* number of tags for line */
char **tags_array; /* tags for line */
char displayed; /* 1 if line is displayed */
char highlight; /* 1 if line has highlight */
char refresh_needed; /* 1 if refresh asked (free buffer) */
char *prefix; /* prefix for line (may be NULL) */
int prefix_length; /* prefix length (on screen) */
@@ -131,6 +132,12 @@ struct t_gui_buffer
int text_search_found; /* 1 if text found, otherwise 0 */
char *text_search_input; /* input saved before text search */
/* highlight settings for buffer */
char *highlight_words; /* list of words to highlight */
int highlight_tags_count; /* number of tags to highlight */
/* (if 0, any tag is highlighted) */
char **highlight_tags_array; /* tags to highlight */
/* keys associated to buffer */
struct t_gui_key *keys; /* keys specific to buffer */
struct t_gui_key *last_key; /* last key for buffer */
+47
View File
@@ -557,6 +557,50 @@ gui_chat_line_match_tags (struct t_gui_line *line, int tags_count,
return 0;
}
/*
* gui_chat_line_has_highlight: return 1 if given message contains highlight (with
* a string in global highlight or buffer highlight)
*/
int
gui_chat_line_has_highlight (struct t_gui_buffer *buffer,
struct t_gui_line *line)
{
int rc;
char *msg_no_color;
/* highlights are disabled on this buffer? (special value "-" means that
buffer does not want any highlight) */
if (buffer->highlight_words && (strcmp (buffer->highlight_words, "-") == 0))
return 0;
/* check that line matches highlight tags, if any (if no tag is specified,
then any tag is allowed) */
if (buffer->highlight_tags_count > 0)
{
if (!gui_chat_line_match_tags (line,
buffer->highlight_tags_count,
buffer->highlight_tags_array))
return 0;
}
/* remove color codes from line message */
msg_no_color = (char *)gui_color_decode ((unsigned char *)line->message);
if (!msg_no_color)
return 0;
/* there is highlight on line if one of global highlight words matches line
or one of buffer highlight words matches line */
rc = (string_has_highlight (msg_no_color,
CONFIG_STRING(config_look_highlight)) ||
string_has_highlight (msg_no_color,
buffer->highlight_words));
free (msg_no_color);
return rc;
}
/*
* gui_chat_line_free: delete a formated line from a buffer
*/
@@ -662,6 +706,9 @@ 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;
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)
+9
View File
@@ -81,6 +81,15 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
"nicklist_group", 1);
}
/* set highlights settings on channel buffer */
weechat_buffer_set (new_buffer, "highlight_words", server->nick);
if (weechat_config_string (irc_config_look_highlight_tags)
&& weechat_config_string (irc_config_look_highlight_tags)[0])
{
weechat_buffer_set (new_buffer, "highlight_tags",
weechat_config_string (irc_config_look_highlight_tags));
}
/* initialize new channel */
new_channel->type = channel_type;
new_channel->name = strdup (channel_name);
+8 -7
View File
@@ -54,9 +54,9 @@ struct t_config_option *irc_config_look_nick_prefix;
struct t_config_option *irc_config_look_nick_suffix;
struct t_config_option *irc_config_look_nick_completion_smart;
struct t_config_option *irc_config_look_display_away;
struct t_config_option *irc_config_look_highlight_tags;
struct t_config_option *irc_config_look_show_away_once;
struct t_config_option *irc_config_look_notice_as_pv;
struct t_config_option *irc_config_look_highlight;
/* IRC config, network section */
@@ -905,6 +905,13 @@ irc_config_init ()
"display_away", "integer",
N_("display message when (un)marking as away"),
"off|local|channel", 0, 0, "local", NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_highlight_tags = weechat_config_new_option (
irc_config_file, ptr_section,
"highlight_tags", "string",
N_("comma separated list of tags for messages that may produce "
"highlight (usually any message from another user, not server "
"messages,..)"),
NULL, 0, 0, "irc_privmsg,irc_notice", NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_show_away_once = weechat_config_new_option (
irc_config_file, ptr_section,
"show_away_once", "boolean",
@@ -915,12 +922,6 @@ irc_config_init ()
"notice_as_pv", "boolean",
N_("display notices as private messages"),
NULL, 0, 0, "off", NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_highlight = weechat_config_new_option (
irc_config_file, ptr_section,
"highlight", "string",
N_("comma separated list of words to highlight (case insensitive "
"comparison, words may begin or end with \"*\" for partial match)"),
NULL, 0, 0, "", NULL, NULL, NULL, NULL, NULL, NULL);
ptr_section = weechat_config_new_section (irc_config_file, "network",
0, 0,
+1 -1
View File
@@ -66,9 +66,9 @@ extern struct t_config_option *irc_config_look_nick_prefix;
extern struct t_config_option *irc_config_look_nick_suffix;
extern struct t_config_option *irc_config_look_nick_completion_smart;
extern struct t_config_option *irc_config_look_display_away;
extern struct t_config_option *irc_config_look_highlight_tags;
extern struct t_config_option *irc_config_look_show_away_once;
extern struct t_config_option *irc_config_look_notice_as_pv;
extern struct t_config_option *irc_config_look_highlight;
extern struct t_config_option *irc_config_network_default_msg_part;
extern struct t_config_option *irc_config_network_default_msg_quit;
+2
View File
@@ -73,6 +73,8 @@ irc_debug_printf (struct t_irc_server *server, int send, int modified,
weechat_buffer_set (irc_debug_buffer,
"title", _("IRC debug messages"));
/* disabled all highlights on this debug buffer */
weechat_buffer_set (irc_debug_buffer, "highlight_words", "-");
}
buf = weechat_iconv_to_internal (NULL, message);
File diff suppressed because it is too large Load Diff
+1 -2
View File
@@ -45,8 +45,7 @@
struct t_irc_server;
typedef int (t_irc_recv_func)(struct t_irc_server *server, char *comand,
int argc, char **argv, char **argv_eol,
int highlight);
int argc, char **argv, char **argv_eol);
struct t_irc_protocol_msg
{
+14
View File
@@ -233,6 +233,8 @@ irc_server_set_nick (struct t_irc_server *server, char *nick)
weechat_buffer_set (server->buffer, "nick", nick);
weechat_buffer_set (server->buffer, "highlight_words", nick);
for (ptr_channel = server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
@@ -1847,9 +1849,21 @@ irc_server_connect (struct t_irc_server *server, int disable_autojoin)
&irc_buffer_close_cb, NULL);
if (!server->buffer)
return 0;
weechat_buffer_set (server->buffer, "display", "1");
weechat_hook_signal_send ("logger_backlog",
WEECHAT_HOOK_SIGNAL_POINTER, server->buffer);
/* set highlights settings on server buffer */
if (server->nick)
weechat_buffer_set (server->buffer, "highlight_words", server->nick);
if (weechat_config_string (irc_config_look_highlight_tags)
&& weechat_config_string (irc_config_look_highlight_tags)[0])
{
weechat_buffer_set (server->buffer, "highlight_tags",
weechat_config_string (irc_config_look_highlight_tags));
}
}
#ifndef HAVE_GNUTLS
+15
View File
@@ -526,6 +526,8 @@ plugin_api_infolist_get_add_buffer_line (struct t_plugin_infolist *infolist,
struct t_gui_line *line)
{
struct t_plugin_infolist_item *ptr_item;
int i;
char option_name[64];
if (!infolist || !line)
return 0;
@@ -540,6 +542,19 @@ plugin_api_infolist_get_add_buffer_line (struct t_plugin_infolist *infolist,
return 0;
if (!plugin_infolist_new_var_string (ptr_item, "str_time", line->str_time))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "tags_count", line->tags_count))
return 0;
for (i = 0; i < line->tags_count; i++)
{
snprintf (option_name, sizeof (option_name), "tag_%05d", i + 1);
if (!plugin_infolist_new_var_string (ptr_item, option_name,
line->tags_array[i]))
return 0;
}
if (!plugin_infolist_new_var_integer (ptr_item, "displayed", line->displayed))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "highlight", line->highlight))
return 0;
if (!plugin_infolist_new_var_string (ptr_item, "prefix", line->prefix))
return 0;
if (!plugin_infolist_new_var_string (ptr_item, "message", line->message))
+1
View File
@@ -292,6 +292,7 @@ plugin_load (char *filename)
new_plugin->string_replace = &string_replace;
new_plugin->string_remove_quotes = &string_remove_quotes;
new_plugin->string_strip = &string_strip;
new_plugin->string_has_highlight = &string_has_highlight;
new_plugin->string_explode = &string_explode;
new_plugin->string_free_exploded = &string_free_exploded;
new_plugin->string_split_command = &string_split_command;
+3
View File
@@ -113,6 +113,7 @@ struct t_weechat_plugin
char *(*string_replace) (char *string, char *search, char *replace);
char *(*string_remove_quotes) (char *string, char *quotes);
char *(*string_strip) (char *string, int left, int right, char *chars);
int (*string_has_highlight) (char *string, char *highlight_words);
char **(*string_explode) (char *string, char *separators, int keep_eol,
int num_items_max, int *num_items);
void (*string_free_exploded) (char **exploded_string);
@@ -492,6 +493,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
weechat_plugin->string_remove_quotes(__string, __quotes)
#define weechat_string_strip(__string, __left, __right, __chars) \
weechat_plugin->string_strip(__string, __left, __right, __chars)
#define weechat_string_has_highlight(__string, __highlight_words) \
weechat_plugin->string_has_highlight(__string, __highlight_words)
#define weechat_string_explode(__string, __separator, __eol, __max, \
__num_items) \
weechat_plugin->string_explode(__string, __separator, __eol, \