1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-01 07:16:37 +02:00

Add new option weechat.look.highlight_regex and function string_has_highlight_regex in plugin API (task #10321)

This commit is contained in:
Sebastien Helleu
2010-11-25 21:28:14 +01:00
parent 8b9abab711
commit e92079cfe9
32 changed files with 578 additions and 18 deletions
@@ -387,6 +387,39 @@ XS (XS_weechat_api_string_has_highlight)
PERL_RETURN_INT(value);
}
/*
* weechat::string_has_highlight_regex: return 1 if string contains a highlight
* (using regular expression)
* return 0 if no highlight is found in
* string
*/
XS (XS_weechat_api_string_has_highlight_regex)
{
int value;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script || !perl_current_script->name)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "string_has_highlight_regex");
PERL_RETURN_INT(0);
}
if (items < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "string_has_highlight_regex");
PERL_RETURN_INT(0);
}
value = weechat_string_has_highlight_regex (SvPV (ST (0), PL_na), /* string */
SvPV (ST (1), PL_na)); /* regex */
PERL_RETURN_INT(value);
}
/*
* weechat::string_mask_to_regex: convert a mask (string with only "*" as
* wildcard) to a regex, paying attention to
@@ -6509,6 +6542,7 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::ngettext", XS_weechat_api_ngettext, "weechat");
newXS ("weechat::string_match", XS_weechat_api_string_match, "weechat");
newXS ("weechat::string_has_highlight", XS_weechat_api_string_has_highlight, "weechat");
newXS ("weechat::string_has_highlight_regex", XS_weechat_api_string_has_highlight_regex, "weechat");
newXS ("weechat::string_mask_to_regex", XS_weechat_api_string_mask_to_regex, "weechat");
newXS ("weechat::string_remove_color", XS_weechat_api_string_remove_color, "weechat");
newXS ("weechat::string_is_command_char", XS_weechat_api_string_is_command_char, "weechat");