mirror of
https://github.com/weechat/weechat.git
synced 2026-07-08 07:45:42 +02:00
Added preliminary support of new buffer type, with free content
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1505,6 +1505,79 @@ static XS (XS_weechat_print)
|
||||
PERL_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::print_date_tags: print message in a buffer with optional date and
|
||||
* tags
|
||||
*/
|
||||
|
||||
static XS (XS_weechat_print_date_tags)
|
||||
{
|
||||
char *buffer, *tags, *message;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("print_date_tags");
|
||||
PERL_RETURN_ERROR;
|
||||
}
|
||||
|
||||
if (items < 4)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("print_date_tags");
|
||||
PERL_RETURN_ERROR;
|
||||
}
|
||||
|
||||
buffer = SvPV (ST (0), PL_na);
|
||||
tags = SvPV (ST (2), PL_na);
|
||||
message = SvPV (ST (3), PL_na);
|
||||
script_api_printf_date_tags (weechat_perl_plugin,
|
||||
perl_current_script,
|
||||
script_str2ptr (buffer),
|
||||
SvIV (ST (1)),
|
||||
tags,
|
||||
"%s", message);
|
||||
|
||||
PERL_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::print_y: print message in a buffer with free content
|
||||
*/
|
||||
|
||||
static XS (XS_weechat_print_y)
|
||||
{
|
||||
char *buffer, *message;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("print_y");
|
||||
PERL_RETURN_ERROR;
|
||||
}
|
||||
|
||||
if (items < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("print_y");
|
||||
PERL_RETURN_ERROR;
|
||||
}
|
||||
|
||||
buffer = SvPV (ST (0), PL_na);
|
||||
message = SvPV (ST (2), PL_na);
|
||||
script_api_printf_y (weechat_perl_plugin,
|
||||
perl_current_script,
|
||||
script_str2ptr (buffer),
|
||||
SvIV (ST (1)),
|
||||
"%s", message);
|
||||
|
||||
PERL_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::infobar_print: print message to infobar
|
||||
*/
|
||||
@@ -2413,7 +2486,7 @@ static XS (XS_weechat_buffer_new)
|
||||
if (!perl_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_new");
|
||||
PERL_RETURN_EMPTY;
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (items < 4)
|
||||
@@ -3512,6 +3585,8 @@ weechat_perl_api_init (pTHX)
|
||||
newXS ("weechat::prefix", XS_weechat_prefix, "weechat");
|
||||
newXS ("weechat::color", XS_weechat_color, "weechat");
|
||||
newXS ("weechat::print", XS_weechat_print, "weechat");
|
||||
newXS ("weechat::print_date_tags", XS_weechat_print_date_tags, "weechat");
|
||||
newXS ("weechat::print_y", XS_weechat_print_y, "weechat");
|
||||
newXS ("weechat::infobar_print", XS_weechat_infobar_print, "weechat");
|
||||
newXS ("weechat::infobar_remove", XS_weechat_infobar_remove, "weechat");
|
||||
newXS ("weechat::log_print", XS_weechat_log_print, "weechat");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1598,6 +1598,85 @@ weechat_python_api_prnt (PyObject *self, PyObject *args)
|
||||
PYTHON_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_prnt_date_tags: print message in a buffer with optional
|
||||
* date and tags
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_prnt_date_tags (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *buffer, *tags, *message;
|
||||
int date;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("prnt_date_tags");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
|
||||
buffer = NULL;
|
||||
date = 0;
|
||||
tags = NULL;
|
||||
message = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "siss", &buffer, &time, &tags, &message))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("prnt_date_tags");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
|
||||
script_api_printf_date_tags (weechat_python_plugin,
|
||||
python_current_script,
|
||||
script_str2ptr (buffer),
|
||||
date,
|
||||
tags,
|
||||
"%s", message);
|
||||
|
||||
PYTHON_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_prnt_y: print message in a buffer with free content
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_prnt_y (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *buffer, *message;
|
||||
int y;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("prnt_y");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
|
||||
buffer = NULL;
|
||||
y = 0;
|
||||
message = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "sis", &buffer, &y, &message))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("prnt_y");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
|
||||
script_api_printf_y (weechat_python_plugin,
|
||||
python_current_script,
|
||||
script_str2ptr (buffer),
|
||||
y,
|
||||
"%s", message);
|
||||
|
||||
PYTHON_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_infobar_print: print message to infobar
|
||||
*/
|
||||
@@ -3735,6 +3814,8 @@ PyMethodDef weechat_python_funcs[] =
|
||||
{ "prefix", &weechat_python_api_prefix, METH_VARARGS, "" },
|
||||
{ "color", &weechat_python_api_color, METH_VARARGS, "" },
|
||||
{ "prnt", &weechat_python_api_prnt, METH_VARARGS, "" },
|
||||
{ "prnt_date_tags", &weechat_python_api_prnt_date_tags, METH_VARARGS, "" },
|
||||
{ "prnt_y", &weechat_python_api_prnt_y, METH_VARARGS, "" },
|
||||
{ "infobar_print", &weechat_python_api_infobar_print, METH_VARARGS, "" },
|
||||
{ "infobar_remove", &weechat_python_api_infobar_remove, METH_VARARGS, "" },
|
||||
{ "log_print", &weechat_python_api_log_print, METH_VARARGS, "" },
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -63,6 +63,15 @@ extern void script_api_printf (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_gui_buffer *buffer,
|
||||
char *format, ...);
|
||||
extern void script_api_printf_date_tags (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_gui_buffer *buffer,
|
||||
time_t date, char *tags,
|
||||
char *format, ...);
|
||||
extern void script_api_printf_y (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_gui_buffer *buffer,
|
||||
int y, char *format, ...);
|
||||
extern void script_api_infobar_printf (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
int delay, char *color_name,
|
||||
|
||||
@@ -68,6 +68,17 @@ script_callback_add (struct t_plugin_script *script,
|
||||
script->callbacks = callback;
|
||||
}
|
||||
|
||||
/*
|
||||
* script_callback_free_data: free data of a script callback
|
||||
*/
|
||||
|
||||
void
|
||||
script_callback_free_data (struct t_script_callback *script_callback)
|
||||
{
|
||||
if (script_callback->function)
|
||||
free (script_callback->function);
|
||||
}
|
||||
|
||||
/*
|
||||
* script_callback_remove: remove a callback from a script
|
||||
*/
|
||||
@@ -86,9 +97,7 @@ script_callback_remove (struct t_plugin_script *script,
|
||||
if (script->callbacks == script_callback)
|
||||
script->callbacks = script_callback->next_callback;
|
||||
|
||||
/* free data */
|
||||
if (script_callback->function)
|
||||
free (script_callback->function);
|
||||
script_callback_free_data (script_callback);
|
||||
|
||||
free (script_callback);
|
||||
}
|
||||
@@ -115,15 +124,15 @@ script_callback_print_log (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_script_callback *script_callback)
|
||||
{
|
||||
weechat_log_printf ("");
|
||||
weechat_log_printf ("[callback (addr:0x%x)]", script_callback);
|
||||
weechat_log_printf (" script. . . . . . . : 0x%x", script_callback->script);
|
||||
weechat_log_printf (" function. . . . . . : '%s'", script_callback->function);
|
||||
weechat_log_printf (" config_file . . . . : '%s'", script_callback->config_file);
|
||||
weechat_log_printf (" config_section. . . : '%s'", script_callback->config_section);
|
||||
weechat_log_printf (" config_option . . . : '%s'", script_callback->config_option);
|
||||
weechat_log_printf (" hook. . . . . . . . : 0x%x", script_callback->hook);
|
||||
weechat_log_printf (" buffer. . . . . . . : 0x%x", script_callback->buffer);
|
||||
weechat_log_printf (" bar_item. . . . . . : 0x%x", script_callback->bar_item);
|
||||
weechat_log_printf (" prev_callback . . . : 0x%x", script_callback->prev_callback);
|
||||
weechat_log_printf (" next_callback . . . : 0x%x", script_callback->next_callback);
|
||||
weechat_log_printf (" [callback (addr:0x%x)]", script_callback);
|
||||
weechat_log_printf (" script. . . . . . . : 0x%x", script_callback->script);
|
||||
weechat_log_printf (" function. . . . . . : '%s'", script_callback->function);
|
||||
weechat_log_printf (" config_file . . . . : 0x%x", script_callback->config_file);
|
||||
weechat_log_printf (" config_section. . . : 0x%x", script_callback->config_section);
|
||||
weechat_log_printf (" config_option . . . : 0x%x", script_callback->config_option);
|
||||
weechat_log_printf (" hook. . . . . . . . : 0x%x", script_callback->hook);
|
||||
weechat_log_printf (" buffer. . . . . . . : 0x%x", script_callback->buffer);
|
||||
weechat_log_printf (" bar_item. . . . . . : 0x%x", script_callback->bar_item);
|
||||
weechat_log_printf (" prev_callback . . . : 0x%x", script_callback->prev_callback);
|
||||
weechat_log_printf (" next_callback . . . : 0x%x", script_callback->next_callback);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ struct t_script_callback
|
||||
extern struct t_script_callback *script_callback_alloc ();
|
||||
extern void script_callback_add (struct t_plugin_script *script,
|
||||
struct t_script_callback *callback);
|
||||
extern void script_callback_free_data (struct t_script_callback *script_callback);
|
||||
extern void script_callback_remove (struct t_plugin_script *script,
|
||||
struct t_script_callback *script_callback);
|
||||
extern void script_callback_remove_all (struct t_plugin_script *script);
|
||||
|
||||
@@ -421,6 +421,7 @@ script_remove (struct t_weechat_plugin *weechat_plugin,
|
||||
{
|
||||
weechat_unhook (ptr_script_callback->hook);
|
||||
}
|
||||
|
||||
/* free config file */
|
||||
if (ptr_script_callback->config_file
|
||||
&& !ptr_script_callback->config_section
|
||||
@@ -430,6 +431,7 @@ script_remove (struct t_weechat_plugin *weechat_plugin,
|
||||
weechat_config_write (ptr_script_callback->config_file);
|
||||
weechat_config_free (ptr_script_callback->config_file);
|
||||
}
|
||||
|
||||
/* remove bar item */
|
||||
if (ptr_script_callback->bar_item)
|
||||
weechat_bar_item_remove (ptr_script_callback->bar_item);
|
||||
|
||||
Reference in New Issue
Block a user