diff options
Diffstat (limited to 'src/plugins/scripts/perl/weechat-perl-api.c')
-rw-r--r-- | src/plugins/scripts/perl/weechat-perl-api.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c index 8db134118..273661e9c 100644 --- a/src/plugins/scripts/perl/weechat-perl-api.c +++ b/src/plugins/scripts/perl/weechat-perl-api.c @@ -388,6 +388,39 @@ XS (XS_weechat_api_string_has_highlight) } /* + * 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 * special chars in a regex @@ -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"); |