diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2017-06-15 22:18:09 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2017-06-25 16:35:28 +0200 |
commit | 263c2904a759bbb0ce55eb86be6313a29f8f67ab (patch) | |
tree | bab8467545703991770ec542ffb90a98dbe87868 /src/plugins/fset | |
parent | f519499057790407bfdcbe568f1c4b5059edc732 (diff) | |
download | weechat-263c2904a759bbb0ce55eb86be6313a29f8f67ab.zip |
fset: add completion "fset_options"
Diffstat (limited to 'src/plugins/fset')
-rw-r--r-- | src/plugins/fset/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/plugins/fset/Makefile.am | 2 | ||||
-rw-r--r-- | src/plugins/fset/fset-command.c | 2 | ||||
-rw-r--r-- | src/plugins/fset/fset-completion.c | 104 | ||||
-rw-r--r-- | src/plugins/fset/fset-completion.h | 25 | ||||
-rw-r--r-- | src/plugins/fset/fset.c | 3 |
6 files changed, 136 insertions, 1 deletions
diff --git a/src/plugins/fset/CMakeLists.txt b/src/plugins/fset/CMakeLists.txt index ef6c7e51f..510ef4afc 100644 --- a/src/plugins/fset/CMakeLists.txt +++ b/src/plugins/fset/CMakeLists.txt @@ -22,6 +22,7 @@ fset.c fset.h fset-bar-item.c fset-bar-item.h fset-buffer.c fset-buffer.h fset-command.c fset-command.h +fset-completion.c fset-completion.h fset-config.c fset-config.h fset-info.c fset-info.h fset-mouse.c fset-mouse.h diff --git a/src/plugins/fset/Makefile.am b/src/plugins/fset/Makefile.am index 5121614f6..db9b8ab3f 100644 --- a/src/plugins/fset/Makefile.am +++ b/src/plugins/fset/Makefile.am @@ -31,6 +31,8 @@ fset_la_SOURCES = fset.c \ fset-buffer.h \ fset-command.c \ fset-command.h \ + fset-completion.c \ + fset-completion.h \ fset-config.c \ fset-config.h \ fset-info.c \ diff --git a/src/plugins/fset/fset-command.c b/src/plugins/fset/fset-command.c index e164e1cd0..f33389320 100644 --- a/src/plugins/fset/fset-command.c +++ b/src/plugins/fset/fset-command.c @@ -751,7 +751,7 @@ fset_command_init () " || -append" " || -mark" " || -export -help|-nohelp|%(filename) %(filename)" - " || *|c:|f:|s:|d|d:|d=|d==|=|==", + " || *|c:|f:|s:|d|d:|d=|d==|=|==|%(fset_options)", &fset_command_fset, NULL, NULL); weechat_hook_command_run ("/set", &fset_command_run_set_cb, NULL, NULL); } diff --git a/src/plugins/fset/fset-completion.c b/src/plugins/fset/fset-completion.c new file mode 100644 index 000000000..e4d4ba7a9 --- /dev/null +++ b/src/plugins/fset/fset-completion.c @@ -0,0 +1,104 @@ +/* + * fset-completion.c - completion for Fast Set commands + * + * Copyright (C) 2003-2017 Sébastien Helleu <flashcode@flashtux.org> + * + * This file is part of WeeChat, the extensible chat client. + * + * WeeChat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * WeeChat is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with WeeChat. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <stdlib.h> + +#include "../weechat-plugin.h" +#include "fset.h" + + +/* + * Adds current server to completion list. + */ + +int +fset_completion_option_cb (const void *pointer, void *data, + const char *completion_item, + struct t_gui_buffer *buffer, + struct t_gui_completion *completion) +{ + struct t_config_file *ptr_config; + struct t_config_section *ptr_section; + struct t_config_option *ptr_option; + int config_section_added; + + /* make C compiler happy */ + (void) pointer; + (void) data; + (void) completion_item; + (void) buffer; + + ptr_config = weechat_hdata_get_list (fset_hdata_config_file, + "config_files"); + while (ptr_config) + { + ptr_section = weechat_hdata_pointer (fset_hdata_config_file, + ptr_config, "sections"); + while (ptr_section) + { + config_section_added = 0; + ptr_option = weechat_hdata_pointer (fset_hdata_config_section, + ptr_section, "options"); + while (ptr_option) + { + if (!config_section_added) + { + weechat_hook_completion_list_add ( + completion, + weechat_config_option_get_string (ptr_option, + "config_name"), + 0, WEECHAT_LIST_POS_SORT); + weechat_hook_completion_list_add ( + completion, + weechat_config_option_get_string (ptr_option, + "section_name"), + 0, WEECHAT_LIST_POS_SORT); + config_section_added = 1; + } + weechat_hook_completion_list_add ( + completion, + weechat_config_option_get_string (ptr_option, "name"), + 0, WEECHAT_LIST_POS_SORT); + ptr_option = weechat_hdata_move (fset_hdata_config_option, + ptr_option, 1); + } + ptr_section = weechat_hdata_move (fset_hdata_config_section, + ptr_section, 1); + } + ptr_config = weechat_hdata_move (fset_hdata_config_file, + ptr_config, 1); + } + + return WEECHAT_RC_OK; +} + +/* + * Hooks completions. + */ + +void +fset_completion_init () +{ + weechat_hook_completion ("fset_options", + N_("configuration files, sections, options and " + "word of options"), + &fset_completion_option_cb, NULL, NULL); +} diff --git a/src/plugins/fset/fset-completion.h b/src/plugins/fset/fset-completion.h new file mode 100644 index 000000000..0e5036a1a --- /dev/null +++ b/src/plugins/fset/fset-completion.h @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2003-2017 Sébastien Helleu <flashcode@flashtux.org> + * + * This file is part of WeeChat, the extensible chat client. + * + * WeeChat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * WeeChat is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with WeeChat. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef WEECHAT_FSET_COMPLETION_H +#define WEECHAT_FSET_COMPLETION_H 1 + +extern void fset_completion_init (); + +#endif /* WEECHAT_FSET_COMPLETION_H */ diff --git a/src/plugins/fset/fset.c b/src/plugins/fset/fset.c index 13333dbf2..c05157035 100644 --- a/src/plugins/fset/fset.c +++ b/src/plugins/fset/fset.c @@ -28,6 +28,7 @@ #include "fset-bar-item.h" #include "fset-buffer.h" #include "fset-command.h" +#include "fset-completion.h" #include "fset-config.h" #include "fset-info.h" #include "fset-mouse.h" @@ -98,6 +99,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) fset_command_init (); + fset_completion_init (); + if (weechat_config_boolean (fset_config_look_show_help_bar)) fset_add_bar (); |