mirror of
https://github.com/weechat/weechat.git
synced 2026-06-29 06:16:40 +02:00
fset: add completion "fset_options"
This commit is contained in:
@@ -156,6 +156,8 @@
|
||||
./src/plugins/fset/fset-buffer.h
|
||||
./src/plugins/fset/fset-command.c
|
||||
./src/plugins/fset/fset-command.h
|
||||
./src/plugins/fset/fset-completion.c
|
||||
./src/plugins/fset/fset-completion.h
|
||||
./src/plugins/fset/fset-config.c
|
||||
./src/plugins/fset/fset-config.h
|
||||
./src/plugins/fset/fset-info.c
|
||||
|
||||
@@ -157,6 +157,8 @@ SET(WEECHAT_SOURCES
|
||||
./src/plugins/fset/fset-buffer.h
|
||||
./src/plugins/fset/fset-command.c
|
||||
./src/plugins/fset/fset-command.h
|
||||
./src/plugins/fset/fset-completion.c
|
||||
./src/plugins/fset/fset-completion.h
|
||||
./src/plugins/fset/fset-config.c
|
||||
./src/plugins/fset/fset-config.h
|
||||
./src/plugins/fset/fset-info.c
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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 */
|
||||
@@ -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 ();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user