summaryrefslogtreecommitdiff
path: root/src/plugins/scripts/tcl
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2009-06-10 12:40:05 +0200
committerSebastien Helleu <flashcode@flashtux.org>2009-06-10 12:40:05 +0200
commit8d58b81d83d9a5462f1b4aeb274a16a91ef213d1 (patch)
tree4bf0ef51ea845f54fa97012b1ebe9a85e24f1750 /src/plugins/scripts/tcl
parentfd31dbb97ec00ee49cec21c4731677c403c80564 (diff)
downloadweechat-8d58b81d83d9a5462f1b4aeb274a16a91ef213d1.zip
Add buffer merging feature, with /buffer merge/unmerge (task #7404)
Diffstat (limited to 'src/plugins/scripts/tcl')
-rw-r--r--src/plugins/scripts/tcl/weechat-tcl-api.c104
1 files changed, 104 insertions, 0 deletions
diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c
index afc4a388d..202710276 100644
--- a/src/plugins/scripts/tcl/weechat-tcl-api.c
+++ b/src/plugins/scripts/tcl/weechat-tcl-api.c
@@ -4440,6 +4440,33 @@ weechat_tcl_api_buffer_search (ClientData clientData, Tcl_Interp *interp,
}
/*
+ * weechat_tcl_api_buffer_search_main: search main buffer (WeeChat core buffer)
+ */
+
+static int
+weechat_tcl_api_buffer_search_main (ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
+{
+ Tcl_Obj *objp;
+ char *result;
+
+ /* make C compiler happy */
+ (void) clientData;
+ (void) objc;
+ (void) objv;
+
+ if (!tcl_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "buffer_search_main");
+ TCL_RETURN_EMPTY;
+ }
+
+ result = script_ptr2str (weechat_buffer_search_main ());
+
+ TCL_RETURN_STRING_FREE(result);
+}
+
+/*
* weechat_tcl_api_current_buffer: get current buffer
*/
@@ -4531,6 +4558,77 @@ weechat_tcl_api_buffer_close (ClientData clientData, Tcl_Interp *interp,
}
/*
+ * weechat_tcl_api_buffer_merge: merge a buffer to another buffer
+ */
+
+static int
+weechat_tcl_api_buffer_merge (ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
+{
+ Tcl_Obj *objp;
+ int i;
+
+ /* make C compiler happy */
+ (void) clientData;
+
+ if (!tcl_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "buffer_merge");
+ TCL_RETURN_ERROR;
+ }
+
+ if (objc < 3)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "buffer_merge");
+ TCL_RETURN_ERROR;
+ }
+
+ weechat_buffer_merge (script_str2ptr (Tcl_GetStringFromObj (objv[1], &i)), /* buffer */
+ script_str2ptr (Tcl_GetStringFromObj (objv[2], &i))); /* target_buffer */
+
+ TCL_RETURN_OK;
+}
+
+/*
+ * weechat_tcl_api_buffer_unmerge: unmerge a buffer from a group of merged
+ * buffers
+ */
+
+static int
+weechat_tcl_api_buffer_unmerge (ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
+{
+ Tcl_Obj *objp;
+ int i, number;
+
+ /* make C compiler happy */
+ (void) clientData;
+
+ if (!tcl_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "buffer_unmerge");
+ TCL_RETURN_ERROR;
+ }
+
+ if (objc < 3)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "buffer_unmerge");
+ TCL_RETURN_ERROR;
+ }
+
+ if (Tcl_GetIntFromObj (interp, objv[2], &number) != TCL_OK)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "buffer_unmerge");
+ TCL_RETURN_ERROR;
+ }
+
+ weechat_buffer_unmerge (script_str2ptr (Tcl_GetStringFromObj (objv[1], &i)),
+ number);
+
+ TCL_RETURN_OK;
+}
+
+/*
* weechat_tcl_api_buffer_get_integer: get a buffer property as integer
*/
@@ -6528,12 +6626,18 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
weechat_tcl_api_buffer_new, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::buffer_search",
weechat_tcl_api_buffer_search, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
+ Tcl_CreateObjCommand (interp, "weechat::buffer_search_main",
+ weechat_tcl_api_buffer_search_main, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::current_buffer",
weechat_tcl_api_current_buffer, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::buffer_clear",
weechat_tcl_api_buffer_clear, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::buffer_close",
weechat_tcl_api_buffer_close, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
+ Tcl_CreateObjCommand (interp, "weechat::buffer_merge",
+ weechat_tcl_api_buffer_merge, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
+ Tcl_CreateObjCommand (interp, "weechat::buffer_unmerge",
+ weechat_tcl_api_buffer_unmerge, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::buffer_get_integer",
weechat_tcl_api_buffer_get_integer, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::buffer_get_string",