core: use buffer pointer instead of window in input functions, add new function window_search_with_buffer in plugin API

v2.8-utf8proc
Sebastien Helleu 2011-04-13 20:25:26 +02:00
parent 7d7eeceb89
commit 7673a700b3
16 changed files with 789 additions and 407 deletions

View File

@ -1,7 +1,7 @@
WeeChat ChangeLog
=================
Sébastien Helleu <flashcode@flashtux.org>
v0.3.5-dev, 2011-04-11
v0.3.5-dev, 2011-04-13
Version 0.3.5 (under dev!)
@ -43,7 +43,7 @@ Version 0.3.5 (under dev!)
* core: dynamically allocate color pairs (extended colors can be used without
being added with command "/color")
* core: allow background for nick colors (using ":")
* api: add new function buffer_match_list
* api: add new functions buffer_match_list and window_search_with_buffer
* aspell: fix spellers used after switch of window (bug #32811)
* irc: do not rejoin channels where /part has been issued before reconnection
to server (bug #33029)

View File

@ -8624,7 +8624,7 @@ Script (Python):
value = weechat.buffer_get_pointer(buffer, property)
# example
weechat.prnt("", "plugin pointer of my buffer: %lx" % weechat.buffer_get_pointer(my_buffer, "plugin"))
weechat.prnt("", "plugin pointer of my buffer: %s" % weechat.buffer_get_pointer(my_buffer, "plugin"))
----------------------------------------
weechat_buffer_set
@ -8977,6 +8977,49 @@ window = weechat.current_window()
current_window = weechat.current_window()
----------------------------------------
weechat_window_search_with_buffer
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_New in version 0.3.5._
Return pointer to window displaying buffer.
Prototype:
[source,C]
----------------------------------------
struct t_gui_window *weechat_window_search_with_buffer (struct t_gui_buffer *buffer);
----------------------------------------
Arguments:
* 'buffer': buffer pointer
Return value:
* pointer to window displaying buffer (NULL if no window is displaying buffer)
C example:
[source,C]
----------------------------------------
weechat_printf (NULL,
"window displaying core buffer: %lx",
weechat_window_search_with_buffer (weechat_buffer_search_main ()));
----------------------------------------
Script (Python):
[source,python]
----------------------------------------
# prototype
window = weechat.window_search_with_buffer(buffer)
# example
weechat.prnt("", "window displaying core buffer: %s"
% weechat.window_search_with_buffer(weechat.buffer_search_main()))
----------------------------------------
weechat_window_get_integer
^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -9104,7 +9147,7 @@ Script (Python):
value = weechat.window_get_pointer(window, property)
# example
weechat.prnt("", "buffer displayed in current window: %lx"
weechat.prnt("", "buffer displayed in current window: %s"
% weechat.window_get_pointer(weechat.current_window(), "buffer"))
----------------------------------------
@ -11243,7 +11286,7 @@ Script (Python):
value = weechat.infolist_pointer(infolist, var)
# example
weechat.prnt("", "pointer = 0x%lx" % weechat.infolist_pointer(infolist, "my_pointer"))
weechat.prnt("", "pointer = 0x%s" % weechat.infolist_pointer(infolist, "my_pointer"))
----------------------------------------
weechat_infolist_buffer

View File

@ -8756,7 +8756,7 @@ Script (Python) :
value = weechat.buffer_get_pointer(buffer, property)
# exemple
weechat.prnt("", "pointeur vers l'extension de mon tampon : %lx" % weechat.buffer_get_pointer(my_buffer, "plugin"))
weechat.prnt("", "pointeur vers l'extension de mon tampon : %s" % weechat.buffer_get_pointer(my_buffer, "plugin"))
----------------------------------------
weechat_buffer_set
@ -9122,6 +9122,50 @@ window = weechat.current_window()
current_window = weechat.current_window()
----------------------------------------
weechat_window_search_with_buffer
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_Nouveau dans la version 0.3.5._
Retourne le pointeur vers la fenêtre affichant un tampon.
Prototype :
[source,C]
----------------------------------------
struct t_gui_window *weechat_window_search_with_buffer (struct t_gui_buffer *buffer);
----------------------------------------
Paramètre :
* 'buffer': buffer pointer
Valeur de retour :
* pointeur vers la fenêtre affichant un tampon (NULL si aucune fenêtre n'affiche
ce tampon)
Exemple en C :
[source,C]
----------------------------------------
weechat_printf (NULL,
"fenêtre affichant le tampon core: %lx",
weechat_window_search_with_buffer (weechat_buffer_search_main ()));
----------------------------------------
Script (Python):
[source,python]
----------------------------------------
# prototype
window = weechat.window_search_with_buffer(buffer)
# exemple
weechat.prnt("", "fenêtre affichant le tampon core: %s"
% weechat.window_search_with_buffer(weechat.buffer_search_main()))
----------------------------------------
weechat_window_get_integer
^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -9257,7 +9301,7 @@ Script (Python) :
value = weechat.window_get_pointer(window, property)
# exemple
weechat.prnt("", "tampon affiché dans la fenêtre courante : %lx"
weechat.prnt("", "tampon affiché dans la fenêtre courante : %s"
% weechat.window_get_pointer(weechat.current_window(), "buffer"))
----------------------------------------
@ -11418,7 +11462,7 @@ Script (Python) :
value = weechat.infolist_pointer(infolist, var)
# exemple
weechat.prnt("", "pointeur = 0x%lx" % weechat.infolist_pointer(infolist, "mon_pointeur"))
weechat.prnt("", "pointeur = 0x%s" % weechat.infolist_pointer(infolist, "mon_pointeur"))
----------------------------------------
weechat_infolist_buffer

View File

@ -8674,7 +8674,7 @@ Script (Python):
value = weechat.buffer_get_pointer(buffer, property)
# esempio
weechat.prnt("", "plugin pointer of my buffer: %lx" % weechat.buffer_get_pointer(my_buffer, "plugin"))
weechat.prnt("", "plugin pointer of my buffer: %s" % weechat.buffer_get_pointer(my_buffer, "plugin"))
----------------------------------------
weechat_buffer_set
@ -9038,6 +9038,50 @@ window = weechat.current_window()
current_window = weechat.current_window()
----------------------------------------
// TRANSLATION MISSING
weechat_window_search_with_buffer
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_Novità nella versione 0.3.5._
Return pointer to window displaying buffer.
Prototipo:
[source,C]
----------------------------------------
struct t_gui_window *weechat_window_search_with_buffer (struct t_gui_buffer *buffer);
----------------------------------------
Argomenti:
* 'buffer': buffer pointer
Valore restituito:
* pointer to window displaying buffer (NULL if no window is displaying buffer)
Esempio in C:
[source,C]
----------------------------------------
weechat_printf (NULL,
"window displaying core buffer: %lx",
weechat_window_search_with_buffer (weechat_buffer_search_main ()));
----------------------------------------
Script (Python):
[source,python]
----------------------------------------
# prototipo
window = weechat.window_search_with_buffer(buffer)
# esempio
weechat.prnt("", "window displaying core buffer: %s"
% weechat.window_search_with_buffer(weechat.buffer_search_main()))
----------------------------------------
weechat_window_get_integer
^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -9168,7 +9212,7 @@ Script (Python):
value = weechat.window_get_pointer(window, property)
# esempio
weechat.prnt("", "buffer displayed in current window: %lx"
weechat.prnt("", "buffer displayed in current window: %s"
% weechat.window_get_pointer(weechat.current_window(), "buffer"))
----------------------------------------
@ -11333,7 +11377,7 @@ Script (Python):
value = weechat.infolist_pointer(infolist, var)
# esempio
weechat.prnt("", "pointer = 0x%lx" % weechat.infolist_pointer(infolist, "my_pointer"))
weechat.prnt("", "pointer = 0x%s" % weechat.infolist_pointer(infolist, "my_pointer"))
----------------------------------------
weechat_infolist_buffer

View File

@ -740,8 +740,7 @@ COMMAND_CALLBACK(buffer)
if (string_strcasecmp (argv[1], "notify") == 0)
{
COMMAND_MIN_ARGS(3, "buffer notify");
config_weechat_notify_set (gui_current_window->buffer,
argv_eol[2]);
config_weechat_notify_set (buffer, argv_eol[2]);
return WEECHAT_RC_OK;
}
@ -860,15 +859,15 @@ COMMAND_CALLBACK(buffer)
if (error && !error[0])
{
/* buffer is currently displayed ? then jump to previous buffer */
if ((number == gui_current_window->buffer->number)
if ((number == buffer->number)
&& (CONFIG_BOOLEAN(config_look_jump_current_to_previous_buffer))
&& gui_buffers_visited)
{
gui_input_jump_previously_visited_buffer (gui_current_window);
gui_input_jump_previously_visited_buffer (buffer);
}
else
{
if (number != gui_current_window->buffer->number)
if (number != buffer->number)
{
gui_buffer_switch_by_number (gui_current_window,
(int) number);
@ -883,8 +882,10 @@ COMMAND_CALLBACK(buffer)
error = NULL;
number = strtol (argv[1], &error, 10);
if (error && !error[0])
{
gui_buffer_switch_by_number (gui_current_window,
(int) number);
}
else
{
ptr_buffer = NULL;
@ -2078,89 +2079,88 @@ COMMAND_CALLBACK(input)
{
/* make C compiler happy */
(void) data;
(void) buffer;
if (argc > 1)
{
if (string_strcasecmp (argv[1], "clipboard_paste") == 0)
gui_input_clipboard_paste (gui_current_window);
gui_input_clipboard_paste (buffer);
else if (string_strcasecmp (argv[1], "return") == 0)
gui_input_return (gui_current_window);
gui_input_return (buffer);
else if (string_strcasecmp (argv[1], "complete_next") == 0)
gui_input_complete_next (gui_current_window);
gui_input_complete_next (buffer);
else if (string_strcasecmp (argv[1], "complete_previous") == 0)
gui_input_complete_previous (gui_current_window);
gui_input_complete_previous (buffer);
else if (string_strcasecmp (argv[1], "search_text") == 0)
gui_input_search_text (gui_current_window);
gui_input_search_text (buffer);
else if (string_strcasecmp (argv[1], "delete_previous_char") == 0)
gui_input_delete_previous_char (gui_current_window);
gui_input_delete_previous_char (buffer);
else if (string_strcasecmp (argv[1], "delete_next_char") == 0)
gui_input_delete_next_char (gui_current_window);
gui_input_delete_next_char (buffer);
else if (string_strcasecmp (argv[1], "delete_previous_word") == 0)
gui_input_delete_previous_word (gui_current_window);
gui_input_delete_previous_word (buffer);
else if (string_strcasecmp (argv[1], "delete_next_word") == 0)
gui_input_delete_next_word (gui_current_window);
gui_input_delete_next_word (buffer);
else if (string_strcasecmp (argv[1], "delete_beginning_of_line") == 0)
gui_input_delete_beginning_of_line (gui_current_window);
gui_input_delete_beginning_of_line (buffer);
else if (string_strcasecmp (argv[1], "delete_end_of_line") == 0)
gui_input_delete_end_of_line (gui_current_window);
gui_input_delete_end_of_line (buffer);
else if (string_strcasecmp (argv[1], "delete_line") == 0)
gui_input_delete_line (gui_current_window);
gui_input_delete_line (buffer);
else if (string_strcasecmp (argv[1], "transpose_chars") == 0)
gui_input_transpose_chars (gui_current_window);
gui_input_transpose_chars (buffer);
else if (string_strcasecmp (argv[1], "move_beginning_of_line") == 0)
gui_input_move_beginning_of_line (gui_current_window);
gui_input_move_beginning_of_line (buffer);
else if (string_strcasecmp (argv[1], "move_end_of_line") == 0)
gui_input_move_end_of_line (gui_current_window);
gui_input_move_end_of_line (buffer);
else if (string_strcasecmp (argv[1], "move_previous_char") == 0)
gui_input_move_previous_char (gui_current_window);
gui_input_move_previous_char (buffer);
else if (string_strcasecmp (argv[1], "move_next_char") == 0)
gui_input_move_next_char (gui_current_window);
gui_input_move_next_char (buffer);
else if (string_strcasecmp (argv[1], "move_previous_word") == 0)
gui_input_move_previous_word (gui_current_window);
gui_input_move_previous_word (buffer);
else if (string_strcasecmp (argv[1], "move_next_word") == 0)
gui_input_move_next_word (gui_current_window);
gui_input_move_next_word (buffer);
else if (string_strcasecmp (argv[1], "history_previous") == 0)
gui_input_history_local_previous (gui_current_window);
gui_input_history_local_previous (buffer);
else if (string_strcasecmp (argv[1], "history_next") == 0)
gui_input_history_local_next (gui_current_window);
gui_input_history_local_next (buffer);
else if (string_strcasecmp (argv[1], "history_global_previous") == 0)
gui_input_history_global_previous (gui_current_window);
gui_input_history_global_previous (buffer);
else if (string_strcasecmp (argv[1], "history_global_next") == 0)
gui_input_history_global_next (gui_current_window);
gui_input_history_global_next (buffer);
else if (string_strcasecmp (argv[1], "jump_smart") == 0)
gui_input_jump_smart (gui_current_window);
gui_input_jump_smart (buffer);
else if (string_strcasecmp (argv[1], "jump_last_buffer") == 0)
gui_input_jump_last_buffer (gui_current_window);
gui_input_jump_last_buffer (buffer);
else if (string_strcasecmp (argv[1], "jump_previously_visited_buffer") == 0)
gui_input_jump_previously_visited_buffer (gui_current_window);
gui_input_jump_previously_visited_buffer (buffer);
else if (string_strcasecmp (argv[1], "jump_next_visited_buffer") == 0)
gui_input_jump_next_visited_buffer (gui_current_window);
gui_input_jump_next_visited_buffer (buffer);
else if (string_strcasecmp (argv[1], "hotlist_clear") == 0)
gui_input_hotlist_clear (gui_current_window);
gui_input_hotlist_clear (buffer);
else if (string_strcasecmp (argv[1], "grab_key") == 0)
gui_input_grab_key (gui_current_window);
gui_input_grab_key (buffer);
else if (string_strcasecmp (argv[1], "grab_key_command") == 0)
gui_input_grab_key_command (gui_current_window);
gui_input_grab_key_command (buffer);
else if (string_strcasecmp (argv[1], "scroll_unread") == 0)
gui_input_scroll_unread (gui_current_window);
gui_input_scroll_unread (buffer);
else if (string_strcasecmp (argv[1], "set_unread") == 0)
gui_input_set_unread ();
else if (string_strcasecmp (argv[1], "set_unread_current_buffer") == 0)
gui_input_set_unread_current (gui_current_window);
gui_input_set_unread_current (buffer);
else if (string_strcasecmp (argv[1], "switch_active_buffer") == 0)
gui_input_switch_active_buffer (gui_current_window);
gui_input_switch_active_buffer (buffer);
else if (string_strcasecmp (argv[1], "switch_active_buffer_previous") == 0)
gui_input_switch_active_buffer_previous (gui_current_window);
gui_input_switch_active_buffer_previous (buffer);
else if (string_strcasecmp (argv[1], "insert") == 0)
{
if (argc > 2)
gui_input_insert (gui_current_window, argv_eol[2]);
gui_input_insert (buffer, argv_eol[2]);
}
else if (string_strcasecmp (argv[1], "undo") == 0)
gui_input_undo (gui_current_window);
gui_input_undo (buffer);
else if (string_strcasecmp (argv[1], "redo") == 0)
gui_input_redo (gui_current_window);
gui_input_redo (buffer);
}
return WEECHAT_RC_OK;

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,6 @@
#define __WEECHAT_GUI_INPUT_H 1
struct t_gui_buffer;
struct t_gui_window;
/* input variables */
@ -39,43 +38,43 @@ extern int gui_input_insert_string (struct t_gui_buffer *buffer,
const char *string, int pos);
extern void gui_input_move_to_buffer (struct t_gui_buffer *from_buffer,
struct t_gui_buffer *to_buffer);
extern void gui_input_clipboard_paste (struct t_gui_window *window);
extern void gui_input_return (struct t_gui_window *window);
extern void gui_input_complete_next (struct t_gui_window *window);
extern void gui_input_complete_previous (struct t_gui_window *window);
extern void gui_input_search_text (struct t_gui_window *window);
extern void gui_input_delete_previous_char (struct t_gui_window *window);
extern void gui_input_delete_next_char (struct t_gui_window *window);
extern void gui_input_delete_previous_word (struct t_gui_window *window);
extern void gui_input_delete_next_word (struct t_gui_window *window);
extern void gui_input_delete_beginning_of_line (struct t_gui_window *window);
extern void gui_input_delete_end_of_line (struct t_gui_window *window);
extern void gui_input_delete_line (struct t_gui_window *window);
extern void gui_input_transpose_chars (struct t_gui_window *window);
extern void gui_input_move_beginning_of_line (struct t_gui_window *window);
extern void gui_input_move_end_of_line (struct t_gui_window *window);
extern void gui_input_move_previous_char (struct t_gui_window *window);
extern void gui_input_move_next_char (struct t_gui_window *window);
extern void gui_input_move_previous_word (struct t_gui_window *window);
extern void gui_input_move_next_word (struct t_gui_window *window);
extern void gui_input_history_local_previous (struct t_gui_window *window);
extern void gui_input_history_local_next (struct t_gui_window *window);
extern void gui_input_history_global_previous (struct t_gui_window *window);
extern void gui_input_history_global_next (struct t_gui_window *window);
extern void gui_input_jump_smart (struct t_gui_window *window);
extern void gui_input_jump_last_buffer (struct t_gui_window *window);
extern void gui_input_jump_previously_visited_buffer (struct t_gui_window *window);
extern void gui_input_jump_next_visited_buffer (struct t_gui_window *window);
extern void gui_input_hotlist_clear (struct t_gui_window *window);
extern void gui_input_grab_key (struct t_gui_window *window);
extern void gui_input_grab_key_command (struct t_gui_window *window);
extern void gui_input_scroll_unread (struct t_gui_window *window);
extern void gui_input_clipboard_paste (struct t_gui_buffer *buffer);
extern void gui_input_return (struct t_gui_buffer *buffer);
extern void gui_input_complete_next (struct t_gui_buffer *buffer);
extern void gui_input_complete_previous (struct t_gui_buffer *buffer);
extern void gui_input_search_text (struct t_gui_buffer *buffer);
extern void gui_input_delete_previous_char (struct t_gui_buffer *buffer);
extern void gui_input_delete_next_char (struct t_gui_buffer *buffer);
extern void gui_input_delete_previous_word (struct t_gui_buffer *buffer);
extern void gui_input_delete_next_word (struct t_gui_buffer *buffer);
extern void gui_input_delete_beginning_of_line (struct t_gui_buffer *buffer);
extern void gui_input_delete_end_of_line (struct t_gui_buffer *buffer);
extern void gui_input_delete_line (struct t_gui_buffer *buffer);
extern void gui_input_transpose_chars (struct t_gui_buffer *buffer);
extern void gui_input_move_beginning_of_line (struct t_gui_buffer *buffer);
extern void gui_input_move_end_of_line (struct t_gui_buffer *buffer);
extern void gui_input_move_previous_char (struct t_gui_buffer *buffer);
extern void gui_input_move_next_char (struct t_gui_buffer *buffer);
extern void gui_input_move_previous_word (struct t_gui_buffer *buffer);
extern void gui_input_move_next_word (struct t_gui_buffer *buffer);
extern void gui_input_history_local_previous (struct t_gui_buffer *buffer);
extern void gui_input_history_local_next (struct t_gui_buffer *buffer);
extern void gui_input_history_global_previous (struct t_gui_buffer *buffer);
extern void gui_input_history_global_next (struct t_gui_buffer *buffer);
extern void gui_input_jump_smart (struct t_gui_buffer *buffer);
extern void gui_input_jump_last_buffer (struct t_gui_buffer *buffer);
extern void gui_input_jump_previously_visited_buffer (struct t_gui_buffer *buffer);
extern void gui_input_jump_next_visited_buffer (struct t_gui_buffer *buffer);
extern void gui_input_hotlist_clear (struct t_gui_buffer *buffer);
extern void gui_input_grab_key (struct t_gui_buffer *buffer);
extern void gui_input_grab_key_command (struct t_gui_buffer *buffer);
extern void gui_input_scroll_unread (struct t_gui_buffer *buffer);
extern void gui_input_set_unread ();
extern void gui_input_set_unread_current (struct t_gui_window *window);
extern void gui_input_switch_active_buffer (struct t_gui_window *window);
extern void gui_input_switch_active_buffer_previous (struct t_gui_window *window);
extern void gui_input_insert (struct t_gui_window *window, const char *args);
extern void gui_input_undo (struct t_gui_window *window);
extern void gui_input_redo (struct t_gui_window *window);
extern void gui_input_set_unread_current (struct t_gui_buffer *buffer);
extern void gui_input_switch_active_buffer (struct t_gui_buffer *buffer);
extern void gui_input_switch_active_buffer_previous (struct t_gui_buffer *buffer);
extern void gui_input_insert (struct t_gui_buffer *buffer, const char *args);
extern void gui_input_undo (struct t_gui_buffer *buffer);
extern void gui_input_redo (struct t_gui_buffer *buffer);
#endif /* __WEECHAT_GUI_INPUT_H */

View File

@ -483,6 +483,38 @@ gui_window_valid (struct t_gui_window *window)
return 0;
}
/*
* gui_window_search_with_buffer: search window displaying a buffer
* return NULL if no window is displaying given
* buffer
* If many windows are displaying this buffer,
* the first window in list is returned (or
* current window if it is displaying this
* buffer)
*/
struct t_gui_window *
gui_window_search_with_buffer (struct t_gui_buffer *buffer)
{
struct t_gui_window *ptr_window;
if (!buffer)
return NULL;
if (gui_current_window->buffer == buffer)
return gui_current_window;
for (ptr_window = gui_windows; ptr_window;
ptr_window = ptr_window->next_window)
{
if (ptr_window->buffer == buffer)
return ptr_window;
}
/* no window displaying buffer */
return NULL;
}
/*
* gui_window_get_integer: get a window property as integer
*/
@ -1064,7 +1096,7 @@ gui_window_search_start (struct t_gui_window *window)
if (window->buffer->input_buffer && window->buffer->input_buffer[0])
window->buffer->text_search_input =
strdup (window->buffer->input_buffer);
gui_input_delete_line (window);
gui_input_delete_line (window->buffer);
}
/*
@ -1101,7 +1133,7 @@ gui_window_search_stop (struct t_gui_window *window)
{
window->buffer->text_search = GUI_TEXT_SEARCH_DISABLED;
window->buffer->text_search = 0;
gui_input_delete_line (window);
gui_input_delete_line (window->buffer);
if (window->buffer->text_search_input)
{
gui_input_insert_string (window->buffer,

View File

@ -128,6 +128,7 @@ extern struct t_gui_window *gui_window_new (struct t_gui_window *parent_window,
int x, int y, int width, int height,
int width_pct, int height_pct);
extern int gui_window_valid (struct t_gui_window *window);
extern struct t_gui_window *gui_window_search_with_buffer (struct t_gui_buffer *buffer);
extern int gui_window_get_integer (struct t_gui_window *window,
const char *property);
extern const char *gui_window_get_string (struct t_gui_window *window,

View File

@ -621,6 +621,7 @@ plugin_load (const char *filename)
new_plugin->buffer_string_replace_local_var = &gui_buffer_string_replace_local_var;
new_plugin->buffer_match_list = &gui_buffer_match_list;
new_plugin->window_search_with_buffer = &gui_window_search_with_buffer;
new_plugin->window_get_integer = &gui_window_get_integer;
new_plugin->window_get_string = &gui_window_get_string;
new_plugin->window_get_pointer = &gui_window_get_pointer;

View File

@ -5302,6 +5302,42 @@ weechat_lua_api_current_window (lua_State *L)
LUA_RETURN_STRING_FREE(result);
}
/*
* weechat_lua_api_window_search_with_buffer: search a window with buffer
* pointer
*/
static int
weechat_lua_api_window_search_with_buffer (lua_State *L)
{
const char *buffer;
char *result;
int n;
/* make C compiler happy */
(void) L;
if (!lua_current_script || !lua_current_script->name)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "window_search_with_buffer");
LUA_RETURN_EMPTY;
}
n = lua_gettop (lua_current_interpreter);
if (n < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "window_search_with_buffer");
LUA_RETURN_EMPTY;
}
buffer = lua_tostring (lua_current_interpreter, -1);
result = script_ptr2str (weechat_window_search_with_buffer (script_str2ptr (buffer)));
LUA_RETURN_STRING_FREE(result);
}
/*
* weechat_lua_api_window_get_integer: get a window property as integer
*/
@ -7807,6 +7843,7 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
{ "buffer_string_replace_local_var", &weechat_lua_api_buffer_string_replace_local_var },
{ "buffer_match_list", &weechat_lua_api_buffer_match_list },
{ "current_window", &weechat_lua_api_current_window },
{ "window_search_with_buffer", &weechat_lua_api_window_search_with_buffer },
{ "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 },

View File

@ -4822,6 +4822,36 @@ XS (XS_weechat_api_current_window)
PERL_RETURN_STRING_FREE(result);
}
/*
* weechat::window_search_with_buffer: search a window with buffer pointer
*/
XS (XS_weechat_api_window_search_with_buffer)
{
char *result;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script || !perl_current_script->name)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "window_search_with_buffer");
PERL_RETURN_EMPTY;
}
if (items < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "window_search_with_buffer");
PERL_RETURN_EMPTY;
}
result = script_ptr2str (weechat_window_search_with_buffer (script_str2ptr (SvPV (ST (0), PL_na))));
PERL_RETURN_STRING_FREE(result);
}
/*
* weechat::window_get_integer: get a window property as integer
*/
@ -6742,6 +6772,7 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::buffer_string_replace_local_var", XS_weechat_api_buffer_string_replace_local_var, "weechat");
newXS ("weechat::buffer_match_list", XS_weechat_api_buffer_match_list, "weechat");
newXS ("weechat::current_window", XS_weechat_api_current_window, "weechat");
newXS ("weechat::window_search_with_buffer", XS_weechat_api_window_search_with_buffer, "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");

View File

@ -5080,6 +5080,39 @@ weechat_python_api_current_window (PyObject *self, PyObject *args)
PYTHON_RETURN_STRING_FREE(result);
}
/*
* weechat_python_api_window_search_with_buffer: search a window with buffer
* pointer
*/
static PyObject *
weechat_python_api_window_search_with_buffer (PyObject *self, PyObject *args)
{
char *buffer, *result;
PyObject *object;
/* make C compiler happy */
(void) self;
if (!python_current_script || !python_current_script->name)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "window_search_with_buffer");
PYTHON_RETURN_EMPTY;
}
buffer = NULL;
if (!PyArg_ParseTuple (args, "s", &buffer))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "window_search_with_buffer");
PYTHON_RETURN_EMPTY;
}
result = script_ptr2str (weechat_window_search_with_buffer (script_str2ptr (buffer)));
PYTHON_RETURN_STRING_FREE(result);
}
/*
* weechat_python_api_window_get_integer get a window property as integer
*/
@ -7076,6 +7109,7 @@ PyMethodDef weechat_python_funcs[] =
{ "buffer_string_replace_local_var", &weechat_python_api_buffer_string_replace_local_var, METH_VARARGS, "" },
{ "buffer_match_list", &weechat_python_api_buffer_match_list, METH_VARARGS, "" },
{ "current_window", &weechat_python_api_current_window, METH_VARARGS, "" },
{ "window_search_with_buffer", &weechat_python_api_window_search_with_buffer, 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, "" },

