diff --git a/CMakeLists.txt b/CMakeLists.txt index 81f4ba8..2ffa115 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,7 @@ add_library(tox MODULE src/tox-weechat-utils.c src/tox-weechat-config.c src/tox-weechat-json.c + src/tox-weechat-completion.c ) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -Wextra -Werror-implicit-function-declaration -Wno-unused-parameter") diff --git a/src/tox-weechat-completion.c b/src/tox-weechat-completion.c new file mode 100644 index 0000000..e5a8759 --- /dev/null +++ b/src/tox-weechat-completion.c @@ -0,0 +1,35 @@ +#include + +#include + +#include "tox-weechat.h" +#include "tox-weechat-identities.h" + +#include "tox-weechat-completion.h" + +int +tox_weechat_completion_identity(void *data, + const char *completion_item, + struct t_gui_buffer *buffer, + struct t_gui_completion *completion) +{ + for (struct t_tox_weechat_identity *identity = tox_weechat_identities; + identity; + identity = identity->next_identity) + { + weechat_hook_completion_list_add(completion, + identity->name, + 0, + WEECHAT_LIST_POS_SORT); + } + + return WEECHAT_RC_OK; +} + +void +tox_weechat_completion_init() +{ + weechat_hook_completion("tox_identity", + "identity", + tox_weechat_completion_identity, NULL); +} diff --git a/src/tox-weechat-completion.h b/src/tox-weechat-completion.h new file mode 100644 index 0000000..6122d8a --- /dev/null +++ b/src/tox-weechat-completion.h @@ -0,0 +1,7 @@ +#ifndef TOX_WEECHAT_COMPLETION_H +#define TOX_WEECHAT_COMPLETION_H + +void +tox_weechat_completion_init(); + +#endif // TOX_WEECHAT_COMPLETION_H diff --git a/src/tox-weechat.c b/src/tox-weechat.c index 2ee4587..95944df 100644 --- a/src/tox-weechat.c +++ b/src/tox-weechat.c @@ -27,6 +27,7 @@ #include "tox-weechat-friend-requests.h" #include "tox-weechat-config.h" #include "tox-weechat-json.h" +#include "tox-weechat-completion.h" #include "tox-weechat.h" @@ -51,6 +52,7 @@ weechat_plugin_init(struct t_weechat_plugin *plugin, int argc, char *argv[]) tox_weechat_config_read(); tox_weechat_commands_init(); tox_weechat_gui_init(); + tox_weechat_completion_init(); tox_weechat_identity_autoconnect();