mirror of
https://github.com/weechat/weechat.git
synced 2026-07-05 09:13:14 +02:00
api: add function line_search_by_id
This commit is contained in:
@@ -3875,6 +3875,22 @@ weechat_guile_api_buffer_match_list (SCM buffer, SCM string)
|
||||
API_RETURN_INT(value);
|
||||
}
|
||||
|
||||
SCM
|
||||
weechat_guile_api_line_search_by_id (SCM buffer, SCM id)
|
||||
{
|
||||
const char *result;
|
||||
SCM return_value;
|
||||
|
||||
API_INIT_FUNC(1, "line_search_by_id", API_RETURN_EMPTY);
|
||||
if (!scm_is_string (buffer) || !scm_is_integer (id))
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
result = API_PTR2STR(weechat_line_search_by_id (API_STR2PTR(API_SCM_TO_STRING(buffer)),
|
||||
scm_to_int (id)));
|
||||
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
SCM
|
||||
weechat_guile_api_current_window ()
|
||||
{
|
||||
@@ -5557,6 +5573,7 @@ weechat_guile_api_module_init (void *data)
|
||||
API_DEF_FUNC(buffer_set, 3);
|
||||
API_DEF_FUNC(buffer_string_replace_local_var, 2);
|
||||
API_DEF_FUNC(buffer_match_list, 2);
|
||||
API_DEF_FUNC(line_search_by_id, 2);
|
||||
API_DEF_FUNC(current_window, 0);
|
||||
API_DEF_FUNC(window_search_with_buffer, 1);
|
||||
API_DEF_FUNC(window_get_integer, 2);
|
||||
|
||||
@@ -3808,6 +3808,22 @@ API_FUNC(buffer_match_list)
|
||||
API_RETURN_INT(value);
|
||||
}
|
||||
|
||||
API_FUNC(line_search_by_id)
|
||||
{
|
||||
const char *result;
|
||||
int id;
|
||||
|
||||
API_INIT_FUNC(1, "line_search_by_id", "si", API_RETURN_EMPTY);
|
||||
|
||||
v8::String::Utf8Value buffer(args[0]);
|
||||
id = args[1]->IntegerValue();
|
||||
|
||||
result = API_PTR2STR(
|
||||
weechat_line_search_by_id ((struct t_gui_buffer *)API_STR2PTR(*buffer), id));
|
||||
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
API_FUNC(current_window)
|
||||
{
|
||||
const char *result;
|
||||
@@ -5487,6 +5503,7 @@ WeechatJsV8::loadLibs()
|
||||
API_DEF_FUNC(buffer_set);
|
||||
API_DEF_FUNC(buffer_string_replace_local_var);
|
||||
API_DEF_FUNC(buffer_match_list);
|
||||
API_DEF_FUNC(line_search_by_id);
|
||||
API_DEF_FUNC(current_window);
|
||||
API_DEF_FUNC(window_search_with_buffer);
|
||||
API_DEF_FUNC(window_get_integer);
|
||||
|
||||
@@ -4083,6 +4083,23 @@ API_FUNC(buffer_match_list)
|
||||
API_RETURN_INT(value);
|
||||
}
|
||||
|
||||
API_FUNC(line_search_by_id)
|
||||
{
|
||||
const char *buffer, *result;
|
||||
int id;
|
||||
|
||||
API_INIT_FUNC(1, "line_search_by_id", API_RETURN_EMPTY);
|
||||
if (lua_gettop (L) < 2)
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
buffer = lua_tostring (L, -2);
|
||||
id = lua_tonumber (L, -1);
|
||||
|
||||
result = API_PTR2STR(weechat_line_search_by_id (API_STR2PTR(buffer), id));
|
||||
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
API_FUNC(current_window)
|
||||
{
|
||||
const char *result;
|
||||
@@ -5879,6 +5896,7 @@ const struct luaL_Reg weechat_lua_api_funcs[] = {
|
||||
API_DEF_FUNC(buffer_set),
|
||||
API_DEF_FUNC(buffer_string_replace_local_var),
|
||||
API_DEF_FUNC(buffer_match_list),
|
||||
API_DEF_FUNC(line_search_by_id),
|
||||
API_DEF_FUNC(current_window),
|
||||
API_DEF_FUNC(window_search_with_buffer),
|
||||
API_DEF_FUNC(window_get_integer),
|
||||
|
||||
@@ -3976,6 +3976,23 @@ API_FUNC(buffer_match_list)
|
||||
API_RETURN_INT(value);
|
||||
}
|
||||
|
||||
API_FUNC(line_search_by_id)
|
||||
{
|
||||
const char *result;
|
||||
dXSARGS;
|
||||
|
||||
API_INIT_FUNC(1, "line_search_by_id", API_RETURN_EMPTY);
|
||||
if (items < 2)
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
result = API_PTR2STR(
|
||||
weechat_line_search_by_id (
|
||||
API_STR2PTR(SvPV_nolen (ST (0))), /* buffer */
|
||||
SvIV (ST (1)))); /* id */
|
||||
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
API_FUNC(current_window)
|
||||
{
|
||||
const char *result;
|
||||
@@ -5817,6 +5834,7 @@ weechat_perl_api_init (pTHX)
|
||||
API_DEF_FUNC(buffer_set);
|
||||
API_DEF_FUNC(buffer_string_replace_local_var);
|
||||
API_DEF_FUNC(buffer_match_list);
|
||||
API_DEF_FUNC(line_search_by_id);
|
||||
API_DEF_FUNC(current_window);
|
||||
API_DEF_FUNC(window_search_with_buffer);
|
||||
API_DEF_FUNC(window_get_integer);
|
||||
|
||||
@@ -3976,6 +3976,27 @@ API_FUNC(buffer_match_list)
|
||||
API_RETURN_INT(result);
|
||||
}
|
||||
|
||||
API_FUNC(line_search_by_id)
|
||||
{
|
||||
zend_string *z_buffer;
|
||||
zend_long z_id;
|
||||
struct t_gui_buffer *buffer;
|
||||
int id;
|
||||
const char *result;
|
||||
|
||||
API_INIT_FUNC(1, "line_search_by_id", API_RETURN_EMPTY);
|
||||
if (zend_parse_parameters (ZEND_NUM_ARGS(), "Sl", &z_buffer,
|
||||
&z_id) == FAILURE)
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer));
|
||||
id = (int)z_id;
|
||||
|
||||
result = API_PTR2STR(weechat_line_search_by_id (buffer, id));
|
||||
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
API_FUNC(current_window)
|
||||
{
|
||||
const char *result;
|
||||
|
||||
@@ -183,6 +183,7 @@ PHP_FUNCTION(weechat_buffer_get_pointer);
|
||||
PHP_FUNCTION(weechat_buffer_set);
|
||||
PHP_FUNCTION(weechat_buffer_string_replace_local_var);
|
||||
PHP_FUNCTION(weechat_buffer_match_list);
|
||||
PHP_FUNCTION(weechat_line_search_by_id);
|
||||
PHP_FUNCTION(weechat_current_window);
|
||||
PHP_FUNCTION(weechat_window_search_with_buffer);
|
||||
PHP_FUNCTION(weechat_window_get_integer);
|
||||
|
||||
@@ -241,6 +241,7 @@ const zend_function_entry weechat_functions[] = {
|
||||
PHP_FE(weechat_buffer_set, arginfo_weechat_buffer_set)
|
||||
PHP_FE(weechat_buffer_string_replace_local_var, arginfo_weechat_buffer_string_replace_local_var)
|
||||
PHP_FE(weechat_buffer_match_list, arginfo_weechat_buffer_match_list)
|
||||
PHP_FE(weechat_line_search_by_id, arginfo_weechat_line_search_by_id)
|
||||
PHP_FE(weechat_current_window, arginfo_weechat_current_window)
|
||||
PHP_FE(weechat_window_search_with_buffer, arginfo_weechat_window_search_with_buffer)
|
||||
PHP_FE(weechat_window_get_integer, arginfo_weechat_window_get_integer)
|
||||
|
||||
@@ -149,6 +149,7 @@ function weechat_buffer_get_pointer(string $p0, string $p1): string {}
|
||||
function weechat_buffer_set(string $p0, string $p1, string $p2): int {}
|
||||
function weechat_buffer_string_replace_local_var(string $p0, string $p1): string {}
|
||||
function weechat_buffer_match_list(string $p0, string $p1): int {}
|
||||
function weechat_line_search_by_id(string $p0, int $p1): string {}
|
||||
function weechat_current_window(): string {}
|
||||
function weechat_window_search_with_buffer(string $p0): string {}
|
||||
function weechat_window_get_integer(string $p0, string $p1): int {}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: cf4a06ff974bca04f671e75e22f7d16534ca643f */
|
||||
* Stub hash: ac17ccd00483eea80bd3dc22ec07ab3bf41dec88 */
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_weechat_register, 0, 7, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, p0, IS_STRING, 0)
|
||||
@@ -439,6 +439,8 @@ ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_weechat_buffer_match_list arginfo_weechat_string_has_highlight
|
||||
|
||||
#define arginfo_weechat_line_search_by_id arginfo_weechat_list_get
|
||||
|
||||
#define arginfo_weechat_current_window arginfo_weechat_list_new
|
||||
|
||||
#define arginfo_weechat_window_search_with_buffer arginfo_weechat_plugin_get_name
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: cf4a06ff974bca04f671e75e22f7d16534ca643f */
|
||||
* Stub hash: ac17ccd00483eea80bd3dc22ec07ab3bf41dec88 */
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_weechat_register, 0, 0, 7)
|
||||
ZEND_ARG_INFO(0, p0)
|
||||
@@ -313,6 +313,8 @@ ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_weechat_buffer_match_list arginfo_weechat_iconv_to_internal
|
||||
|
||||
#define arginfo_weechat_line_search_by_id arginfo_weechat_iconv_to_internal
|
||||
|
||||
#define arginfo_weechat_current_window arginfo_weechat_list_new
|
||||
|
||||
#define arginfo_weechat_window_search_with_buffer arginfo_weechat_plugin_get_name
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
#include "../gui/gui-color.h"
|
||||
#include "../gui/gui-completion.h"
|
||||
#include "../gui/gui-key.h"
|
||||
#include "../gui/gui-line.h"
|
||||
#include "../gui/gui-nicklist.h"
|
||||
#include "../gui/gui-window.h"
|
||||
#include "plugin.h"
|
||||
@@ -845,6 +846,8 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv)
|
||||
new_plugin->buffer_string_replace_local_var = &gui_buffer_string_replace_local_var;
|
||||
new_plugin->buffer_match_list = &gui_buffer_match_list;
|
||||
|
||||
new_plugin->line_search_by_id = &gui_line_search_by_id;
|
||||
|
||||
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;
|
||||
|
||||
@@ -3990,6 +3990,23 @@ API_FUNC(buffer_match_list)
|
||||
API_RETURN_INT(value);
|
||||
}
|
||||
|
||||
API_FUNC(line_search_by_id)
|
||||
{
|
||||
char *buffer;
|
||||
int id;
|
||||
const char *result;
|
||||
|
||||
API_INIT_FUNC(1, "line_search_by_id", API_RETURN_EMPTY);
|
||||
buffer = NULL;
|
||||
id = 0;
|
||||
if (!PyArg_ParseTuple (args, "si", &buffer, &id))
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
result = API_PTR2STR(weechat_line_search_by_id (API_STR2PTR(buffer), id));
|
||||
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
API_FUNC(current_window)
|
||||
{
|
||||
const char *result;
|
||||
@@ -5745,6 +5762,7 @@ PyMethodDef weechat_python_funcs[] =
|
||||
API_DEF_FUNC(buffer_set),
|
||||
API_DEF_FUNC(buffer_string_replace_local_var),
|
||||
API_DEF_FUNC(buffer_match_list),
|
||||
API_DEF_FUNC(line_search_by_id),
|
||||
API_DEF_FUNC(current_window),
|
||||
API_DEF_FUNC(window_search_with_buffer),
|
||||
API_DEF_FUNC(window_get_integer),
|
||||
|
||||
@@ -1926,6 +1926,16 @@ def buffer_match_list(buffer: str, string: str) -> int:
|
||||
...
|
||||
|
||||
|
||||
def line_search_by_id(buffer: str, line_id: int) -> str:
|
||||
"""`line_search_by_id in WeeChat plugin API reference <https://weechat.org/doc/weechat/api/#_line_search_by_id>`_
|
||||
::
|
||||
|
||||
# example
|
||||
line = weechat.line_search_by_id(buffer, 123)
|
||||
"""
|
||||
...
|
||||
|
||||
|
||||
def current_window() -> str:
|
||||
"""`current_window in WeeChat plugin API reference <https://weechat.org/doc/weechat/api/#_current_window>`_
|
||||
::
|
||||
|
||||
@@ -4822,6 +4822,29 @@ weechat_ruby_api_buffer_match_list (VALUE class, VALUE buffer, VALUE string)
|
||||
API_RETURN_INT(value);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_line_search_by_id (VALUE class, VALUE buffer, VALUE id)
|
||||
{
|
||||
char *c_buffer;
|
||||
int c_id;
|
||||
const char *result;
|
||||
|
||||
API_INIT_FUNC(1, "line_search_by_id", API_RETURN_EMPTY);
|
||||
if (NIL_P (buffer) || NIL_P (id))
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
Check_Type (buffer, T_STRING);
|
||||
CHECK_INTEGER(id);
|
||||
|
||||
c_buffer = StringValuePtr (buffer);
|
||||
c_id = NUM2INT (id);
|
||||
|
||||
result = API_PTR2STR(weechat_line_search_by_id (API_STR2PTR(c_buffer),
|
||||
c_id));
|
||||
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_current_window (VALUE class)
|
||||
{
|
||||
@@ -7081,6 +7104,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
API_DEF_FUNC(buffer_set, 3);
|
||||
API_DEF_FUNC(buffer_string_replace_local_var, 2);
|
||||
API_DEF_FUNC(buffer_match_list, 2);
|
||||
API_DEF_FUNC(line_search_by_id, 2);
|
||||
API_DEF_FUNC(current_window, 0);
|
||||
API_DEF_FUNC(window_search_with_buffer, 1);
|
||||
API_DEF_FUNC(window_get_integer, 2);
|
||||
|
||||
@@ -4043,6 +4043,25 @@ API_FUNC(buffer_match_list)
|
||||
API_RETURN_INT(result);
|
||||
}
|
||||
|
||||
API_FUNC(line_search_by_id)
|
||||
{
|
||||
char *buffer;
|
||||
int id;
|
||||
const char *result;
|
||||
|
||||
API_INIT_FUNC(1, "line_search_by_id", API_RETURN_EMPTY);
|
||||
if (objc < 3)
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
buffer = Tcl_GetString (objv[1]);
|
||||
if (Tcl_GetIntFromObj (interp, objv[2], &id) != TCL_OK)
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
result = API_PTR2STR(weechat_line_search_by_id (API_STR2PTR(buffer), id));
|
||||
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
API_FUNC(current_window)
|
||||
{
|
||||
const char *result;
|
||||
@@ -5821,6 +5840,7 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
|
||||
API_DEF_FUNC(buffer_set);
|
||||
API_DEF_FUNC(buffer_string_replace_local_var);
|
||||
API_DEF_FUNC(buffer_match_list);
|
||||
API_DEF_FUNC(line_search_by_id);
|
||||
API_DEF_FUNC(current_window);
|
||||
API_DEF_FUNC(window_search_with_buffer);
|
||||
API_DEF_FUNC(window_get_integer);
|
||||
|
||||
@@ -74,7 +74,7 @@ struct t_weelist_item;
|
||||
* please change the date with current one; for a second change at same
|
||||
* date, increment the 01, otherwise please keep 01.
|
||||
*/
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20240610-01"
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20240627-01"
|
||||
|
||||
/* macros for defining plugin infos */
|
||||
#define WEECHAT_PLUGIN_NAME(__name) \
|
||||
@@ -1008,6 +1008,9 @@ struct t_weechat_plugin
|
||||
const char *string);
|
||||
int (*buffer_match_list) (struct t_gui_buffer *buffer, const char *string);
|
||||
|
||||
/* buffer lines */
|
||||
struct t_gui_line *(*line_search_by_id) (struct t_gui_buffer *buffer, int id);
|
||||
|
||||
/* windows */
|
||||
struct t_gui_window *(*window_search_with_buffer) (struct t_gui_buffer *buffer);
|
||||
int (*window_get_integer) (struct t_gui_window *window,
|
||||
@@ -2067,6 +2070,10 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
|
||||
#define weechat_buffer_match_list(__buffer, __string) \
|
||||
(weechat_plugin->buffer_match_list)(__buffer, __string)
|
||||
|
||||
/* buffer lines */
|
||||
#define weechat_line_search_by_id(__buffer, __id) \
|
||||
(weechat_plugin->line_search_by_id)(__buffer, __id)
|
||||
|
||||
/* windows */
|
||||
#define weechat_window_search_with_buffer(__buffer) \
|
||||
(weechat_plugin->window_search_with_buffer)(__buffer)
|
||||
|
||||
Reference in New Issue
Block a user