diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-01-12 10:33:13 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-01-12 10:33:13 +0100 |
commit | 63aaf9dc01fef850ba5a00d11073c9d8a17b3b82 (patch) | |
tree | 71b262dd3074d1ea892e0a0ee37758a51ac2a4a9 /src/plugins/scripts/tcl/weechat-tcl-api.c | |
parent | c9b71fca2d20f14ad12b67110c5aea9cd6c21eaa (diff) | |
download | weechat-63aaf9dc01fef850ba5a00d11073c9d8a17b3b82.zip |
Add function "buffer_string_replace_local_var" in script API (patch #7061)
Diffstat (limited to 'src/plugins/scripts/tcl/weechat-tcl-api.c')
-rw-r--r-- | src/plugins/scripts/tcl/weechat-tcl-api.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c index 6e7e1a53a..2e3553256 100644 --- a/src/plugins/scripts/tcl/weechat-tcl-api.c +++ b/src/plugins/scripts/tcl/weechat-tcl-api.c @@ -4778,6 +4778,42 @@ weechat_tcl_api_buffer_set (ClientData clientData, Tcl_Interp *interp, } /* + * weechat_tcl_api_buffer_string_replace_local_var: replace local variables ($var) in a string, + * using value of local variables + */ + +static int +weechat_tcl_api_buffer_string_replace_local_var (ClientData clientData, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]) +{ + Tcl_Obj *objp; + char *buffer, *string, *result; + int i; + + /* make C compiler happy */ + (void) clientData; + + if (!tcl_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "buffer_string_replace_local_var"); + TCL_RETURN_ERROR; + } + + if (objc < 3) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "buffer_string_replace_local_var"); + TCL_RETURN_ERROR; + } + + buffer = Tcl_GetStringFromObj (objv[1], &i); + string = Tcl_GetStringFromObj (objv[2], &i); + + result = weechat_buffer_string_replace_local_var (script_str2ptr (buffer), string); + + TCL_RETURN_STRING_FREE(result); +} + +/* * weechat_tcl_api_current_window: get current window */ @@ -6683,6 +6719,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp) weechat_tcl_api_buffer_get_pointer, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); Tcl_CreateObjCommand (interp, "weechat::buffer_set", weechat_tcl_api_buffer_set, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); + Tcl_CreateObjCommand (interp, "weechat::buffer_string_replace_local_var", + weechat_tcl_api_buffer_string_replace_local_var, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); Tcl_CreateObjCommand (interp, "weechat::current_window", weechat_tcl_api_current_window, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); Tcl_CreateObjCommand (interp, "weechat::window_get_integer", |