View File

@ -5497,6 +5497,41 @@ weechat_ruby_api_current_window (VALUE class)
RUBY_RETURN_STRING_FREE(result);
}
/*
* weechat_ruby_api_window_search_with_buffer: search a window with buffer
* pointer
*/
static VALUE
weechat_ruby_api_window_search_with_buffer (VALUE class, VALUE buffer)
{
char *c_buffer, *result;
VALUE return_value;
/* make C compiler happy */
(void) class;
if (!ruby_current_script || !ruby_current_script->name)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "window_search_with_buffer");
RUBY_RETURN_EMPTY;
}
if (NIL_P (buffer))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "window_search_with_buffer");
RUBY_RETURN_EMPTY;
}
Check_Type (buffer, T_STRING);
c_buffer = StringValuePtr (buffer);
result = script_ptr2str (weechat_window_search_with_buffer (script_str2ptr (c_buffer)));
RUBY_RETURN_STRING_FREE(result);
}
/*
* weechat_ruby_api_window_get_integer: get a window property as integer
*/
@ -7745,6 +7780,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
rb_define_module_function (ruby_mWeechat, "buffer_string_replace_local_var", &weechat_ruby_api_buffer_string_replace_local_var, 2);
rb_define_module_function (ruby_mWeechat, "buffer_match_list", &weechat_ruby_api_buffer_match_list, 2);
rb_define_module_function (ruby_mWeechat, "current_window", &weechat_ruby_api_current_window, 0);
rb_define_module_function (ruby_mWeechat, "window_search_with_buffer", &weechat_ruby_api_window_search_with_buffer, 1);
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);

