diff options
author | James Booth <boothj5@gmail.com> | 2016-07-04 23:14:08 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2016-07-04 23:14:08 +0100 |
commit | fd218ac3e443650a7b310d4f8cde758f08c0ed8c (patch) | |
tree | dc1efd227324d8d9aef9a7e6fd5a808a08c67ab3 /src | |
parent | 03c7ac73fd903a6c48658fd3c5e270d35f5a80c2 (diff) | |
download | profani-tty-fd218ac3e443650a7b310d4f8cde758f08c0ed8c.tar.gz |
Pass plugin name to all autocompleter functions
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/api.c | 4 | ||||
-rw-r--r-- | src/plugins/api.h | 4 | ||||
-rw-r--r-- | src/plugins/c_api.c | 22 | ||||
-rw-r--r-- | src/plugins/callbacks.c | 1 | ||||
-rw-r--r-- | src/plugins/profapi.c | 4 | ||||
-rw-r--r-- | src/plugins/profapi.h | 6 | ||||
-rw-r--r-- | src/plugins/python_api.c | 14 |
7 files changed, 39 insertions, 16 deletions
diff --git a/src/plugins/api.c b/src/plugins/api.c index 53138a4e..ecd1749e 100644 --- a/src/plugins/api.c +++ b/src/plugins/api.c @@ -167,13 +167,13 @@ api_completer_add(const char *const plugin_name, const char *key, char **items) } void -api_completer_remove(const char *key, char **items) +api_completer_remove(const char *const plugin_name, const char *key, char **items) { autocompleters_remove(key, items); } void -api_completer_clear(const char *key) +api_completer_clear(const char *const plugin_name, const char *key) { autocompleters_clear(key); } diff --git a/src/plugins/api.h b/src/plugins/api.h index 0b1aec32..b87b9bc5 100644 --- a/src/plugins/api.h +++ b/src/plugins/api.h @@ -57,8 +57,8 @@ void api_register_timed(const char *const plugin_name, void *callback, int inter void (*callback_func)(PluginTimedFunction *timed_function), void(*callback_destroy)(void *callback)); void api_completer_add(const char *const plugin_name, const char *key, char **items); -void api_completer_remove(const char *key, char **items); -void api_completer_clear(const char *key); +void api_completer_remove(const char *const plugin_name, const char *key, char **items); +void api_completer_clear(const char *const plugin_name, const char *key); void api_log_debug(const char *message); void api_log_info(const char *message); diff --git a/src/plugins/c_api.c b/src/plugins/c_api.c index 32719feb..22a2fde4 100644 --- a/src/plugins/c_api.c +++ b/src/plugins/c_api.c @@ -120,15 +120,25 @@ c_api_completer_add(const char *filename, const char *key, char **items) } static void -c_api_completer_remove(const char *key, char **items) +c_api_completer_remove(const char *filename, const char *key, char **items) { - api_completer_remove(key, items); + char *plugin_name = _c_plugin_name(filename); + log_debug("Autocomplete remove %s for %s", key, plugin_name); + + api_completer_remove(plugin_name, key, items); + + free(plugin_name); } static void -c_api_completer_clear(const char *key) +c_api_completer_clear(const char *filename, const char *key) { - api_completer_clear(key); + char *plugin_name = _c_plugin_name(filename); + log_debug("Autocomplete clear %s for %s", key, plugin_name); + + api_completer_clear(plugin_name, key); + + free(plugin_name); } static void @@ -322,9 +332,9 @@ c_api_init(void) _prof_register_command = c_api_register_command; _prof_register_timed = c_api_register_timed; _prof_completer_add = c_api_completer_add; + _prof_completer_remove = c_api_completer_remove; + _prof_completer_clear = c_api_completer_clear; _prof_win_create = c_api_win_create; - prof_completer_remove = c_api_completer_remove; - prof_completer_clear = c_api_completer_clear; prof_notify = c_api_notify; prof_send_line = c_api_send_line; prof_get_current_recipient = c_api_get_current_recipient; diff --git a/src/plugins/callbacks.c b/src/plugins/callbacks.c index c0a25ca6..d313690b 100644 --- a/src/plugins/callbacks.c +++ b/src/plugins/callbacks.c @@ -141,6 +141,7 @@ callbacks_init(void) void callbacks_remove(const char *const plugin_name) { + // TODO remove from cmd_ac and cmd_ac_help g_hash_table_remove(p_commands, plugin_name); g_hash_table_remove(p_timed_functions, plugin_name); g_hash_table_remove(p_window_callbacks, plugin_name); diff --git a/src/plugins/profapi.c b/src/plugins/profapi.c index 2f955ecb..20b8c26b 100644 --- a/src/plugins/profapi.c +++ b/src/plugins/profapi.c @@ -49,8 +49,8 @@ void (*_prof_register_command)(const char *filename, const char *command_name, i void (*_prof_register_timed)(const char *filename, void(*callback)(void), int interval_seconds) = NULL; void (*_prof_completer_add)(const char *filename, const char *key, char **items) = NULL; -void (*prof_completer_remove)(const char *key, char **items) = NULL; -void (*prof_completer_clear)(const char *key) = NULL; +void (*_prof_completer_remove)(const char *filename, const char *key, char **items) = NULL; +void (*_prof_completer_clear)(const char *filename, const char *key) = NULL; void (*prof_notify)(const char *message, int timeout_ms, const char *category) = NULL; diff --git a/src/plugins/profapi.h b/src/plugins/profapi.h index d42bf70f..87bfd6d3 100644 --- a/src/plugins/profapi.h +++ b/src/plugins/profapi.h @@ -38,6 +38,8 @@ #define prof_register_command(command_name, min_args, max_args, synopsis, description, arguments, examples, callback) _prof_register_command(__FILE__, command_name, min_args, max_args, synopsis, description, arguments, examples, callback) #define prof_register_timed(callback, interval_seconds) _prof_register_timed(__FILE__, callback, interval_seconds) #define prof_completer_add(key, items) _prof_completer_add(__FILE__, key, items) +#define prof_completer_remove(key, items) _prof_completer_remove(__FILE__, key, items) +#define prof_completer_clear(key) _prof_completer_clear(__FILE__, key) #define prof_win_create(win, input_handler) _prof_win_create(__FILE__, win, input_handler) typedef char* PROF_WIN_TAG; @@ -54,8 +56,8 @@ void (*_prof_register_command)(const char *filename, const char *command_name, i void (*_prof_register_timed)(const char *filename, void(*callback)(void), int interval_seconds); void (*_prof_completer_add)(const char *filename, const char *key, char **items); -void (*prof_completer_remove)(const char *key, char **items); -void (*prof_completer_clear)(const char *key); +void (*_prof_completer_remove)(const char *filename, const char *key, char **items); +void (*_prof_completer_clear)(const char *filename, const char *key); void (*prof_notify)(const char *message, int timeout_ms, const char *category); diff --git a/src/plugins/python_api.c b/src/plugins/python_api.c index 82cf22eb..6f478893 100644 --- a/src/plugins/python_api.c +++ b/src/plugins/python_api.c @@ -242,6 +242,9 @@ python_api_completer_remove(PyObject *self, PyObject *args) return Py_BuildValue(""); } + char *plugin_name = _python_plugin_name(); + log_debug("Autocomplete remove %s for %s", key, plugin_name); + Py_ssize_t len = PyList_Size(items); char *c_items[len]; @@ -254,9 +257,11 @@ python_api_completer_remove(PyObject *self, PyObject *args) c_items[len] = NULL; allow_python_threads(); - api_completer_remove(key, c_items); + api_completer_remove(plugin_name, key, c_items); disable_python_threads(); + free(plugin_name); + return Py_BuildValue(""); } @@ -269,10 +274,15 @@ python_api_completer_clear(PyObject *self, PyObject *args) return Py_BuildValue(""); } + char *plugin_name = _python_plugin_name(); + log_debug("Autocomplete clear %s for %s", key, plugin_name); + allow_python_threads(); - api_completer_clear(key); + api_completer_clear(plugin_name, key); disable_python_threads(); + free(plugin_name); + return Py_BuildValue(""); } |