1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-26 04:46:37 +02:00

Add current_window function in plugin API, add window functions in english developer guide

This commit is contained in:
Sebastien Helleu
2008-11-29 16:08:55 +01:00
parent 364aa00ab7
commit bc00946a0d
12 changed files with 428 additions and 17 deletions
+257 -1
View File
@@ -6345,7 +6345,7 @@ weechat_buffer_close (my_buffer);
<para>
Prototype:
<programlisting>
int weechat_buffer_integer (struct t_gui_buffer *buffer, const char *property);
int weechat_buffer_get_integer (struct t_gui_buffer *buffer, const char *property);
</programlisting>
</para>
<para>
@@ -6884,6 +6884,262 @@ free (str);
</section>
<!-- ============================[ windows ]============================= -->
<section id="secPluginCApi_windows">
<title>Windows</title>
<para>
Functions to query windows.
</para>
<section id="secPluginCApi_weechat_current_window">
<title>weechat_current_windowr</title>
<para>
Prototype:
<programlisting>
struct t_gui_window *weechat_current_window ();
</programlisting>
</para>
<para>
Return pointer to current window.
</para>
<para>
Return value: pointer to current window.
</para>
<para>
Example:
<screen>
struct t_gui_window *current_window = weechat_current_window ();
</screen>
</para>
</section>
<section id="secPluginCApi_weechat_window_get_integer">
<title>weechat_window_get_integer</title>
<para>
Prototype:
<programlisting>
int weechat_window_get_integer (struct t_gui_window *window, const char *property);
</programlisting>
</para>
<para>
Get integer value of a window property.
</para>
<para>
Arguments:
<itemizedlist>
<listitem>
<para>
<option>window</option>: window pointer
</para>
</listitem>
<listitem>
<para>
<option>property</option>: property name:
<informaltable colsep="0" frame="none">
<tgroup cols="2">
<thead>
<row>
<entry>Name</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>win_x</entry>
<entry>
X position of window in terminal (0 is first column)
</entry>
</row>
<row>
<entry>win_y</entry>
<entry>
Y position of window in terminal (0 is first column)
</entry>
</row>
<row>
<entry>win_width</entry>
<entry>width of window, in chars</entry>
</row>
<row>
<entry>win_height</entry>
<entry>height of window, in chars</entry>
</row>
<row>
<entry>win_width_pct</entry>
<entry>
percentage size, compared to parent window (if 50,
width is half)
</entry>
</row>
<row>
<entry>win_height_pct</entry>
<entry>
percentage size, compared to parent window (if 50,
height is half)
</entry>
</row>
<row>
<entry>win_chat_x</entry>
<entry>
X position of chat window in terminal (0 is first
column)
</entry>
</row>
<row>
<entry>win_chat_y</entry>
<entry>
Y position of chat window in terminal (0 is first
column)
</entry>
</row>
<row>
<entry>win_chat_width</entry>
<entry>width of chat window, in chars</entry>
</row>
<row>
<entry>win_chat_height</entry>
<entry>height of chat window, in chars</entry>
</row>
<row>
<entry>first_line_displayed</entry>
<entry>
1 if first line of buffer is displayed on screen,
otherwise 0
</entry>
</row>
<row>
<entry>scroll</entry>
<entry>
1 if scroll is active on window (last line not
displayed)
</entry>
</row>
<row>
<entry>scroll_lines_after</entry>
<entry>
number of lines not displayed after last one displayed
(when scrolling)
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</listitem>
</itemizedlist>
</para>
<para>
Return value: integer value of property.
</para>
<para>
Example:
<screen>
weechat_printf (NULL, "current window is at position (x,y): (%d,%d)",
weechat_window_get_integer (weechat_current_window, "win_x"),
weechat_window_get_integer (weechat_current_window, "win_y"));
</screen>
</para>
</section>
<section id="secPluginCApi_weechat_window_get_string">
<title>weechat_window_get_string</title>
<para>
Prototype:
<programlisting>
const char *weechat_window_get_string (struct t_gui_window *window, const char *property);
</programlisting>
</para>
<para>
Get string value of a window property. NOT USED TODAY, reserved for
future version.
</para>
<para>
Arguments:
<itemizedlist>
<listitem>
<para>
<option>window</option>: window pointer
</para>
</listitem>
<listitem>
<para>
<option>property</option>: property name
</para>
</listitem>
</itemizedlist>
</para>
<para>
Return value: string value of property.
</para>
</section>
<section id="secPluginCApi_weechat_window_get_pointer">
<title>weechat_window_get_pointer</title>
<para>
Prototype:
<programlisting>
void *weechat_window_get_pointer (struct t_gui_window *window, const char *property);
</programlisting>
</para>
<para>
Get pointer value of a window property.
</para>
<para>
Arguments:
<itemizedlist>
<listitem>
<para>
<option>window</option>: window pointer
</para>
</listitem>
<listitem>
<para>
<option>property</option>: property name:
<informaltable colsep="0" frame="none">
<tgroup cols="2">
<thead>
<row>
<entry>Name</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>current</entry>
<entry>current window pointer</entry>
</row>
<row>
<entry>buffer</entry>
<entry>pointer to buffer displayed by window</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</listitem>
</itemizedlist>
</para>
<para>
Return value: pointer value of property.
</para>
<para>
Example:
<screen>
weechat_printf (NULL, "current window pointer is: %lx, buffer displayed is: %lx",
weechat_window_get_pointer (NULL, "current"),
weechat_window_get_integer (weechat_current_window, "buffer"));
</screen>
</para>
</section>
</section>
<!-- ============================[ nicklist ]============================ -->
<section id="secPluginCApi_nicklist">
+26
View File
@@ -291,6 +291,32 @@ gui_window_get_integer (struct t_gui_window *window, const char *property)
{
if (window && property)
{
if (string_strcasecmp (property, "win_x") == 0)
return window->win_x;
if (string_strcasecmp (property, "win_y") == 0)
return window->win_y;
if (string_strcasecmp (property, "win_width") == 0)
return window->win_width;
if (string_strcasecmp (property, "win_height") == 0)
return window->win_height;
if (string_strcasecmp (property, "win_width_pct") == 0)
return window->win_width_pct;
if (string_strcasecmp (property, "win_height_pct") == 0)
return window->win_height_pct;
if (string_strcasecmp (property, "win_chat_x") == 0)
return window->win_chat_x;
if (string_strcasecmp (property, "win_chat_y") == 0)
return window->win_chat_y;
if (string_strcasecmp (property, "win_chat_width") == 0)
return window->win_chat_width;
if (string_strcasecmp (property, "win_chat_height") == 0)
return window->win_chat_height;
if (string_strcasecmp (property, "first_line_displayed") == 0)
return window->first_line_displayed;
if (string_strcasecmp (property, "scroll") == 0)
return window->scroll;
if (string_strcasecmp (property, "scroll_lines_after") == 0)
return window->scroll_lines_after;
}
return 0;
+4 -4
View File
@@ -107,7 +107,7 @@ weechat_aspell_config_change_default_dict (void *data,
(void) data;
(void) option;
weechat_aspell_create_spellers (weechat_current_buffer);
weechat_aspell_create_spellers (weechat_current_buffer ());
}
/*
@@ -122,7 +122,7 @@ weechat_aspell_config_dict_change (void *data,
(void) data;
(void) option;
weechat_aspell_create_spellers (weechat_current_buffer);
weechat_aspell_create_spellers (weechat_current_buffer ());
}
/*
@@ -141,7 +141,7 @@ weechat_aspell_config_dict_delete_option (void *data,
(void) section;
weechat_config_option_free (option);
weechat_aspell_create_spellers (weechat_current_buffer);
weechat_aspell_create_spellers (weechat_current_buffer ());
return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
}
@@ -209,7 +209,7 @@ weechat_aspell_config_dict_create_option (void *data,
option_name, value);
}
else
weechat_aspell_create_spellers (weechat_current_buffer);
weechat_aspell_create_spellers (weechat_current_buffer ());
return rc;
}
+1 -1
View File
@@ -970,7 +970,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
weechat_hook_modifier ("weechat_input_text_display",
&weechat_aspell_modifier_cb, NULL);
weechat_aspell_create_spellers (weechat_current_buffer);
weechat_aspell_create_spellers (weechat_current_buffer ());
return WEECHAT_RC_OK;
}
+1 -1
View File
@@ -185,7 +185,7 @@ fifo_exec (const char *text)
if (text2[0] == '*')
{
pos_msg = text2 + 1;
ptr_buffer = weechat_current_buffer;
ptr_buffer = weechat_current_buffer ();
}
else
{
+3 -3
View File
@@ -52,7 +52,7 @@ irc_bar_item_buffer_title (void *data, struct t_gui_bar_item *item,
(void) max_height;
if (!window)
window = weechat_current_window;
window = weechat_current_window ();
buffer = weechat_window_get_pointer (window, "buffer");
@@ -93,7 +93,7 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item,
(void) max_height;
if (!window)
window = weechat_current_window;
window = weechat_current_window ();
buf_name[0] = '\0';
modes[0] = '\0';
@@ -251,7 +251,7 @@ irc_bar_item_input_prompt (void *data, struct t_gui_bar_item *item,
(void) max_height;
if (!window)
window = weechat_current_window;
window = weechat_current_window ();
buffer = weechat_window_get_pointer (window, "buffer");
+25 -1
View File
@@ -3748,7 +3748,7 @@ weechat_lua_api_current_buffer (lua_State *L)
LUA_RETURN_EMPTY;
}
result = script_ptr2str (weechat_current_buffer);
result = script_ptr2str (weechat_current_buffer ());
LUA_RETURN_STRING_FREE(result);
}
@@ -3984,6 +3984,29 @@ weechat_lua_api_buffer_set (lua_State *L)
LUA_RETURN_OK;
}
/*
* weechat_lua_api_current_window: get current window
*/
static int
weechat_lua_api_current_window (lua_State *L)
{
char *result;
/* make C compiler happy */
(void) L;
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("current_window");
LUA_RETURN_EMPTY;
}
result = script_ptr2str (weechat_current_window ());
LUA_RETURN_STRING_FREE(result);
}
/*
* weechat_lua_api_window_get_integer: get a window property as integer
*/
@@ -5893,6 +5916,7 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
{ "buffer_get_string", &weechat_lua_api_buffer_get_string },
{ "buffer_get_pointer", &weechat_lua_api_buffer_get_pointer },
{ "buffer_set", &weechat_lua_api_buffer_set },
{ "current_window", &weechat_lua_api_current_window },
{ "window_get_integer", &weechat_lua_api_window_get_integer },
{ "window_get_string", &weechat_lua_api_window_get_string },
{ "window_get_pointer", &weechat_lua_api_window_get_pointer },
+26 -1
View File
@@ -3173,7 +3173,7 @@ static XS (XS_weechat_api_current_buffer)
PERL_RETURN_EMPTY;
}
result = script_ptr2str (weechat_current_buffer);
result = script_ptr2str (weechat_current_buffer ());
PERL_RETURN_STRING_FREE(result);
}
@@ -3364,6 +3364,30 @@ static XS (XS_weechat_api_buffer_set)
PERL_RETURN_OK;
}
/*
* weechat::current_window: get current window
*/
static XS (XS_weechat_api_current_window)
{
char *result;
dXSARGS;
/* make C compiler happy */
(void) items;
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("current_window");
PERL_RETURN_EMPTY;
}
result = script_ptr2str (weechat_current_window ());
PERL_RETURN_STRING_FREE(result);
}
/*
* weechat::window_get_integer: get a window property as integer
*/
@@ -4633,6 +4657,7 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::buffer_get_string", XS_weechat_api_buffer_get_string, "weechat");
newXS ("weechat::buffer_get_pointer", XS_weechat_api_buffer_get_pointer, "weechat");
newXS ("weechat::buffer_set", XS_weechat_api_buffer_set, "weechat");
newXS ("weechat::current_window", XS_weechat_api_current_window, "weechat");
newXS ("weechat::window_get_integer", XS_weechat_api_window_get_integer, "weechat");
newXS ("weechat::window_get_string", XS_weechat_api_window_get_string, "weechat");
newXS ("weechat::window_get_pointer", XS_weechat_api_window_get_pointer, "weechat");
@@ -3365,7 +3365,7 @@ weechat_python_api_current_buffer (PyObject *self, PyObject *args)
PYTHON_RETURN_EMPTY;
}
result = script_ptr2str (weechat_current_buffer);
result = script_ptr2str (weechat_current_buffer ());
PYTHON_RETURN_STRING_FREE(result);
}
@@ -3569,6 +3569,31 @@ weechat_python_api_buffer_set (PyObject *self, PyObject *args)
PYTHON_RETURN_OK;
}
/*
* weechat_python_api_current_window: get current window
*/
static PyObject *
weechat_python_api_current_window (PyObject *self, PyObject *args)
{
char *result;
PyObject *object;
/* make C compiler happy */
(void) self;
(void) args;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("current_window");
PYTHON_RETURN_EMPTY;
}
result = script_ptr2str (weechat_current_window ());
PYTHON_RETURN_STRING_FREE(result);
}
/*
* weechat_python_api_window_get_integer get a window property as integer
*/
@@ -4922,6 +4947,7 @@ PyMethodDef weechat_python_funcs[] =
{ "buffer_get_string", &weechat_python_api_buffer_get_string, METH_VARARGS, "" },
{ "buffer_get_pointer", &weechat_python_api_buffer_get_pointer, METH_VARARGS, "" },
{ "buffer_set", &weechat_python_api_buffer_set, METH_VARARGS, "" },
{ "current_window", &weechat_python_api_current_window, METH_VARARGS, "" },
{ "window_get_integer", &weechat_python_api_window_get_integer, METH_VARARGS, "" },
{ "window_get_string", &weechat_python_api_window_get_string, METH_VARARGS, "" },
{ "window_get_pointer", &weechat_python_api_window_get_pointer, METH_VARARGS, "" },
+26 -1
View File
@@ -3850,7 +3850,7 @@ weechat_ruby_api_current_buffer (VALUE class)
RUBY_RETURN_EMPTY;
}
result = script_ptr2str (weechat_current_buffer);
result = script_ptr2str (weechat_current_buffer ());
RUBY_RETURN_STRING_FREE(result);
}
@@ -4078,6 +4078,30 @@ weechat_ruby_api_buffer_set (VALUE class, VALUE buffer, VALUE property,
RUBY_RETURN_OK;
}
/*
* weechat_ruby_api_current_window: get current window
*/
static VALUE
weechat_ruby_api_current_window (VALUE class)
{
char *result;
VALUE return_value;
/* make C compiler happy */
(void) class;
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("current_window");
RUBY_RETURN_EMPTY;
}
result = script_ptr2str (weechat_current_window ());
RUBY_RETURN_STRING_FREE(result);
}
/*
* weechat_ruby_api_window_get_integer: get a window property as integer
*/
@@ -5653,6 +5677,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
rb_define_module_function (ruby_mWeechat, "buffer_get_string", &weechat_ruby_api_buffer_get_string, 2);
rb_define_module_function (ruby_mWeechat, "buffer_get_pointer", &weechat_ruby_api_buffer_get_pointer, 2);
rb_define_module_function (ruby_mWeechat, "buffer_set", &weechat_ruby_api_buffer_set, 3);
rb_define_module_function (ruby_mWeechat, "current_window", &weechat_ruby_api_current_window, 0);
rb_define_module_function (ruby_mWeechat, "window_get_integer", &weechat_ruby_api_window_get_integer, 2);
rb_define_module_function (ruby_mWeechat, "window_get_string", &weechat_ruby_api_window_get_string, 2);
rb_define_module_function (ruby_mWeechat, "window_get_pointer", &weechat_ruby_api_window_get_pointer, 2);
+30 -1
View File
@@ -3605,7 +3605,7 @@ weechat_tcl_api_current_buffer (ClientData clientData, Tcl_Interp *interp,
TCL_RETURN_EMPTY;
}
result = script_ptr2str (weechat_current_buffer);
result = script_ptr2str (weechat_current_buffer ());
TCL_RETURN_STRING_FREE(result);
}
@@ -3818,6 +3818,33 @@ weechat_tcl_api_buffer_set (ClientData clientData, Tcl_Interp *interp,
TCL_RETURN_OK;
}
/*
* weechat_tcl_api_current_window: get current window
*/
static int
weechat_tcl_api_current_window (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_INITIALIZED("current_window");
TCL_RETURN_EMPTY;
}
result = script_ptr2str (weechat_current_window ());
TCL_RETURN_STRING_FREE(result);
}
/*
* weechat_tcl_api_window_get_integer: get a window property as integer
*/
@@ -5378,6 +5405,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::current_window",
weechat_tcl_api_current_window, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::window_get_integer",
weechat_tcl_api_window_get_integer, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::window_get_string",
+2 -2
View File
@@ -930,7 +930,7 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
__close_callback, __close_callback_data)
#define weechat_buffer_search(__plugin, __name) \
weechat_plugin->buffer_search(__plugin, __name)
#define weechat_current_buffer \
#define weechat_current_buffer() \
weechat_plugin->buffer_search(NULL, NULL)
#define weechat_buffer_clear(__buffer) \
weechat_plugin->buffer_clear(__buffer)
@@ -956,7 +956,7 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
weechat_plugin->window_get_string(__window, __property)
#define weechat_window_get_pointer(__window, __property) \
weechat_plugin->window_get_pointer(__window, __property)
#define weechat_current_window \
#define weechat_current_window() \
weechat_plugin->window_get_pointer(NULL, "current")
/* nicklist */