diff --git a/doc/en/weechat_plugin_api.en.adoc b/doc/en/weechat_plugin_api.en.adoc index 17c73d182..0c4c4a699 100644 --- a/doc/en/weechat_plugin_api.en.adoc +++ b/doc/en/weechat_plugin_api.en.adoc @@ -14993,8 +14993,8 @@ Prototype: [source,C] ---- -void weechat_completion_search (struct t_gui_completion *completion, const char *data, - int position, int direction); +int weechat_completion_search (struct t_gui_completion *completion, const char *data, + int position, int direction); ---- Arguments: @@ -15004,12 +15004,19 @@ Arguments: * _position_: index of the char in string to complete (starts to 0) * _direction_: 1 for next completion, -1 for previous completion +Return value: + +* 1 if OK, 0 if error + C example: [source,C] ---- struct t_gui_completion *completion = weechat_completion_new (weechat_buffer_search_main ()); -weechat_completion_search (completion, "/help filt", 10, 1); +if (weechat_completion_search (completion, "/help filt", 10, 1)) +{ + /* ... */ +} ---- Script (Python): @@ -15017,11 +15024,12 @@ Script (Python): [source,python] ---- # prototype -weechat.completion_search(completion, data, position, direction) +rc = weechat.completion_search(completion, data, position, direction) # example completion = weechat.completion_new(weechat.buffer_search_main()) -weechat.completion_search(completion, "/help filt", 10, 1); +if weechat.completion_search(completion, "/help filt", 10, 1): + # ... ---- ==== completion_free diff --git a/doc/fr/weechat_plugin_api.fr.adoc b/doc/fr/weechat_plugin_api.fr.adoc index a4f482d34..d7ddb4c25 100644 --- a/doc/fr/weechat_plugin_api.fr.adoc +++ b/doc/fr/weechat_plugin_api.fr.adoc @@ -15312,8 +15312,8 @@ Prototype : [source,C] ---- -void weechat_completion_search (struct t_gui_completion *completion, const char *data, - int position, int direction); +int weechat_completion_search (struct t_gui_completion *completion, const char *data, + int position, int direction); ---- Paramètres : @@ -15323,12 +15323,19 @@ Paramètres : * _position_ : index du caractère dans la chaîne à compléter (commence à 0) * _direction_ : 1 pour la complétion suivante, -1 pour la complétion précédente +Valeur de retour : + +* 1 si OK, 0 si erreur + Exemple en C : [source,C] ---- struct t_gui_completion *completion = weechat_completion_new (weechat_buffer_search_main ()); -weechat_completion_search (completion, "/help filt", 10, 1); +if (weechat_completion_search (completion, "/help filt", 10, 1)) +{ + /* ... */ +} ---- Script (Python) : @@ -15336,11 +15343,12 @@ Script (Python) : [source,python] ---- # prototype -weechat.completion_search(completion, data, position, direction) +rc = weechat.completion_search(completion, data, position, direction) # exemple completion = weechat.completion_new(weechat.buffer_search_main()) -weechat.completion_search(completion, "/help filt", 10, 1); +if weechat.completion_search(completion, "/help filt", 10, 1): + # ... ---- ==== completion_free diff --git a/doc/it/weechat_plugin_api.it.adoc b/doc/it/weechat_plugin_api.it.adoc index 6494b5c75..000e42ade 100644 --- a/doc/it/weechat_plugin_api.it.adoc +++ b/doc/it/weechat_plugin_api.it.adoc @@ -15593,8 +15593,8 @@ Prototipo: [source,C] ---- -void weechat_completion_search (struct t_gui_completion *completion, const char *data, - int position, int direction); +int weechat_completion_search (struct t_gui_completion *completion, const char *data, + int position, int direction); ---- Argomenti: @@ -15604,12 +15604,20 @@ Argomenti: * _position_: index of the char in string to complete (starts to 0) * _direction_: 1 for next completion, -1 for previous completion +Valore restituito: + +// TRANSLATION MISSING +* 1 if OK, 0 if error + Esempio in C: [source,C] ---- struct t_gui_completion *completion = weechat_completion_new (weechat_buffer_search_main ()); -weechat_completion_search (completion, "/help filt", 10, 1); +if (weechat_completion_search (completion, "/help filt", 10, 1)) +{ + /* ... */ +} ---- Script (Python): @@ -15617,11 +15625,12 @@ Script (Python): [source,python] ---- # prototipo -weechat.completion_search(completion, data, position, direction) +rc = weechat.completion_search(completion, data, position, direction) # esempio completion = weechat.completion_new(weechat.buffer_search_main()) -weechat.completion_search(completion, "/help filt", 10, 1); +if weechat.completion_search(completion, "/help filt", 10, 1): + # ... ---- // TRANSLATION MISSING diff --git a/doc/ja/weechat_plugin_api.ja.adoc b/doc/ja/weechat_plugin_api.ja.adoc index 90bc27d07..a3beb8492 100644 --- a/doc/ja/weechat_plugin_api.ja.adoc +++ b/doc/ja/weechat_plugin_api.ja.adoc @@ -14978,8 +14978,8 @@ context. [source,C] ---- -void weechat_completion_search (struct t_gui_completion *completion, const char *data, - int position, int direction); +int weechat_completion_search (struct t_gui_completion *completion, const char *data, + int position, int direction); ---- 引数: @@ -14989,12 +14989,19 @@ void weechat_completion_search (struct t_gui_completion *completion, const char * _position_: index of the char in string to complete (starts to 0) * _direction_: 1 for next completion, -1 for previous completion +戻り値: + +* 成功した場合は 1、失敗した場合は 0 + C 言語での使用例: [source,C] ---- struct t_gui_completion *completion = weechat_completion_new (weechat_buffer_search_main ()); -weechat_completion_search (completion, "/help filt", 10, 1); +if (weechat_completion_search (completion, "/help filt", 10, 1)) +{ + /* ... */ +} ---- スクリプト (Python) での使用例: @@ -15002,11 +15009,12 @@ weechat_completion_search (completion, "/help filt", 10, 1); [source,python] ---- # prototype -weechat.completion_search(completion, data, position, direction) +rc = weechat.completion_search(completion, data, position, direction) # example completion = weechat.completion_new(weechat.buffer_search_main()) -weechat.completion_search(completion, "/help filt", 10, 1); +if weechat.completion_search(completion, "/help filt", 10, 1): + # ... ---- // TRANSLATION MISSING diff --git a/src/gui/gui-completion.c b/src/gui/gui-completion.c index c36ab940a..599205365 100644 --- a/src/gui/gui-completion.c +++ b/src/gui/gui-completion.c @@ -1370,15 +1370,15 @@ gui_completion_auto (struct t_gui_completion *completion) * Completes word according to context. */ -void +int gui_completion_search (struct t_gui_completion *completion, const char *data, int position, int direction) { char *old_word_found; int real_position; - if (!data) - return; + if (!completion || !data || (position < 0)) + return 0; real_position = utf8_real_pos (data, position); @@ -1404,7 +1404,7 @@ gui_completion_search (struct t_gui_completion *completion, const char *data, /* should never be executed */ if (old_word_found) free (old_word_found); - return; + return 0; case GUI_COMPLETION_COMMAND: gui_completion_command (completion); break; @@ -1440,6 +1440,8 @@ gui_completion_search (struct t_gui_completion *completion, const char *data, } if (old_word_found) free (old_word_found); + + return 1; } /* diff --git a/src/gui/gui-completion.h b/src/gui/gui-completion.h index 8056d1bf8..193cbff5e 100644 --- a/src/gui/gui-completion.h +++ b/src/gui/gui-completion.h @@ -88,9 +88,9 @@ extern void gui_completion_stop (struct t_gui_completion *completion); extern void gui_completion_list_add (struct t_gui_completion *completion, const char *word, int nick_completion, const char *where); -extern void gui_completion_search (struct t_gui_completion *completion, - const char *data, int position, - int direction); +extern int gui_completion_search (struct t_gui_completion *completion, + const char *data, int position, + int direction); extern const char *gui_completion_get_string (struct t_gui_completion *completion, const char *property); extern struct t_hdata *gui_completion_hdata_completion_cb (const void *pointer, diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c index cab58f6f7..1614266ad 100644 --- a/src/gui/gui-input.c +++ b/src/gui/gui-input.c @@ -532,14 +532,17 @@ gui_input_complete_next (struct t_gui_buffer *buffer) && (buffer->text_search == GUI_TEXT_SEARCH_DISABLED)) { gui_buffer_undo_snap (buffer); - gui_completion_search (buffer->completion, - buffer->input_buffer, - buffer->input_buffer_pos, - 1); - gui_input_complete (buffer); - gui_input_text_changed_modifier_and_signal (buffer, - 1, /* save undo */ - 0); /* stop completion */ + if (gui_completion_search (buffer->completion, + buffer->input_buffer, + buffer->input_buffer_pos, + 1)) + { + gui_input_complete (buffer); + gui_input_text_changed_modifier_and_signal ( + buffer, + 1, /* save undo */ + 0); /* stop completion */ + } } } @@ -554,14 +557,17 @@ gui_input_complete_previous (struct t_gui_buffer *buffer) && (buffer->text_search == GUI_TEXT_SEARCH_DISABLED)) { gui_buffer_undo_snap (buffer); - gui_completion_search (buffer->completion, - buffer->input_buffer, - buffer->input_buffer_pos, - -1); - gui_input_complete (buffer); - gui_input_text_changed_modifier_and_signal (buffer, - 1, /* save undo */ - 0); /* stop completion */ + if (gui_completion_search (buffer->completion, + buffer->input_buffer, + buffer->input_buffer_pos, + -1)) + { + gui_input_complete (buffer); + gui_input_text_changed_modifier_and_signal ( + buffer, + 1, /* save undo */ + 0); /* stop completion */ + } } } diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c index eff2bf22d..15f51b735 100644 --- a/src/plugins/guile/weechat-guile-api.c +++ b/src/plugins/guile/weechat-guile-api.c @@ -4122,17 +4122,19 @@ SCM weechat_guile_api_completion_search (SCM completion, SCM data, SCM position, SCM direction) { - API_INIT_FUNC(1, "completion_search", API_RETURN_ERROR); + int rc; + + API_INIT_FUNC(1, "completion_search", API_RETURN_INT(0)); if (!scm_is_string (completion) || !scm_is_string (data) || !scm_is_integer (position) || !scm_is_integer (direction)) - API_WRONG_ARGS(API_RETURN_ERROR); + API_WRONG_ARGS(API_RETURN_INT(0)); - weechat_completion_search (API_STR2PTR(API_SCM_TO_STRING(completion)), - API_SCM_TO_STRING(data), - scm_to_int (position), - scm_to_int (direction)); + rc = weechat_completion_search (API_STR2PTR(API_SCM_TO_STRING(completion)), + API_SCM_TO_STRING(data), + scm_to_int (position), + scm_to_int (direction)); - API_RETURN_OK; + API_RETURN_INT(rc); } SCM diff --git a/src/plugins/javascript/weechat-js-api.cpp b/src/plugins/javascript/weechat-js-api.cpp index 8935a17e7..275c38592 100644 --- a/src/plugins/javascript/weechat-js-api.cpp +++ b/src/plugins/javascript/weechat-js-api.cpp @@ -4015,22 +4015,22 @@ API_FUNC(completion_new) API_FUNC(completion_search) { - int position, direction; + int position, direction, rc; - API_INIT_FUNC(1, "completion_search", "ssii", API_RETURN_ERROR); + API_INIT_FUNC(1, "completion_search", "ssii", API_RETURN_INT(0)); v8::String::Utf8Value completion(args[0]); v8::String::Utf8Value data(args[1]); position = args[2]->IntegerValue(); direction = args[3]->IntegerValue(); - weechat_completion_search ( + rc = weechat_completion_search ( (struct t_gui_completion *)API_STR2PTR(*completion), (const char *)(*data), position, direction); - API_RETURN_OK; + API_RETURN_INT(rc); } API_FUNC(completion_free) diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c index 0d16363b1..f6587a90e 100644 --- a/src/plugins/lua/weechat-lua-api.c +++ b/src/plugins/lua/weechat-lua-api.c @@ -4356,21 +4356,21 @@ API_FUNC(completion_new) API_FUNC(completion_search) { const char *completion, *data; - int position, direction; + int position, direction, rc; - API_INIT_FUNC(1, "completion_search", API_RETURN_ERROR); + API_INIT_FUNC(1, "completion_search", API_RETURN_INT(0)); if (lua_gettop (L) < 4) - API_WRONG_ARGS(API_RETURN_ERROR); + API_WRONG_ARGS(API_RETURN_INT(0)); completion = lua_tostring (L, -4); data = lua_tostring (L, -3); position = lua_tonumber (L, -2); direction = lua_tonumber (L, -1); - weechat_completion_search (API_STR2PTR(completion), data, position, - direction); + rc = weechat_completion_search (API_STR2PTR(completion), data, position, + direction); - API_RETURN_OK; + API_RETURN_INT(rc); } API_FUNC(completion_free) diff --git a/src/plugins/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c index 9526b5109..259fb29ca 100644 --- a/src/plugins/perl/weechat-perl-api.c +++ b/src/plugins/perl/weechat-perl-api.c @@ -4278,21 +4278,22 @@ API_FUNC(completion_new) API_FUNC(completion_search) { char *completion, *data; + int rc; dXSARGS; - API_INIT_FUNC(1, "completion_search", API_RETURN_ERROR); + API_INIT_FUNC(1, "completion_search", API_RETURN_INT(0)); if (items < 4) - API_WRONG_ARGS(API_RETURN_ERROR); + API_WRONG_ARGS(API_RETURN_INT(0)); completion = SvPV_nolen (ST (0)); data = SvPV_nolen (ST (1)); - weechat_completion_search (API_STR2PTR(completion), - data, - SvIV (ST (2)), /* position */ - SvIV (ST (3))); /* direction */ + rc = weechat_completion_search (API_STR2PTR(completion), + data, + SvIV (ST (2)), /* position */ + SvIV (ST (3))); /* direction */ - API_RETURN_OK; + API_RETURN_INT(rc); } API_FUNC(completion_free) diff --git a/src/plugins/php/weechat-php-api.c b/src/plugins/php/weechat-php-api.c index 981f3f365..7a736061d 100644 --- a/src/plugins/php/weechat-php-api.c +++ b/src/plugins/php/weechat-php-api.c @@ -4291,21 +4291,21 @@ API_FUNC(completion_search) zend_long z_position, z_direction; char *data; struct t_gui_completion *completion; - int position, direction; + int position, direction, rc; - API_INIT_FUNC(1, "completion_search", API_RETURN_ERROR); + API_INIT_FUNC(1, "completion_search", API_RETURN_INT(0)); if (zend_parse_parameters (ZEND_NUM_ARGS(), "SSll", &z_completion, &z_data, &z_position, &z_direction) == FAILURE) - API_WRONG_ARGS(API_RETURN_ERROR); + API_WRONG_ARGS(API_RETURN_INT(0)); completion = (struct t_gui_completion *)API_STR2PTR(ZSTR_VAL(z_completion)); data = ZSTR_VAL(z_data); position = (int)z_position; direction = (int)z_direction; - weechat_completion_search (completion, data, position, direction); + rc = weechat_completion_search (completion, data, position, direction); - API_RETURN_OK; + API_RETURN_INT(rc); } API_FUNC(completion_free) diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c index 9ed65c47a..0803ed21b 100644 --- a/src/plugins/python/weechat-python-api.c +++ b/src/plugins/python/weechat-python-api.c @@ -4290,22 +4290,22 @@ API_FUNC(completion_new) API_FUNC(completion_search) { char *completion, *data; - int position, direction; + int position, direction, rc; - API_INIT_FUNC(1, "completion_search", API_RETURN_ERROR); + API_INIT_FUNC(1, "completion_search", API_RETURN_INT(0)); completion = NULL; position = 0; direction = 1; if (!PyArg_ParseTuple (args, "ssii", &completion, &data, &position, &direction)) - API_WRONG_ARGS(API_RETURN_ERROR); + API_WRONG_ARGS(API_RETURN_INT(0)); - weechat_completion_search (API_STR2PTR(completion), - data, - position, - direction); + rc = weechat_completion_search (API_STR2PTR(completion), + data, + position, + direction); - API_RETURN_OK; + API_RETURN_INT(rc); } API_FUNC(completion_free) diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c index 3788ba3d4..31bbc2103 100644 --- a/src/plugins/ruby/weechat-ruby-api.c +++ b/src/plugins/ruby/weechat-ruby-api.c @@ -5174,12 +5174,12 @@ weechat_ruby_api_completion_search (VALUE class, VALUE completion, VALUE data, VALUE position, VALUE direction) { char *c_completion, *c_data; - int c_position, c_direction; + int c_position, c_direction, rc; - API_INIT_FUNC(1, "completion_search", API_RETURN_ERROR); + API_INIT_FUNC(1, "completion_search", API_RETURN_INT(0)); if (NIL_P (completion) || NIL_P (data) || NIL_P(position) || NIL_P(direction)) - API_WRONG_ARGS(API_RETURN_ERROR); + API_WRONG_ARGS(API_RETURN_INT(0)); Check_Type (completion, T_STRING); Check_Type (data, T_STRING); @@ -5191,10 +5191,10 @@ weechat_ruby_api_completion_search (VALUE class, VALUE completion, VALUE data, c_position = NUM2INT (position); c_direction = NUM2INT (direction); - weechat_completion_search (API_STR2PTR(c_completion), c_data, c_position, - c_direction); + rc = weechat_completion_search (API_STR2PTR(c_completion), c_data, + c_position, c_direction); - API_RETURN_OK; + API_RETURN_INT(rc); } static VALUE diff --git a/src/plugins/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c index edd3bb63b..d7df56161 100644 --- a/src/plugins/tcl/weechat-tcl-api.c +++ b/src/plugins/tcl/weechat-tcl-api.c @@ -4646,11 +4646,11 @@ API_FUNC(completion_search) { Tcl_Obj *objp; char *completion, *data; - int i, position, direction; + int i, position, direction, rc; - API_INIT_FUNC(1, "completion_search", API_RETURN_ERROR); + API_INIT_FUNC(1, "completion_search", API_RETURN_INT(0)); if (objc < 5) - API_WRONG_ARGS(API_RETURN_ERROR); + API_WRONG_ARGS(API_RETURN_INT(0)); completion = Tcl_GetStringFromObj (objv[1], &i); data = Tcl_GetStringFromObj (objv[2], &i); @@ -4659,10 +4659,10 @@ API_FUNC(completion_search) || (Tcl_GetIntFromObj (interp, objv[4], &direction) != TCL_OK)) API_WRONG_ARGS(API_RETURN_ERROR); - weechat_completion_search (API_STR2PTR(completion), data, position, - direction); + rc = weechat_completion_search (API_STR2PTR(completion), data, position, + direction); - API_RETURN_OK; + API_RETURN_INT(rc); } API_FUNC(info_get) diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index c76f33f01..f58705e80 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -67,7 +67,7 @@ struct timeval; * 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 "20200426-01" +#define WEECHAT_PLUGIN_API_VERSION "20200428-01" /* macros for defining plugin infos */ #define WEECHAT_PLUGIN_NAME(__name) \ @@ -1012,8 +1012,8 @@ struct t_weechat_plugin /* completion */ struct t_gui_completion *(*completion_new) (struct t_weechat_plugin *plugin, struct t_gui_buffer *buffer); - void (*completion_search) (struct t_gui_completion *completion, - const char *data, int position, int direction); + int (*completion_search) (struct t_gui_completion *completion, + const char *data, int position, int direction); void (*completion_free) (struct t_gui_completion *completion); /* network */