From e92079cfe9c2ad89cf4c9f7d2ce146f4393cb9f4 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Thu, 25 Nov 2010 21:28:14 +0100 Subject: Add new option weechat.look.highlight_regex and function string_has_highlight_regex in plugin API (task #10321) --- doc/en/autogen/user/weechat_options.txt | 5 ++++ doc/en/weechat_plugin_api.en.txt | 43 +++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) (limited to 'doc/en') diff --git a/doc/en/autogen/user/weechat_options.txt b/doc/en/autogen/user/weechat_options.txt index 0586b4e9c..8779f96da 100644 --- a/doc/en/autogen/user/weechat_options.txt +++ b/doc/en/autogen/user/weechat_options.txt @@ -388,6 +388,11 @@ ** type: string ** values: any string (default value: `""`) +* *weechat.look.highlight_regex* +** description: `regular expression used to check if a message has highlight or not, at least one match in string must be surrounded by word chars (alphanumeric, "-", "_" or "|"), regular expression is case sensitive, example: "FlashCode|flashy"` +** type: string +** values: any string (default value: `""`) + * *weechat.look.hline_char* ** description: `char used to draw horizontal lines, note that empty value will draw a real line with ncurses, but may cause bugs with URL selection under some terminals` ** type: string diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt index e1ccfb010..ce6ac9cdc 100644 --- a/doc/en/weechat_plugin_api.en.txt +++ b/doc/en/weechat_plugin_api.en.txt @@ -933,6 +933,49 @@ highlight = weechat.string_has_highlight(string, highlight_words) highlight = weechat.string_has_highlight("my test string", "test,word2") # 1 ---------------------------------------- +weechat_string_has_highlight_regex +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +_New in version 0.3.4._ + +Check if a string has one or more highlights, using a regular expression. +For at least one match of regular expression on string, it must be surrounded +by word chars (alphanumeric character, "-", "_" or "|"). + +Prototype: + +[source,C] +---------------------------------------- +int weechat_string_has_highlight_regex (const char *string, const char *regex); +---------------------------------------- + +Arguments: + +* 'string': string +* 'regex': regular expression + +Return value: + +* 1 if string has one or more highlights, otherwise 0 + +C example: + +[source,C] +---------------------------------------- +int hl = weechat_string_has_highlight_regex ("my test string", "test|word2"); /* == 1 */ +---------------------------------------- + +Script (Python): + +[source,python] +---------------------------------------- +# prototype +highlight = weechat.string_has_highlight_regex(string, regex) + +# example +highlight = weechat.string_has_highlight_regex("my test string", "test|word2") # 1 +---------------------------------------- + weechat_string_mask_to_regex ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- cgit v1.2.3