diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/guile/weechat-guile-api.c | 48 | ||||
-rw-r--r-- | src/plugins/javascript/weechat-js-api.cpp | 48 | ||||
-rw-r--r-- | src/plugins/lua/weechat-lua-api.c | 54 | ||||
-rw-r--r-- | src/plugins/perl/weechat-perl-api.c | 53 | ||||
-rw-r--r-- | src/plugins/php/weechat-php-api.c | 173 | ||||
-rw-r--r-- | src/plugins/php/weechat-php-api.h | 3 | ||||
-rw-r--r-- | src/plugins/php/weechat-php.c | 3 | ||||
-rw-r--r-- | src/plugins/plugin.c | 8 | ||||
-rw-r--r-- | src/plugins/python/weechat-python-api.c | 53 | ||||
-rw-r--r-- | src/plugins/ruby/weechat-ruby-api.c | 68 | ||||
-rw-r--r-- | src/plugins/tcl/weechat-tcl-api.c | 43 | ||||
-rw-r--r-- | src/plugins/weechat-plugin.h | 19 |
12 files changed, 572 insertions, 1 deletions
diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c index ec4c20e97..eff2bf22d 100644 --- a/src/plugins/guile/weechat-guile-api.c +++ b/src/plugins/guile/weechat-guile-api.c @@ -4103,6 +4103,51 @@ weechat_guile_api_command_options (SCM buffer, SCM command, SCM options) } SCM +weechat_guile_api_completion_new (SCM buffer) +{ + const char *result; + SCM return_value; + + API_INIT_FUNC(1, "completion_new", API_RETURN_EMPTY); + if (!scm_is_string (buffer)) + API_WRONG_ARGS(API_RETURN_EMPTY); + + result = API_PTR2STR( + weechat_completion_new (API_STR2PTR(API_SCM_TO_STRING(buffer)))); + + API_RETURN_STRING(result); +} + +SCM +weechat_guile_api_completion_search (SCM completion, SCM data, SCM position, + SCM direction) +{ + API_INIT_FUNC(1, "completion_search", API_RETURN_ERROR); + if (!scm_is_string (completion) || !scm_is_string (data) + || !scm_is_integer (position) || !scm_is_integer (direction)) + API_WRONG_ARGS(API_RETURN_ERROR); + + 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; +} + +SCM +weechat_guile_api_completion_free (SCM completion) +{ + API_INIT_FUNC(1, "completion_free", API_RETURN_ERROR); + if (!scm_is_string (completion)) + API_WRONG_ARGS(API_RETURN_ERROR); + + weechat_completion_free (API_STR2PTR(API_SCM_TO_STRING(completion))); + + API_RETURN_OK; +} + +SCM weechat_guile_api_info_get (SCM info_name, SCM arguments) { char *result; @@ -5054,6 +5099,9 @@ weechat_guile_api_module_init (void *data) API_DEF_FUNC(bar_remove, 1); API_DEF_FUNC(command, 2); API_DEF_FUNC(command_options, 3); + API_DEF_FUNC(completion_new, 1); + API_DEF_FUNC(completion_search, 4); + API_DEF_FUNC(completion_free, 1); API_DEF_FUNC(info_get, 2); API_DEF_FUNC(info_get_hashtable, 2); API_DEF_FUNC(infolist_new, 0); diff --git a/src/plugins/javascript/weechat-js-api.cpp b/src/plugins/javascript/weechat-js-api.cpp index 5c159387d..8935a17e7 100644 --- a/src/plugins/javascript/weechat-js-api.cpp +++ b/src/plugins/javascript/weechat-js-api.cpp @@ -3999,6 +3999,51 @@ API_FUNC(command_options) API_RETURN_INT(rc); } +API_FUNC(completion_new) +{ + const char *result; + + API_INIT_FUNC(1, "completion_new", "s", API_RETURN_EMPTY); + + v8::String::Utf8Value buffer(args[0]); + + result = API_PTR2STR( + weechat_completion_new ((struct t_gui_buffer *)API_STR2PTR(*buffer))); + + API_RETURN_STRING(result); +} + +API_FUNC(completion_search) +{ + int position, direction; + + API_INIT_FUNC(1, "completion_search", "ssii", API_RETURN_ERROR); + + v8::String::Utf8Value completion(args[0]); + v8::String::Utf8Value data(args[1]); + position = args[2]->IntegerValue(); + direction = args[3]->IntegerValue(); + + weechat_completion_search ( + (struct t_gui_completion *)API_STR2PTR(*completion), + (const char *)(*data), + position, + direction); + + API_RETURN_OK; +} + +API_FUNC(completion_free) +{ + API_INIT_FUNC(1, "completion_free", "s", API_RETURN_ERROR); + + v8::String::Utf8Value completion(args[0]); + + weechat_completion_free ((struct t_gui_completion *)API_STR2PTR(*completion)); + + API_RETURN_OK; +} + API_FUNC(info_get) { const char *result; @@ -4991,6 +5036,9 @@ WeechatJsV8::loadLibs() API_DEF_FUNC(bar_remove); API_DEF_FUNC(command); API_DEF_FUNC(command_options); + API_DEF_FUNC(completion_new); + API_DEF_FUNC(completion_search); + API_DEF_FUNC(completion_free); API_DEF_FUNC(info_get); API_DEF_FUNC(info_get_hashtable); API_DEF_FUNC(infolist_new); diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c index f6230a71a..0d16363b1 100644 --- a/src/plugins/lua/weechat-lua-api.c +++ b/src/plugins/lua/weechat-lua-api.c @@ -4337,6 +4337,57 @@ API_FUNC(command_options) API_RETURN_INT(rc); } +API_FUNC(completion_new) +{ + const char *buffer; + const char *result; + + API_INIT_FUNC(1, "completion_new", API_RETURN_EMPTY); + if (lua_gettop (L) < 1) + API_WRONG_ARGS(API_RETURN_EMPTY); + + buffer = lua_tostring (L, -1); + + result = API_PTR2STR(weechat_completion_new (API_STR2PTR(buffer))); + + API_RETURN_STRING(result); +} + +API_FUNC(completion_search) +{ + const char *completion, *data; + int position, direction; + + API_INIT_FUNC(1, "completion_search", API_RETURN_ERROR); + if (lua_gettop (L) < 4) + API_WRONG_ARGS(API_RETURN_ERROR); + + 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); + + API_RETURN_OK; +} + +API_FUNC(completion_free) +{ + const char *completion; + + API_INIT_FUNC(1, "completion_free", API_RETURN_ERROR); + if (lua_gettop (L) < 1) + API_WRONG_ARGS(API_RETURN_ERROR); + + completion = lua_tostring (L, -1); + + weechat_completion_free (API_STR2PTR(completion)); + + API_RETURN_OK; +} + API_FUNC(info_get) { const char *info_name, *arguments; @@ -5345,6 +5396,9 @@ const struct luaL_Reg weechat_lua_api_funcs[] = { API_DEF_FUNC(bar_remove), API_DEF_FUNC(command), API_DEF_FUNC(command_options), + API_DEF_FUNC(completion_new), + API_DEF_FUNC(completion_search), + API_DEF_FUNC(completion_free), API_DEF_FUNC(info_get), API_DEF_FUNC(info_get_hashtable), API_DEF_FUNC(infolist_new), diff --git a/src/plugins/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c index 983564905..9526b5109 100644 --- a/src/plugins/perl/weechat-perl-api.c +++ b/src/plugins/perl/weechat-perl-api.c @@ -4258,6 +4258,56 @@ API_FUNC(command_options) API_RETURN_INT(rc); } +API_FUNC(completion_new) +{ + char *buffer; + const char *result; + dXSARGS; + + API_INIT_FUNC(1, "completion_new", API_RETURN_EMPTY); + if (items < 1) + API_WRONG_ARGS(API_RETURN_EMPTY); + + buffer = SvPV_nolen (ST (0)); + + result = API_PTR2STR(weechat_completion_new (API_STR2PTR(buffer))); + + API_RETURN_STRING(result); +} + +API_FUNC(completion_search) +{ + char *completion, *data; + dXSARGS; + + API_INIT_FUNC(1, "completion_search", API_RETURN_ERROR); + if (items < 4) + API_WRONG_ARGS(API_RETURN_ERROR); + + 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 */ + + API_RETURN_OK; +} + +API_FUNC(completion_free) +{ + dXSARGS; + + API_INIT_FUNC(1, "completion_free", API_RETURN_ERROR); + if (items < 1) + API_WRONG_ARGS(API_RETURN_ERROR); + + weechat_completion_free (API_STR2PTR(SvPV_nolen (ST (0)))); /* completion */ + + API_RETURN_OK; +} + API_FUNC(info_get) { char *info_name, *arguments, *result; @@ -5302,6 +5352,9 @@ weechat_perl_api_init (pTHX) API_DEF_FUNC(bar_remove); API_DEF_FUNC(command); API_DEF_FUNC(command_options); + API_DEF_FUNC(completion_new); + API_DEF_FUNC(completion_search); + API_DEF_FUNC(completion_free); API_DEF_FUNC(info_get); API_DEF_FUNC(info_get_hashtable); API_DEF_FUNC(infolist_new); diff --git a/src/plugins/php/weechat-php-api.c b/src/plugins/php/weechat-php-api.c index a8cd4a79f..981f3f365 100644 --- a/src/plugins/php/weechat-php-api.c +++ b/src/plugins/php/weechat-php-api.c @@ -275,6 +275,7 @@ API_FUNC(charset_set) API_WRONG_ARGS(API_RETURN_ERROR); charset = ZSTR_VAL(z_charset); + plugin_script_api_charset_set (php_current_script, (const char *)charset); API_RETURN_OK; @@ -292,6 +293,7 @@ API_FUNC(iconv_to_internal) charset = ZSTR_VAL(z_charset); string = ZSTR_VAL(z_string); + result = weechat_iconv_to_internal ((const char *)charset, (const char *)string); @@ -310,6 +312,7 @@ API_FUNC(iconv_from_internal) charset = ZSTR_VAL(z_charset); string = ZSTR_VAL(z_string); + result = weechat_iconv_from_internal ((const char *)charset, (const char *)string); @@ -327,6 +330,7 @@ API_FUNC(gettext) API_WRONG_ARGS(API_RETURN_EMPTY); string = ZSTR_VAL(z_string); + result = weechat_gettext ((const char *)string); API_RETURN_STRING(result); @@ -348,6 +352,7 @@ API_FUNC(ngettext) single = ZSTR_VAL(z_single); plural = ZSTR_VAL(z_plural); count = (int)z_count; + result = weechat_ngettext ((const char *)single, (const char *)plural, count); @@ -367,6 +372,7 @@ API_FUNC(strlen_screen) API_WRONG_ARGS(API_RETURN_INT(0)); string = ZSTR_VAL(z_string); + result = weechat_strlen_screen ((const char *)string); API_RETURN_INT(result); @@ -387,6 +393,7 @@ API_FUNC(string_match) string = ZSTR_VAL(z_string); mask = ZSTR_VAL(z_mask); case_sensitive = (int)z_case_sensitive; + result = weechat_string_match ((const char *)string, (const char *)mask, case_sensitive); @@ -409,6 +416,7 @@ API_FUNC(string_match_list) string = ZSTR_VAL(z_string); masks = ZSTR_VAL(z_masks); case_sensitive = (int)z_case_sensitive; + result = plugin_script_api_string_match_list (weechat_php_plugin, (const char *)string, (const char *)masks, @@ -431,6 +439,7 @@ API_FUNC(string_has_highlight) string = ZSTR_VAL(z_string); highlight_words = ZSTR_VAL(z_highlight_words); + result = weechat_string_has_highlight ((const char *)string, (const char *)highlight_words); @@ -450,6 +459,7 @@ API_FUNC(string_has_highlight_regex) string = ZSTR_VAL(z_string); regex = ZSTR_VAL(z_regex); + result = weechat_string_has_highlight_regex ((const char *)string, (const char *)regex); @@ -467,6 +477,7 @@ API_FUNC(string_mask_to_regex) API_WRONG_ARGS(API_RETURN_EMPTY); mask = ZSTR_VAL(z_mask); + result = weechat_string_mask_to_regex ((const char *)mask); API_RETURN_STRING_FREE(result); @@ -498,6 +509,7 @@ API_FUNC(string_remove_color) string = ZSTR_VAL(z_string); replacement = ZSTR_VAL(z_replacement); + result = weechat_string_remove_color ((const char *)string, (const char *)replacement); @@ -515,6 +527,7 @@ API_FUNC(string_is_command_char) API_WRONG_ARGS(API_RETURN_INT(0)); string = ZSTR_VAL(z_string); + result = weechat_string_is_command_char ((const char *)string); API_RETURN_INT(result); @@ -531,6 +544,7 @@ API_FUNC(string_input_for_buffer) API_WRONG_ARGS(API_RETURN_EMPTY); string = ZSTR_VAL(z_string); + result = weechat_string_input_for_buffer ((const char *)string); API_RETURN_STRING(result); @@ -639,6 +653,7 @@ API_FUNC(mkdir_home) directory = ZSTR_VAL(z_directory); mode = (int)z_mode; + if (weechat_mkdir_home ((const char *)directory, mode)) API_RETURN_OK; @@ -659,6 +674,7 @@ API_FUNC(mkdir) directory = ZSTR_VAL(z_directory); mode = (int)z_mode; + if (weechat_mkdir ((const char *)directory, mode)) API_RETURN_OK; @@ -679,6 +695,7 @@ API_FUNC(mkdir_parents) directory = ZSTR_VAL(z_directory); mode = (int)z_mode; + if (weechat_mkdir_parents ((const char *)directory, mode)) API_RETURN_OK; @@ -758,6 +775,7 @@ API_FUNC(list_search_pos) weelist = (struct t_weelist *)API_STR2PTR(ZSTR_VAL(z_weelist)); data = ZSTR_VAL(z_data); + result = weechat_list_search_pos (weelist, (const char *)data); API_RETURN_INT(result); @@ -798,6 +816,7 @@ API_FUNC(list_casesearch_pos) weelist = (struct t_weelist *)API_STR2PTR(ZSTR_VAL(z_weelist)); data = ZSTR_VAL(z_data); + result = weechat_list_casesearch_pos (weelist, (const char *)data); API_RETURN_INT(result); @@ -837,6 +856,7 @@ API_FUNC(list_set) item = (struct t_weelist_item *)API_STR2PTR(ZSTR_VAL(z_item)); value = ZSTR_VAL(z_value); + weechat_list_set (item, (const char *)value); API_RETURN_OK; @@ -888,6 +908,7 @@ API_FUNC(list_string) API_WRONG_ARGS(API_RETURN_EMPTY); item = (struct t_weelist_item *)API_STR2PTR(ZSTR_VAL(z_item)); + result = weechat_list_string (item); API_RETURN_STRING(result); @@ -904,6 +925,7 @@ API_FUNC(list_size) API_WRONG_ARGS(API_RETURN_INT(0)); weelist = (struct t_weelist *)API_STR2PTR(ZSTR_VAL(z_weelist)); + result = weechat_list_size (weelist); API_RETURN_INT(result); @@ -922,6 +944,7 @@ API_FUNC(list_remove) weelist = (struct t_weelist *)API_STR2PTR(ZSTR_VAL(z_weelist)); item = (struct t_weelist_item *)API_STR2PTR(ZSTR_VAL(z_item)); + weechat_list_remove (weelist, item); API_RETURN_OK; @@ -938,6 +961,7 @@ API_FUNC(list_remove_all) API_WRONG_ARGS(API_RETURN_ERROR); weelist = (struct t_weelist *)API_STR2PTR(ZSTR_VAL(z_weelist)); + weechat_list_remove_all (weelist); API_RETURN_OK; @@ -953,6 +977,7 @@ API_FUNC(list_free) API_WRONG_ARGS(API_RETURN_ERROR); weelist = (struct t_weelist *)API_STR2PTR(ZSTR_VAL(z_weelist)); + weechat_list_free (weelist); API_RETURN_OK; @@ -1344,6 +1369,7 @@ API_FUNC(config_string_to_boolean) API_WRONG_ARGS(API_RETURN_INT(0)); text = ZSTR_VAL(z_text); + result = weechat_config_string_to_boolean ((const char *)text); API_RETURN_INT(result); @@ -1363,6 +1389,7 @@ API_FUNC(config_option_reset) option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); run_callback = (int)z_run_callback; + result = weechat_config_option_reset (option, run_callback); API_RETURN_INT(result); @@ -1385,6 +1412,7 @@ API_FUNC(config_option_set) option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); value = ZSTR_VAL(z_value); run_callback = (int)z_run_callback; + result = weechat_config_option_set (option, (const char *)value, run_callback); @@ -1405,6 +1433,7 @@ API_FUNC(config_option_set_null) option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); run_callback = (int)z_run_callback; + result = weechat_config_option_set_null (option, run_callback); API_RETURN_INT(result); @@ -1421,6 +1450,7 @@ API_FUNC(config_option_unset) API_WRONG_ARGS(API_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR)); option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); + result = weechat_config_option_unset (option); API_RETURN_INT(result); @@ -1439,6 +1469,7 @@ API_FUNC(config_option_rename) option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); new_name = ZSTR_VAL(z_new_name); + weechat_config_option_rename (option, (const char *)new_name); API_RETURN_OK; @@ -1455,6 +1486,7 @@ API_FUNC(config_option_is_null) API_WRONG_ARGS(API_RETURN_INT(1)); option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); + result = weechat_config_option_is_null (option); API_RETURN_INT(result); @@ -1471,6 +1503,7 @@ API_FUNC(config_option_default_is_null) API_WRONG_ARGS(API_RETURN_INT(1)); option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); + result = weechat_config_option_default_is_null (option); API_RETURN_INT(result); @@ -1487,6 +1520,7 @@ API_FUNC(config_boolean) API_WRONG_ARGS(API_RETURN_INT(0)); option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); + result = weechat_config_boolean (option); API_RETURN_INT(result); @@ -1503,6 +1537,7 @@ API_FUNC(config_boolean_default) API_WRONG_ARGS(API_RETURN_INT(0)); option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); + result = weechat_config_boolean_default (option); API_RETURN_INT(result); @@ -1519,6 +1554,7 @@ API_FUNC(config_integer) API_WRONG_ARGS(API_RETURN_INT(0)); option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); + result = weechat_config_integer (option); API_RETURN_INT(result); @@ -1535,6 +1571,7 @@ API_FUNC(config_integer_default) API_WRONG_ARGS(API_RETURN_INT(0)); option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); + result = weechat_config_integer_default (option); API_RETURN_INT(result); @@ -1551,6 +1588,7 @@ API_FUNC(config_string) API_WRONG_ARGS(API_RETURN_EMPTY); option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); + result = weechat_config_string (option); API_RETURN_STRING(result); @@ -1567,6 +1605,7 @@ API_FUNC(config_string_default) API_WRONG_ARGS(API_RETURN_EMPTY); option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); + result = weechat_config_string_default (option); API_RETURN_STRING(result); @@ -1583,6 +1622,7 @@ API_FUNC(config_color) API_WRONG_ARGS(API_RETURN_EMPTY); option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); + result = weechat_config_color (option); API_RETURN_STRING(result); @@ -1599,6 +1639,7 @@ API_FUNC(config_color_default) API_WRONG_ARGS(API_RETURN_EMPTY); option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); + result = weechat_config_color_default (option); API_RETURN_STRING(result); @@ -1657,6 +1698,7 @@ API_FUNC(config_write) API_WRONG_ARGS(API_RETURN_INT(WEECHAT_CONFIG_WRITE_ERROR)); config_file = (struct t_config_file *)API_STR2PTR(ZSTR_VAL(z_config_file)); + result = weechat_config_write (config_file); API_RETURN_INT(result); @@ -1674,6 +1716,7 @@ API_FUNC(config_read) API_WRONG_ARGS(API_RETURN_INT(WEECHAT_CONFIG_READ_FILE_NOT_FOUND)); config_file = (struct t_config_file *)API_STR2PTR(ZSTR_VAL(z_config_file)); + result = weechat_config_read (config_file); API_RETURN_INT(result); @@ -1691,6 +1734,7 @@ API_FUNC(config_reload) API_WRONG_ARGS(API_RETURN_INT(WEECHAT_CONFIG_READ_FILE_NOT_FOUND)); config_file = (struct t_config_file *)API_STR2PTR(ZSTR_VAL(z_config_file)); + result = weechat_config_reload (config_file); API_RETURN_INT(result); @@ -1706,6 +1750,7 @@ API_FUNC(config_option_free) API_WRONG_ARGS(API_RETURN_ERROR); option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); + weechat_config_option_free (option); API_RETURN_OK; @@ -1722,6 +1767,7 @@ API_FUNC(config_section_free_options) API_WRONG_ARGS(API_RETURN_ERROR); section = (struct t_config_section *)API_STR2PTR(ZSTR_VAL(z_section)); + weechat_config_section_free_options (section); API_RETURN_OK; @@ -1738,6 +1784,7 @@ API_FUNC(config_section_free) API_WRONG_ARGS(API_RETURN_ERROR); section = (struct t_config_section *)API_STR2PTR(ZSTR_VAL(z_section)); + weechat_config_section_free (section); API_RETURN_OK; @@ -1754,6 +1801,7 @@ API_FUNC(config_free) API_WRONG_ARGS(API_RETURN_ERROR); config_file = (struct t_config_file *)API_STR2PTR(ZSTR_VAL(z_config_file)); + weechat_config_free (config_file); API_RETURN_OK; @@ -1788,6 +1836,7 @@ API_FUNC(config_get_plugin) API_WRONG_ARGS(API_RETURN_EMPTY); option = ZSTR_VAL(z_option); + result = plugin_script_api_config_get_plugin (weechat_php_plugin, php_current_script, (const char *)option); @@ -1806,6 +1855,7 @@ API_FUNC(config_is_set_plugin) API_WRONG_ARGS(API_RETURN_INT(0)); option = ZSTR_VAL(z_option); + result = plugin_script_api_config_is_set_plugin (weechat_php_plugin, php_current_script, (const char *)option); @@ -1826,6 +1876,7 @@ API_FUNC(config_set_plugin) option = ZSTR_VAL(z_option); value = ZSTR_VAL(z_value); + result = plugin_script_api_config_set_plugin (weechat_php_plugin, php_current_script, (const char *)option, @@ -1846,6 +1897,7 @@ API_FUNC(config_set_desc_plugin) option = ZSTR_VAL(z_option); description = ZSTR_VAL(z_description); + plugin_script_api_config_set_desc_plugin (weechat_php_plugin, php_current_script, (const char *)option, @@ -1865,6 +1917,7 @@ API_FUNC(config_unset_plugin) API_WRONG_ARGS(API_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR)); option = ZSTR_VAL(z_option); + result = plugin_script_api_config_unset_plugin (weechat_php_plugin, php_current_script, (const char *)option); @@ -1912,6 +1965,7 @@ API_FUNC(key_unbind) context = ZSTR_VAL(z_context); key = ZSTR_VAL(z_key); + result = weechat_key_unbind ((const char *)context, (const char *)key); API_RETURN_INT(result); @@ -1928,6 +1982,7 @@ API_FUNC(prefix) API_WRONG_ARGS(API_RETURN_EMPTY); prefix = ZSTR_VAL(z_prefix); + result = weechat_prefix ((const char *)prefix); API_RETURN_STRING(result); @@ -1944,6 +1999,7 @@ API_FUNC(color) API_WRONG_ARGS(API_RETURN_EMPTY); color_name = ZSTR_VAL(z_color_name); + result = weechat_color ((const char *)color_name); API_RETURN_STRING(result); @@ -1962,6 +2018,7 @@ API_FUNC(print) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); message = ZSTR_VAL(z_message); + plugin_script_api_printf (weechat_php_plugin, php_current_script, buffer, "%s", message); @@ -1985,6 +2042,7 @@ API_FUNC(print_date_tags) date = (time_t)z_date; tags = ZSTR_VAL(z_tags); message = ZSTR_VAL(z_message); + plugin_script_api_printf_date_tags (weechat_php_plugin, php_current_script, buffer, @@ -2012,6 +2070,7 @@ API_FUNC(print_y) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); y = (int)z_y; message = ZSTR_VAL(z_message); + plugin_script_api_printf_y (weechat_php_plugin, php_current_script, buffer, @@ -2032,6 +2091,7 @@ API_FUNC(log_print) API_WRONG_ARGS(API_RETURN_ERROR); message = ZSTR_VAL(z_message); + plugin_script_api_log_printf (weechat_php_plugin, php_current_script, "%s", message); @@ -2160,6 +2220,7 @@ API_FUNC(hook_completion_get_string) completion = (struct t_gui_completion *)API_STR2PTR(ZSTR_VAL(z_completion)); property = ZSTR_VAL(z_property); + result = weechat_hook_completion_get_string (completion, (const char *)property); @@ -2183,6 +2244,7 @@ API_FUNC(hook_completion_list_add) word = ZSTR_VAL(z_word); nick_completion = (int)z_nick_completion; where = ZSTR_VAL(z_where); + weechat_hook_completion_list_add (completion, (const char *)word, nick_completion, @@ -2880,6 +2942,7 @@ API_FUNC(hook_modifier_exec) modifier = ZSTR_VAL(z_modifier); modifier_data = ZSTR_VAL(z_modifier_data); string = ZSTR_VAL(z_string); + result = weechat_hook_modifier_exec ((const char *)modifier, (const char *)modifier_data, (const char *)string); @@ -3107,6 +3170,7 @@ API_FUNC(hook_set) hook = (struct t_hook *)API_STR2PTR(ZSTR_VAL(z_hook)); property = ZSTR_VAL(z_property); value = ZSTR_VAL(z_value); + weechat_hook_set (hook, (const char *)property, (const char *)value); API_RETURN_OK; @@ -3122,6 +3186,7 @@ API_FUNC(unhook) API_WRONG_ARGS(API_RETURN_ERROR); hook = (struct t_hook *)API_STR2PTR(ZSTR_VAL(z_hook)); + weechat_unhook (hook); API_RETURN_OK; @@ -3137,6 +3202,7 @@ API_FUNC(unhook_all) API_WRONG_ARGS(API_RETURN_ERROR); subplugin = ZSTR_VAL(z_subplugin); + weechat_unhook_all ((const char *)subplugin); API_RETURN_OK; @@ -3264,6 +3330,7 @@ API_FUNC(buffer_clear) API_WRONG_ARGS(API_RETURN_ERROR); buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); + weechat_buffer_clear (buffer); API_RETURN_OK; @@ -3279,6 +3346,7 @@ API_FUNC(buffer_close) API_WRONG_ARGS(API_RETURN_ERROR); buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); + weechat_buffer_close (buffer); API_RETURN_OK; @@ -3298,6 +3366,7 @@ API_FUNC(buffer_merge) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); target_buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_target_buffer)); + weechat_buffer_merge (buffer, target_buffer); API_RETURN_OK; @@ -3317,6 +3386,7 @@ API_FUNC(buffer_unmerge) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); number = (int)z_number; + weechat_buffer_unmerge (buffer, number); API_RETURN_OK; @@ -3336,6 +3406,7 @@ API_FUNC(buffer_get_integer) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); property = ZSTR_VAL(z_property); + result = weechat_buffer_get_integer (buffer, (const char *)property); API_RETURN_INT(result); @@ -3355,6 +3426,7 @@ API_FUNC(buffer_get_string) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); property = ZSTR_VAL(z_property); + result = weechat_buffer_get_string (buffer, (const char *)property); API_RETURN_STRING(result); @@ -3395,6 +3467,7 @@ API_FUNC(buffer_set) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); property = ZSTR_VAL(z_property); value = ZSTR_VAL(z_value); + weechat_buffer_set (buffer, (const char *)property, (const char *)value); API_RETURN_OK; @@ -3413,6 +3486,7 @@ API_FUNC(buffer_string_replace_local_var) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); string = ZSTR_VAL(z_string); + result = weechat_buffer_string_replace_local_var (buffer, (const char *)string); @@ -3433,6 +3507,7 @@ API_FUNC(buffer_match_list) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); string = ZSTR_VAL(z_string); + result = weechat_buffer_match_list (buffer, (const char *)string); API_RETURN_INT(result); @@ -3482,6 +3557,7 @@ API_FUNC(window_get_integer) window = (struct t_gui_window *)API_STR2PTR(ZSTR_VAL(z_window)); property = ZSTR_VAL(z_property); + result = weechat_window_get_integer (window, (const char *)property); API_RETURN_INT(result); @@ -3501,6 +3577,7 @@ API_FUNC(window_get_string) window = (struct t_gui_window *)API_STR2PTR(ZSTR_VAL(z_window)); property = ZSTR_VAL(z_property); + result = weechat_window_get_string (window, (const char *)property); API_RETURN_STRING(result); @@ -3537,6 +3614,7 @@ API_FUNC(window_set_title) API_WRONG_ARGS(API_RETURN_ERROR); title = ZSTR_VAL(z_title); + weechat_window_set_title ((const char *)title); API_RETURN_OK; @@ -3672,6 +3750,7 @@ API_FUNC(nicklist_remove_group) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); group = (struct t_gui_nick_group *)API_STR2PTR(ZSTR_VAL(z_group)); + weechat_nicklist_remove_group (buffer, group); API_RETURN_OK; @@ -3690,6 +3769,7 @@ API_FUNC(nicklist_remove_nick) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); nick = (struct t_gui_nick *)API_STR2PTR(ZSTR_VAL(z_nick)); + weechat_nicklist_remove_nick (buffer, nick); API_RETURN_OK; @@ -3705,6 +3785,7 @@ API_FUNC(nicklist_remove_all) API_WRONG_ARGS(API_RETURN_ERROR); buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); + weechat_nicklist_remove_all (buffer); API_RETURN_OK; @@ -3726,6 +3807,7 @@ API_FUNC(nicklist_group_get_integer) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); group = (struct t_gui_nick_group *)API_STR2PTR(ZSTR_VAL(z_group)); property = ZSTR_VAL(z_property); + result = weechat_nicklist_group_get_integer (buffer, group, (const char *)property); @@ -3749,6 +3831,7 @@ API_FUNC(nicklist_group_get_string) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); group = (struct t_gui_nick_group *)API_STR2PTR(ZSTR_VAL(z_group)); property = ZSTR_VAL(z_property); + result = weechat_nicklist_group_get_string (buffer, group, (const char *)property); @@ -3797,6 +3880,7 @@ API_FUNC(nicklist_group_set) group = (struct t_gui_nick_group *)API_STR2PTR(ZSTR_VAL(z_group)); property = ZSTR_VAL(z_property); value = ZSTR_VAL(z_value); + weechat_nicklist_group_set (buffer, group, (const char *)property, @@ -3821,6 +3905,7 @@ API_FUNC(nicklist_nick_get_integer) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); nick = (struct t_gui_nick *)API_STR2PTR(ZSTR_VAL(z_nick)); property = ZSTR_VAL(z_property); + result = weechat_nicklist_nick_get_integer (buffer, nick, (const char *)property); @@ -3844,6 +3929,7 @@ API_FUNC(nicklist_nick_get_string) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); nick = (struct t_gui_nick *)API_STR2PTR(ZSTR_VAL(z_nick)); property = ZSTR_VAL(z_property); + result = weechat_nicklist_nick_get_string (buffer, nick, (const char *)property); @@ -3892,6 +3978,7 @@ API_FUNC(nicklist_nick_set) nick = (struct t_gui_nick *)API_STR2PTR(ZSTR_VAL(z_nick)); property = ZSTR_VAL(z_property); value = ZSTR_VAL(z_value); + weechat_nicklist_nick_set (buffer, nick, (const char *)property, @@ -3976,6 +4063,7 @@ API_FUNC(bar_item_update) API_WRONG_ARGS(API_RETURN_ERROR); name = ZSTR_VAL(z_name); + weechat_bar_item_update ((const char *)name); API_RETURN_OK; @@ -3991,6 +4079,7 @@ API_FUNC(bar_item_remove) API_WRONG_ARGS(API_RETURN_ERROR); item = (struct t_gui_bar_item *)API_STR2PTR(ZSTR_VAL(z_item)); + weechat_bar_item_remove (item); API_RETURN_OK; @@ -4085,6 +4174,7 @@ API_FUNC(bar_set) bar = (struct t_gui_bar *)API_STR2PTR(ZSTR_VAL(z_bar)); property = ZSTR_VAL(z_property); value = ZSTR_VAL(z_value); + result = weechat_bar_set (bar, (const char *)property, (const char *)value); API_RETURN_INT(result); @@ -4115,6 +4205,7 @@ API_FUNC(bar_remove) API_WRONG_ARGS(API_RETURN_ERROR); bar = (struct t_gui_bar *)API_STR2PTR(ZSTR_VAL(z_bar)); + weechat_bar_remove (bar); API_RETURN_OK; @@ -4134,6 +4225,7 @@ API_FUNC(command) buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); command = ZSTR_VAL(z_command); + result = plugin_script_api_command (weechat_php_plugin, php_current_script, buffer, @@ -4176,6 +4268,62 @@ API_FUNC(command_options) API_RETURN_INT(result); } +API_FUNC(completion_new) +{ + zend_string *z_buffer; + struct t_gui_buffer *buffer; + const char *result; + + API_INIT_FUNC(1, "completion_new", API_RETURN_EMPTY); + if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_buffer) == FAILURE) + API_WRONG_ARGS(API_RETURN_EMPTY); + + buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); + + result = API_PTR2STR(weechat_completion_new (buffer)); + + API_RETURN_STRING(result); +} + +API_FUNC(completion_search) +{ + zend_string *z_completion, *z_data; + zend_long z_position, z_direction; + char *data; + struct t_gui_completion *completion; + int position, direction; + + API_INIT_FUNC(1, "completion_search", API_RETURN_ERROR); + if (zend_parse_parameters (ZEND_NUM_ARGS(), "SSll", &z_completion, &z_data, + &z_position, &z_direction) == FAILURE) + API_WRONG_ARGS(API_RETURN_ERROR); + + 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); + + API_RETURN_OK; +} + +API_FUNC(completion_free) +{ + zend_string *z_completion; + struct t_gui_completion *completion; + + API_INIT_FUNC(1, "completion_free", API_RETURN_ERROR); + if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_completion) == FAILURE) + API_WRONG_ARGS(API_RETURN_ERROR); + + completion = (struct t_gui_completion *)API_STR2PTR(ZSTR_VAL(z_completion)); + + weechat_completion_free (completion); + + API_RETURN_OK; +} + API_FUNC(info_get) { zend_string *z_info_name, *z_arguments; @@ -4188,6 +4336,7 @@ API_FUNC(info_get) info_name = ZSTR_VAL(z_info_name); arguments = ZSTR_VAL(z_arguments); + result = weechat_info_get ((const char *)info_name, (const char *)arguments); @@ -4405,6 +4554,7 @@ API_FUNC(infolist_next) API_WRONG_ARGS(API_RETURN_INT(0)); infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist)); + result = weechat_infolist_next (infolist); API_RETURN_INT(result); @@ -4421,6 +4571,7 @@ API_FUNC(infolist_prev) API_WRONG_ARGS(API_RETURN_INT(0)); infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist)); + result = weechat_infolist_prev (infolist); API_RETURN_INT(result); @@ -4436,6 +4587,7 @@ API_FUNC(infolist_reset_item_cursor) API_WRONG_ARGS(API_RETURN_ERROR); infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist)); + weechat_infolist_reset_item_cursor (infolist); API_RETURN_OK; @@ -4452,6 +4604,7 @@ API_FUNC(infolist_fields) API_WRONG_ARGS(API_RETURN_EMPTY); infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist)); + result = weechat_infolist_fields (infolist); API_RETURN_STRING(result); @@ -4471,6 +4624,7 @@ API_FUNC(infolist_integer) infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist)); var = ZSTR_VAL(z_var); + result = weechat_infolist_integer (infolist, (const char *)var); API_RETURN_INT(result); @@ -4490,6 +4644,7 @@ API_FUNC(infolist_string) infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist)); var = ZSTR_VAL(z_var); + result = weechat_infolist_string (infolist, (const char *)var); API_RETURN_STRING(result); @@ -4546,6 +4701,7 @@ API_FUNC(infolist_free) API_WRONG_ARGS(API_RETURN_ERROR); infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist)); + weechat_infolist_free (infolist); API_RETURN_OK; @@ -4582,6 +4738,7 @@ API_FUNC(hdata_get_var_offset) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); name = ZSTR_VAL(z_name); + result = weechat_hdata_get_var_offset (hdata, (const char *)name); API_RETURN_INT(result); @@ -4601,6 +4758,7 @@ API_FUNC(hdata_get_var_type_string) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); name = ZSTR_VAL(z_name); + result = weechat_hdata_get_var_type_string (hdata, (const char *)name); API_RETURN_STRING(result); @@ -4622,6 +4780,7 @@ API_FUNC(hdata_get_var_array_size) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer)); name = ZSTR_VAL(z_name); + result = weechat_hdata_get_var_array_size (hdata, pointer, (const char *)name); @@ -4645,6 +4804,7 @@ API_FUNC(hdata_get_var_array_size_string) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer)); name = ZSTR_VAL(z_name); + result = weechat_hdata_get_var_array_size_string (hdata, pointer, (const char *)name); @@ -4666,6 +4826,7 @@ API_FUNC(hdata_get_var_hdata) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); name = ZSTR_VAL(z_name); + result = weechat_hdata_get_var_hdata (hdata, (const char *)name); API_RETURN_STRING(result); @@ -4707,6 +4868,7 @@ API_FUNC(hdata_check_pointer) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); list = (void *)API_STR2PTR(ZSTR_VAL(z_list)); pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer)); + result = weechat_hdata_check_pointer (hdata, list, pointer); API_RETURN_INT(result); @@ -4776,6 +4938,7 @@ API_FUNC(hdata_char) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer)); name = ZSTR_VAL(z_name); + result = weechat_hdata_char (hdata, pointer, (const char *)name); API_RETURN_INT((int)result); @@ -4797,6 +4960,7 @@ API_FUNC(hdata_integer) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer)); name = ZSTR_VAL(z_name); + result = weechat_hdata_integer (hdata, pointer, (const char *)name); API_RETURN_INT(result); @@ -4818,6 +4982,7 @@ API_FUNC(hdata_long) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer)); name = ZSTR_VAL(z_name); + result = weechat_hdata_long (hdata, pointer, (const char *)name); API_RETURN_LONG(result); @@ -4839,6 +5004,7 @@ API_FUNC(hdata_string) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer)); name = ZSTR_VAL(z_name); + result = weechat_hdata_string (hdata, pointer, (const char *)name); API_RETURN_STRING(result); @@ -4883,6 +5049,7 @@ API_FUNC(hdata_time) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer)); name = ZSTR_VAL(z_name); + result = weechat_hdata_time (hdata, pointer, (const char *)name); API_RETURN_LONG(result); @@ -4904,6 +5071,7 @@ API_FUNC(hdata_hashtable) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer)); name = ZSTR_VAL(z_name); + result = weechat_hdata_hashtable (hdata, pointer, (const char *)name); weechat_php_hashtable_to_array (result, return_value); @@ -4929,6 +5097,7 @@ API_FUNC(hdata_compare) pointer2 = (void *)API_STR2PTR(ZSTR_VAL(z_pointer2)); name = (void *)API_STR2PTR(ZSTR_VAL(z_name)); case_sensitive = (int)z_case_sensitive; + result = weechat_hdata_compare (hdata, pointer1, pointer2, name, case_sensitive); @@ -4979,6 +5148,7 @@ API_FUNC(hdata_get_string) hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata)); property = ZSTR_VAL(z_property); + result = weechat_hdata_get_string (hdata, (const char *)property); API_RETURN_STRING(result); @@ -5049,6 +5219,7 @@ API_FUNC(upgrade_write_object) upgrade_file = (struct t_upgrade_file *)API_STR2PTR(ZSTR_VAL(z_upgrade_file)); object_id = (int)z_object_id; infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist)); + result = weechat_upgrade_write_object (upgrade_file, object_id, infolist); API_RETURN_INT(result); @@ -5066,6 +5237,7 @@ API_FUNC(upgrade_read) API_WRONG_ARGS(API_RETURN_INT(0)); upgrade_file = (struct t_upgrade_file *)API_STR2PTR(ZSTR_VAL(z_upgrade_file)); + result = weechat_upgrade_read (upgrade_file); API_RETURN_INT(result); @@ -5082,6 +5254,7 @@ API_FUNC(upgrade_close) API_WRONG_ARGS(API_RETURN_ERROR); upgrade_file = (struct t_upgrade_file *)API_STR2PTR(ZSTR_VAL(z_upgrade_file)); + weechat_upgrade_close (upgrade_file); API_RETURN_OK; diff --git a/src/plugins/php/weechat-php-api.h b/src/plugins/php/weechat-php-api.h index 971a6d83f..303b30735 100644 --- a/src/plugins/php/weechat-php-api.h +++ b/src/plugins/php/weechat-php-api.h @@ -198,6 +198,9 @@ PHP_FUNCTION(weechat_bar_update); PHP_FUNCTION(weechat_bar_remove); PHP_FUNCTION(weechat_command); PHP_FUNCTION(weechat_command_options); +PHP_FUNCTION(weechat_completion_new); +PHP_FUNCTION(weechat_completion_search); +PHP_FUNCTION(weechat_completion_free); PHP_FUNCTION(weechat_info_get); PHP_FUNCTION(weechat_info_get_hashtable); PHP_FUNCTION(weechat_infolist_new); diff --git a/src/plugins/php/weechat-php.c b/src/plugins/php/weechat-php.c index 189c51689..95e096b8f 100644 --- a/src/plugins/php/weechat-php.c +++ b/src/plugins/php/weechat-php.c @@ -251,6 +251,9 @@ const zend_function_entry weechat_functions[] = { PHP_FE(weechat_bar_remove, NULL) PHP_FE(weechat_command, NULL) PHP_FE(weechat_command_options, NULL) + PHP_FE(weechat_completion_new, NULL) + PHP_FE(weechat_completion_search, NULL) + PHP_FE(weechat_completion_free, NULL) PHP_FE(weechat_info_get, NULL) PHP_FE(weechat_info_get_hashtable, NULL) PHP_FE(weechat_infolist_new, NULL) diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index f2065f191..1b5cf78a1 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -55,6 +55,7 @@ #include "../gui/gui-buffer.h" #include "../gui/gui-chat.h" #include "../gui/gui-color.h" +#include "../gui/gui-completion.h" #include "../gui/gui-key.h" #include "../gui/gui-nicklist.h" #include "../gui/gui-window.h" @@ -849,6 +850,10 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv) new_plugin->command = &plugin_api_command; new_plugin->command_options = &plugin_api_command_options; + new_plugin->completion_new = &gui_completion_new; + new_plugin->completion_search = &gui_completion_search; + new_plugin->completion_free = &gui_completion_free; + new_plugin->network_pass_proxy = &network_pass_proxy; new_plugin->network_connect_to = &network_connect_to; @@ -1133,6 +1138,9 @@ plugin_remove (struct t_weechat_plugin *plugin) struct t_weechat_plugin *new_weechat_plugins; struct t_gui_buffer *ptr_buffer, *next_buffer; + /* remove all completions (only those created by API) */ + gui_completion_free_all_plugin (plugin); + /* close buffers created by this plugin */ ptr_buffer = gui_buffers; while (ptr_buffer) diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c index e9e3235e8..9ed65c47a 100644 --- a/src/plugins/python/weechat-python-api.c +++ b/src/plugins/python/weechat-python-api.c @@ -4272,6 +4272,56 @@ API_FUNC(command_options) API_RETURN_INT(rc); } +API_FUNC(completion_new) +{ + char *buffer; + const char *result; + + API_INIT_FUNC(1, "completion_new", API_RETURN_EMPTY); + buffer = NULL; + if (!PyArg_ParseTuple (args, "s", &buffer)) + API_WRONG_ARGS(API_RETURN_EMPTY); + + result = API_PTR2STR(weechat_completion_new (API_STR2PTR(buffer))); + + API_RETURN_STRING(result); +} + +API_FUNC(completion_search) +{ + char *completion, *data; + int position, direction; + + API_INIT_FUNC(1, "completion_search", API_RETURN_ERROR); + completion = NULL; + position = 0; + direction = 1; + if (!PyArg_ParseTuple (args, "ssii", &completion, &data, &position, + &direction)) + API_WRONG_ARGS(API_RETURN_ERROR); + + weechat_completion_search (API_STR2PTR(completion), + data, + position, + direction); + + API_RETURN_OK; +} + +API_FUNC(completion_free) +{ + char *completion; + + API_INIT_FUNC(1, "completion_free", API_RETURN_ERROR); + completion = NULL; + if (!PyArg_ParseTuple (args, "s", &completion)) + API_WRONG_ARGS(API_RETURN_ERROR); + + weechat_completion_free (API_STR2PTR(completion)); + + API_RETURN_OK; +} + API_FUNC(info_get) { char *info_name, *arguments, *result; @@ -5253,6 +5303,9 @@ PyMethodDef weechat_python_funcs[] = API_DEF_FUNC(bar_remove), API_DEF_FUNC(command), API_DEF_FUNC(command_options), + API_DEF_FUNC(completion_new), + API_DEF_FUNC(completion_search), + API_DEF_FUNC(completion_free), API_DEF_FUNC(info_get), API_DEF_FUNC(info_get_hashtable), API_DEF_FUNC(infolist_new), diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c index 1137ea030..3788ba3d4 100644 --- a/src/plugins/ruby/weechat-ruby-api.c +++ b/src/plugins/ruby/weechat-ruby-api.c @@ -5151,6 +5151,71 @@ weechat_ruby_api_command_options (VALUE class, VALUE buffer, VALUE command, } static VALUE +weechat_ruby_api_completion_new (VALUE class, VALUE buffer) +{ + char *c_buffer; + const char *result; + + API_INIT_FUNC(1, "completion_new", API_RETURN_EMPTY); + if (NIL_P (buffer)) + API_WRONG_ARGS(API_RETURN_EMPTY); + + Check_Type (buffer, T_STRING); + + c_buffer = StringValuePtr (buffer); + + result = API_PTR2STR(weechat_completion_new (API_STR2PTR(c_buffer))); + + API_RETURN_STRING(result); +} + +static VALUE +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; + + API_INIT_FUNC(1, "completion_search", API_RETURN_ERROR); + if (NIL_P (completion) || NIL_P (data) || NIL_P(position) + || NIL_P(direction)) + API_WRONG_ARGS(API_RETURN_ERROR); + + Check_Type (completion, T_STRING); + Check_Type (data, T_STRING); + CHECK_INTEGER(position); + CHECK_INTEGER(direction); + + c_completion = StringValuePtr (completion); + c_data = StringValuePtr (data); + c_position = NUM2INT (position); + c_direction = NUM2INT (direction); + + weechat_completion_search (API_STR2PTR(c_completion), c_data, c_position, + c_direction); + + API_RETURN_OK; +} + +static VALUE +weechat_ruby_api_completion_free (VALUE class, VALUE completion) +{ + char *c_completion; + + API_INIT_FUNC(1, "completion_free", API_RETURN_ERROR); + if (NIL_P (completion)) + API_WRONG_ARGS(API_RETURN_ERROR); + + Check_Type (completion, T_STRING); + + c_completion = StringValuePtr (completion); + + weechat_completion_free (API_STR2PTR(c_completion)); + + API_RETURN_OK; +} + +static VALUE weechat_ruby_api_info_get (VALUE class, VALUE info_name, VALUE arguments) { char *c_info_name, *c_arguments, *result; @@ -6421,6 +6486,9 @@ weechat_ruby_api_init (VALUE ruby_mWeechat) API_DEF_FUNC(bar_remove, 1); API_DEF_FUNC(command, 2); API_DEF_FUNC(command_options, 3); + API_DEF_FUNC(completion_new, 1); + API_DEF_FUNC(completion_search, 4); + API_DEF_FUNC(completion_free, 1); API_DEF_FUNC(info_get, 2); API_DEF_FUNC(info_get_hashtable, 2); API_DEF_FUNC(infolist_new, 0); diff --git a/src/plugins/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c index e75b44295..edd3bb63b 100644 --- a/src/plugins/tcl/weechat-tcl-api.c +++ b/src/plugins/tcl/weechat-tcl-api.c @@ -4624,6 +4624,47 @@ API_FUNC(command_options) API_RETURN_INT(rc); } +API_FUNC(completion_new) +{ + Tcl_Obj *objp; + char *buffer; + const char *result; + int i; + + API_INIT_FUNC(1, "completion_new", API_RETURN_EMPTY); + if (objc < 2) + API_WRONG_ARGS(API_RETURN_EMPTY); + + buffer = Tcl_GetStringFromObj (objv[1], &i); + + result = API_PTR2STR(weechat_completion_new (API_STR2PTR(buffer))); + + API_RETURN_STRING(result); +} + +API_FUNC(completion_search) +{ + Tcl_Obj *objp; + char *completion, *data; + int i, position, direction; + + API_INIT_FUNC(1, "completion_search", API_RETURN_ERROR); + if (objc < 5) + API_WRONG_ARGS(API_RETURN_ERROR); + + completion = Tcl_GetStringFromObj (objv[1], &i); + data = Tcl_GetStringFromObj (objv[2], &i); + + if ((Tcl_GetIntFromObj (interp, objv[3], &position) != TCL_OK) + || (Tcl_GetIntFromObj (interp, objv[4], &direction) != TCL_OK)) + API_WRONG_ARGS(API_RETURN_ERROR); + + weechat_completion_search (API_STR2PTR(completion), data, position, + direction); + + API_RETURN_OK; +} + API_FUNC(info_get) { Tcl_Obj *objp; @@ -5780,6 +5821,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp) API_DEF_FUNC(bar_remove); API_DEF_FUNC(command); API_DEF_FUNC(command_options); + API_DEF_FUNC(completion_new); + API_DEF_FUNC(completion_search); API_DEF_FUNC(info_get); API_DEF_FUNC(info_get_hashtable); API_DEF_FUNC(infolist_new); diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index ca9f783cf..c76f33f01 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 "20200301-03" +#define WEECHAT_PLUGIN_API_VERSION "20200426-01" /* macros for defining plugin infos */ #define WEECHAT_PLUGIN_NAME(__name) \ @@ -1009,6 +1009,13 @@ struct t_weechat_plugin struct t_gui_buffer *buffer, const char *command, struct t_hashtable *options); + /* 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); + void (*completion_free) (struct t_gui_completion *completion); + /* network */ int (*network_pass_proxy) (const char *proxy, int sock, const char *address, int port); @@ -1942,6 +1949,16 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin); (weechat_plugin->command_options)(weechat_plugin, __buffer, \ __command, __options) +/* completion */ +#define weechat_completion_new(__buffer) \ + (weechat_plugin->completion_new)(weechat_plugin, __buffer) +#define weechat_completion_search(__completion, __data, __position, \ + __direction) \ + (weechat_plugin->completion_search)(__completion, __data, \ + __position, __direction) +#define weechat_completion_free(__completion) \ + (weechat_plugin->completion_free)(__completion) + /* network */ #define weechat_network_pass_proxy(__proxy, __sock, __address, __port) \ (weechat_plugin->network_pass_proxy)(__proxy, __sock, __address, \ |