summaryrefslogtreecommitdiff
path: root/src/plugins/scripts/tcl/weechat-tcl-api.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2010-11-25 21:28:14 +0100
committerSebastien Helleu <flashcode@flashtux.org>2010-11-25 21:28:14 +0100
commite92079cfe9c2ad89cf4c9f7d2ce146f4393cb9f4 (patch)
tree09343bd04a8c939351237d3babdcf0b05f0a0eb4 /src/plugins/scripts/tcl/weechat-tcl-api.c
parent8b9abab711ccdccceafcbea351b8bef0d23b8ecd (diff)
downloadweechat-e92079cfe9c2ad89cf4c9f7d2ce146f4393cb9f4.zip
Add new option weechat.look.highlight_regex and function string_has_highlight_regex in plugin API (task #10321)
Diffstat (limited to 'src/plugins/scripts/tcl/weechat-tcl-api.c')
-rw-r--r--src/plugins/scripts/tcl/weechat-tcl-api.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c
index 196850a0c..581b5499b 100644
--- a/src/plugins/scripts/tcl/weechat-tcl-api.c
+++ b/src/plugins/scripts/tcl/weechat-tcl-api.c
@@ -531,6 +531,46 @@ weechat_tcl_api_string_has_highlight (ClientData clientData,
}
/*
+ * weechat_tcl_api_string_has_highlight_regex: return 1 if string contains a
+ * highlight (using a regular
+ * expression)
+ * return 0 if no highlight is
+ * found in string
+ */
+
+static int
+weechat_tcl_api_string_has_highlight_regex (ClientData clientData,
+ Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
+{
+ Tcl_Obj* objp;
+ char *string, *regex;
+ int result, i;
+
+ /* make C compiler happy */
+ (void) clientData;
+
+ if (!tcl_current_script || !tcl_current_script->name)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "string_has_highlight_regex");
+ TCL_RETURN_INT(0);
+ }
+
+ if (objc < 3)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "string_has_highlight_regex");
+ TCL_RETURN_INT(0);
+ }
+
+ string = Tcl_GetStringFromObj (objv[1], &i);
+ regex = Tcl_GetStringFromObj (objv[2], &i);
+
+ result = weechat_string_has_highlight_regex (string, regex);
+
+ TCL_RETURN_INT(result);
+}
+
+/*
* weechat_tcl_api_string_mask_to_regex: convert a mask (string with only
* "*" as wildcard) to a regex, paying
* attention to special chars in a
@@ -7343,6 +7383,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
weechat_tcl_api_string_match, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::string_has_highlight",
weechat_tcl_api_string_has_highlight, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
+ Tcl_CreateObjCommand (interp, "weechat::string_has_highlight_regex",
+ weechat_tcl_api_string_has_highlight_regex, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::string_mask_to_regex",
weechat_tcl_api_string_mask_to_regex, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::string_remove_color",