mirror of
https://github.com/weechat/weechat.git
synced 2026-07-09 11:13:12 +02:00
core: add support of flags in regular expressions and highlight options, add irc options to customize/disable default nick highlight (task #11128)
New functions in C plugin API:
- string_regex_flags
- string_regcomp
New irc options:
- irc.look.highlight_server
- irc.look.highlight_channel
- irc.look.highlight_pv
Regex flags are supported in following options/commands:
- option weechat.look.highlight
- option weechat.look.highlight_regex
- options irc.look.highlight_{server|channel|pv}
- option relay.network.allowed_ips
- core command /filter
- irc command /list
- irc command /ignore
- rmodifier command /rmodifier
This commit is contained in:
@@ -229,7 +229,10 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
}
|
||||
|
||||
/* set highlights settings on channel buffer */
|
||||
weechat_buffer_set(new_buffer, "highlight_words_add", "$nick");
|
||||
weechat_buffer_set(new_buffer, "highlight_words_add",
|
||||
(channel_type == IRC_CHANNEL_TYPE_CHANNEL) ?
|
||||
weechat_config_string (irc_config_look_highlight_channel) :
|
||||
weechat_config_string (irc_config_look_highlight_pv));
|
||||
if (weechat_config_string (irc_config_look_highlight_tags)
|
||||
&& weechat_config_string (irc_config_look_highlight_tags)[0])
|
||||
{
|
||||
|
||||
@@ -2245,8 +2245,8 @@ irc_command_list (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
ptr_server->cmd_list_regexp = malloc (sizeof (*ptr_server->cmd_list_regexp));
|
||||
if (ptr_server->cmd_list_regexp)
|
||||
{
|
||||
if ((ret = regcomp (ptr_server->cmd_list_regexp, ptr_regex,
|
||||
REG_NOSUB | REG_ICASE | REG_EXTENDED)) != 0)
|
||||
if ((ret = weechat_string_regcomp (ptr_server->cmd_list_regexp, ptr_regex,
|
||||
REG_EXTENDED | REG_ICASE | REG_NOSUB)) != 0)
|
||||
{
|
||||
regerror (ret, ptr_server->cmd_list_regexp,
|
||||
buf, sizeof(buf));
|
||||
@@ -4946,6 +4946,8 @@ irc_command_init ()
|
||||
"is working\n"
|
||||
" channel: channel name where ignore is "
|
||||
"working\n\n"
|
||||
"Note: the regular expression can start with "
|
||||
"\"(?-i)\" to become case sensitive.\n\n"
|
||||
"Examples:\n"
|
||||
" ignore nick \"toto\" everywhere:\n"
|
||||
" /ignore add toto\n"
|
||||
@@ -5029,7 +5031,8 @@ irc_command_init ()
|
||||
N_("channel: channel to list\n"
|
||||
" server: server name\n"
|
||||
" regex: regular expression used to filter "
|
||||
"results\n\n"
|
||||
"results (case insensitive, can start by \"(?-i)\" "
|
||||
"to become case sensitive)\n\n"
|
||||
"Examples:\n"
|
||||
" list all channels on server (can be very slow "
|
||||
"on large networks):\n"
|
||||
|
||||
@@ -80,6 +80,9 @@ struct t_config_option *irc_config_look_item_channel_modes_hide_key;
|
||||
struct t_config_option *irc_config_look_item_nick_modes;
|
||||
struct t_config_option *irc_config_look_item_nick_prefix;
|
||||
struct t_config_option *irc_config_look_hide_nickserv_pwd;
|
||||
struct t_config_option *irc_config_look_highlight_server;
|
||||
struct t_config_option *irc_config_look_highlight_channel;
|
||||
struct t_config_option *irc_config_look_highlight_pv;
|
||||
struct t_config_option *irc_config_look_highlight_tags;
|
||||
struct t_config_option *irc_config_look_item_display_server;
|
||||
struct t_config_option *irc_config_look_msgbuffer_fallback;
|
||||
@@ -2183,6 +2186,42 @@ irc_config_init ()
|
||||
"hide_nickserv_pwd", "boolean",
|
||||
N_("hide password displayed by nickserv"),
|
||||
NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
irc_config_look_highlight_server = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"highlight_server", "string",
|
||||
N_("comma separated list of words to highlight in server buffers "
|
||||
"(case insensitive, use \"(?-i)\" at beginning of words to "
|
||||
"make them case sensitive; special variables $nick, $channel and "
|
||||
"$server are replaced by their value), these words are added to "
|
||||
"buffer local variable \"highlight_words\" only when buffer is "
|
||||
"created (it does not affect current buffers), an empty string "
|
||||
"disables default highlight on nick, examples: \"$nick\", "
|
||||
"\"(?-i)$nick\""),
|
||||
NULL, 0, 0, "$nick", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
irc_config_look_highlight_channel = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"highlight_channel", "string",
|
||||
N_("comma separated list of words to highlight in channel buffers "
|
||||
"(case insensitive, use \"(?-i)\" at beginning of words to "
|
||||
"make them case sensitive; special variables $nick, $channel and "
|
||||
"$server are replaced by their value), these words are added to "
|
||||
"buffer local variable \"highlight_words\" only when buffer is "
|
||||
"created (it does not affect current buffers), an empty string "
|
||||
"disables default highlight on nick, examples: \"$nick\", "
|
||||
"\"(?-i)$nick\""),
|
||||
NULL, 0, 0, "$nick", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
irc_config_look_highlight_pv = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"highlight_pv", "string",
|
||||
N_("comma separated list of words to highlight in private buffers "
|
||||
"(case insensitive, use \"(?-i)\" at beginning of words to "
|
||||
"make them case sensitive; special variables $nick, $channel and "
|
||||
"$server are replaced by their value), these words are added to "
|
||||
"buffer local variable \"highlight_words\" only when buffer is "
|
||||
"created (it does not affect current buffers), an empty string "
|
||||
"disables default highlight on nick, examples: \"$nick\", "
|
||||
"\"(?-i)$nick\""),
|
||||
NULL, 0, 0, "$nick", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
irc_config_look_highlight_tags = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"highlight_tags", "string",
|
||||
|
||||
@@ -105,6 +105,9 @@ extern struct t_config_option *irc_config_look_item_channel_modes_hide_key;
|
||||
extern struct t_config_option *irc_config_look_item_nick_modes;
|
||||
extern struct t_config_option *irc_config_look_item_nick_prefix;
|
||||
extern struct t_config_option *irc_config_look_hide_nickserv_pwd;
|
||||
extern struct t_config_option *irc_config_look_highlight_server;
|
||||
extern struct t_config_option *irc_config_look_highlight_channel;
|
||||
extern struct t_config_option *irc_config_look_highlight_pv;
|
||||
extern struct t_config_option *irc_config_look_highlight_tags;
|
||||
extern struct t_config_option *irc_config_look_item_display_server;
|
||||
extern struct t_config_option *irc_config_look_msgbuffer_fallback;
|
||||
|
||||
@@ -146,7 +146,8 @@ irc_ignore_new (const char *mask, const char *server, const char *channel)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (regcomp (regex, complete_mask, REG_NOSUB | REG_ICASE | REG_EXTENDED) != 0)
|
||||
if (weechat_string_regcomp (regex, complete_mask,
|
||||
REG_EXTENDED | REG_ICASE | REG_NOSUB) != 0)
|
||||
{
|
||||
free (regex);
|
||||
free (complete_mask);
|
||||
|
||||
@@ -3010,7 +3010,8 @@ irc_server_create_buffer (struct t_irc_server *server)
|
||||
weechat_buffer_set (server->buffer, "input_get_unknown_commands", "1");
|
||||
|
||||
/* set highlights settings on server buffer */
|
||||
weechat_buffer_set (server->buffer, "highlight_words_add", "$nick");
|
||||
weechat_buffer_set (server->buffer, "highlight_words_add",
|
||||
weechat_config_string (irc_config_look_highlight_server));
|
||||
if (weechat_config_string (irc_config_look_highlight_tags)
|
||||
&& weechat_config_string (irc_config_look_highlight_tags)[0])
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user