View File

@ -5390,6 +5390,41 @@ weechat_tcl_api_current_window (ClientData clientData, Tcl_Interp *interp,
TCL_RETURN_STRING_FREE(result);
}
/*
* weechat_tcl_api_window_search_with_buffer: search a window with buffer
* pointer
*/
static int
weechat_tcl_api_window_search_with_buffer (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *objp;
char *buffer, *result;
int i;
/* make C compiler happy */
(void) clientData;
if (!tcl_current_script || !tcl_current_script->name)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "window_search_with_buffer");
TCL_RETURN_EMPTY;
}
if (objc < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "window_search_with_buffer");
TCL_RETURN_EMPTY;
}
buffer = Tcl_GetStringFromObj (objv[1], &i);
result = script_ptr2str (weechat_window_search_with_buffer (script_str2ptr (buffer)));
TCL_RETURN_STRING_FREE(result);
}
/*
* weechat_tcl_api_window_get_integer: get a window property as integer
*/
@ -7690,6 +7725,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
weechat_tcl_api_buffer_match_list, (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_search_with_buffer",
weechat_tcl_api_window_search_with_buffer, (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",

View File

@ -45,7 +45,7 @@ struct timeval;
*/
/* API version (used to check that plugin has same API and can be loaded) */
#define WEECHAT_PLUGIN_API_VERSION "20110311-01"
#define WEECHAT_PLUGIN_API_VERSION "20110413-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@ -600,6 +600,7 @@ struct t_weechat_plugin
int (*buffer_match_list) (struct t_gui_buffer *buffer, const char *string);
/* windows */
struct t_gui_window *(*window_search_with_buffer) (struct t_gui_buffer *buffer);
int (*window_get_integer) (struct t_gui_window *window,
const char *property);
const char *(*window_get_string) (struct t_gui_window *window,
@ -1260,6 +1261,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
weechat_plugin->buffer_match_list(__buffer, __string)
/* windows */
#define weechat_window_search_with_buffer(__buffer) \
weechat_plugin->window_search_with_buffer(__buffer)
#define weechat_window_get_integer(__window, __property) \
weechat_plugin->window_get_integer(__window, __property)
#define weechat_window_get_string(__window, __property) \