diff --git a/doc/docgen.py b/doc/docgen.py index e3479dece..a5805e129 100644 --- a/doc/docgen.py +++ b/doc/docgen.py @@ -90,7 +90,7 @@ PLUGIN_LIST = { 'weechat': 'co', 'alias': '', 'aspell': 'o', - 'buflist': 'o', + 'buflist': 'co', 'charset': 'o', 'exec': 'o', 'fifo': 'o', diff --git a/doc/en/weechat_dev.en.adoc b/doc/en/weechat_dev.en.adoc index dd8a6673f..f2ddf6a3b 100644 --- a/doc/en/weechat_dev.en.adoc +++ b/doc/en/weechat_dev.en.adoc @@ -197,6 +197,7 @@ WeeChat "core" is located in following directories: |    buflist/ | Buflist plugin. |       buflist.c | Main buflist functions. |       buflist-bar-item.c | Buflist bar items. +|       buflist-command.c | Buflist commands. |       buflist-config.c | Buflist config options (file buflist.conf). |    charset/ | Charset plugin. |       charset.c | Charset functions. diff --git a/doc/fr/weechat_dev.fr.adoc b/doc/fr/weechat_dev.fr.adoc index 949936778..0e10cb813 100644 --- a/doc/fr/weechat_dev.fr.adoc +++ b/doc/fr/weechat_dev.fr.adoc @@ -199,6 +199,7 @@ Le cœur de WeeChat est situé dans les répertoires suivants : |    buflist/ | Extension Buflist. |       buflist.c | Fonctions principales de Buflist. |       buflist-bar-item.c | Objets de barre Buflist. +|       buflist-command.c | Commandes pour Buflist. |       buflist-config.c | Options de configuration pour Buflist (fichier buflist.conf). |    charset/ | Extension Charset. |       charset.c | Fonctions pour Charset. diff --git a/doc/ja/weechat_dev.ja.adoc b/doc/ja/weechat_dev.ja.adoc index 33a5b2fdf..8513b51dc 100644 --- a/doc/ja/weechat_dev.ja.adoc +++ b/doc/ja/weechat_dev.ja.adoc @@ -203,6 +203,7 @@ WeeChat "core" は以下のディレクトリに配置されています: |    buflist/ | buflist プラグイン |       buflist.c | buflist の主要関数 |       buflist-bar-item.c | buflist バー要素 +|       buflist-command.c | buflist コマンド |       buflist-config.c | buflist 設定オプション (buflist.conf ファイル) |    charset/ | charset プラグイン |       charset.c | charset 関数 diff --git a/po/POTFILES.in b/po/POTFILES.in index f957e2522..e0bccfd13 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -124,6 +124,8 @@ ./src/plugins/buflist/buflist-bar-item.c ./src/plugins/buflist/buflist-bar-item.h ./src/plugins/buflist/buflist.c +./src/plugins/buflist/buflist-command.c +./src/plugins/buflist/buflist-command.h ./src/plugins/buflist/buflist-config.c ./src/plugins/buflist/buflist-config.h ./src/plugins/buflist/buflist.h diff --git a/po/srcfiles.cmake b/po/srcfiles.cmake index d6bfb273b..b03a1b4dd 100644 --- a/po/srcfiles.cmake +++ b/po/srcfiles.cmake @@ -125,6 +125,8 @@ SET(WEECHAT_SOURCES ./src/plugins/buflist/buflist-bar-item.c ./src/plugins/buflist/buflist-bar-item.h ./src/plugins/buflist/buflist.c +./src/plugins/buflist/buflist-command.c +./src/plugins/buflist/buflist-command.h ./src/plugins/buflist/buflist-config.c ./src/plugins/buflist/buflist-config.h ./src/plugins/buflist/buflist.h diff --git a/src/plugins/buflist/CMakeLists.txt b/src/plugins/buflist/CMakeLists.txt index 5f15447f3..f19e425b7 100644 --- a/src/plugins/buflist/CMakeLists.txt +++ b/src/plugins/buflist/CMakeLists.txt @@ -20,6 +20,7 @@ add_library(buflist MODULE buflist.c buflist.h buflist-bar-item.c buflist-bar-item.h +buflist-command.c buflist-command.h buflist-config.c buflist-config.h) set_target_properties(buflist PROPERTIES PREFIX "") diff --git a/src/plugins/buflist/Makefile.am b/src/plugins/buflist/Makefile.am index 72453f803..dabf9c70d 100644 --- a/src/plugins/buflist/Makefile.am +++ b/src/plugins/buflist/Makefile.am @@ -27,6 +27,8 @@ buflist_la_SOURCES = buflist.c \ buflist.h \ buflist-bar-item.c \ buflist-bar-item.h \ + buflist-command.c \ + buflist-command.h \ buflist-config.c \ buflist-config.h diff --git a/src/plugins/buflist/buflist-bar-item.c b/src/plugins/buflist/buflist-bar-item.c index a84ac26dd..17092f114 100644 --- a/src/plugins/buflist/buflist-bar-item.c +++ b/src/plugins/buflist/buflist-bar-item.c @@ -144,6 +144,10 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data, "buffer", ptr_buffer); /* set extra variables */ + weechat_hashtable_set (buflist_hashtable_extra_vars, + "format_buffer", + weechat_config_string ( + buflist_config_format_buffer)); weechat_hashtable_set (buflist_hashtable_extra_vars, "number", str_number); weechat_hashtable_set (buflist_hashtable_extra_vars, diff --git a/src/plugins/buflist/buflist-command.c b/src/plugins/buflist/buflist-command.c new file mode 100644 index 000000000..57156f907 --- /dev/null +++ b/src/plugins/buflist/buflist-command.c @@ -0,0 +1,110 @@ +/* + * buflist-command.c - buflist command + * + * Copyright (C) 2003-2017 Sébastien Helleu + * + * 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 . + */ + +#include +#include +#include +#include + +#include "../weechat-plugin.h" +#include "buflist.h" +#include "buflist-bar-item.h" +#include "buflist-command.h" + + +/* + * Callback for command "/buflist". + */ + +int +buflist_command_buflist (const void *pointer, void *data, + struct t_gui_buffer *buffer, int argc, + char **argv, char **argv_eol) +{ + /* make C compiler happy */ + (void) pointer; + (void) data; + (void) buffer; + (void) argc; + (void) argv; + (void) argv_eol; + + if (argc == 1) + return WEECHAT_RC_OK; + + if (weechat_strcasecmp (argv[1], "refresh") == 0) + { + weechat_bar_item_update (BUFLIST_BAR_ITEM_NAME); + return WEECHAT_RC_OK; + } + + WEECHAT_COMMAND_ERROR; +} + +/* + * Hooks buflist commands. + */ + +void +buflist_command_init () +{ + weechat_hook_command ( + "buflist", + N_("bar item with list of buffers"), + "refresh", + N_("refresh: force the refresh of the buflist bar item\n" + "\n" + "The lines with buffers are displayed using string evaluation " + "(see /help eval for the format), with two main options:\n" + " - buflist.format.buffer: format for a buffer which is not " + "current buffer\n" + " - buflist.format.buffer_current: format for the current buffer\n" + "\n" + "The following variables can be used in these options:\n" + " - buffer data (see hdata \"buffer\" in API doc for a complete " + "list), for example:\n" + " - ${buffer.number}\n" + " - ${buffer.name}\n" + " - ${buffer.full_name}\n" + " - ${buffer.short_name}\n" + " - ${buffer.nicklist_nicks_count}\n" + " - extra variables added by buflist for convenience:\n" + " - ${format_buffer}: the evaluated value of option " + "buflist.format.buffer; this can be used in option " + "buflist.format.buffer_current to just change the background color " + "for example\n" + " - ${number}: indented number, for example \" 1\" if there " + "are between 10 and 99 buffers opened\n" + " - ${indent}: indentation for name (channel and private " + "buffers are indented)\n" + " - ${name}: the short name (if set), with a fallback on the " + "name\n" + " - ${color_hotlist}: the color depending on the highest " + "hotlist level for the buffer, which is the content of option " + "buflist.format.hotlist_xxx (xxx is the level)\n" + " - ${format_hotlist}: the formatted hotlist (evaluation " + "of option buflist.format.hotlist)\n" + " - ${hotlist}: the raw hotlist\n" + " - ${format_lag}: the lag for an IRC server buffer " + "(empty if there's no lag)\n"), + "refresh", + &buflist_command_buflist, NULL, NULL); +} diff --git a/src/plugins/buflist/buflist-command.h b/src/plugins/buflist/buflist-command.h new file mode 100644 index 000000000..5f622ecee --- /dev/null +++ b/src/plugins/buflist/buflist-command.h @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2003-2017 Sébastien Helleu + * + * 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 . + */ + +#ifndef WEECHAT_BUFLIST_COMMAND_H +#define WEECHAT_BUFLIST_COMMAND_H 1 + +extern void buflist_command_init (); + +#endif /* WEECHAT_BUFLIST_COMMAND_H */ diff --git a/src/plugins/buflist/buflist-config.c b/src/plugins/buflist/buflist-config.c index 2253bebf1..cb4711001 100644 --- a/src/plugins/buflist/buflist-config.c +++ b/src/plugins/buflist/buflist-config.c @@ -148,7 +148,8 @@ buflist_config_init () buflist_config_format_buffer = weechat_config_new_option ( buflist_config_file, ptr_section, "buffer", "string", - N_("format of each line with a buffer"), + N_("format of each line with a buffer " + "(note: content is evaluated, see /help buflist)"), NULL, 0, 0, "${color:green}${number}.${indent}${color_hotlist}${name}", NULL, 0, @@ -158,7 +159,8 @@ buflist_config_init () buflist_config_format_buffer_current = weechat_config_new_option ( buflist_config_file, ptr_section, "buffer_current", "string", - N_("format for the line with current buffer"), + N_("format for the line with current buffer " + "(note: content is evaluated, see /help buflist)"), NULL, 0, 0, "${color:lightgreen,blue}${number}.${indent}${color_hotlist}${name}", NULL, 0, @@ -168,7 +170,8 @@ buflist_config_init () buflist_config_format_hotlist = weechat_config_new_option ( buflist_config_file, ptr_section, "hotlist", "string", - N_("format for hotlist"), + N_("format for hotlist " + "(note: content is evaluated, see /help buflist)"), NULL, 0, 0, " ${color:green}(${hotlist}${color:green})", NULL, 0, @@ -178,7 +181,8 @@ buflist_config_init () buflist_config_format_hotlist_level[0] = weechat_config_new_option ( buflist_config_file, ptr_section, "hotlist_low", "string", - N_("format for a buffer with hotlist level \"low\""), + N_("format for a buffer with hotlist level \"low\" " + "(note: content is evaluated, see /help buflist)"), NULL, 0, 0, "${color:white}", NULL, 0, @@ -188,7 +192,8 @@ buflist_config_init () buflist_config_format_hotlist_level[1] = weechat_config_new_option ( buflist_config_file, ptr_section, "hotlist_message", "string", - N_("format for a buffer with hotlist level \"message\""), + N_("format for a buffer with hotlist level \"message\" " + "(note: content is evaluated, see /help buflist)"), NULL, 0, 0, "${color:brown}", NULL, 0, @@ -198,7 +203,8 @@ buflist_config_init () buflist_config_format_hotlist_level[2] = weechat_config_new_option ( buflist_config_file, ptr_section, "hotlist_private", "string", - N_("format for a buffer with hotlist level \"private\""), + N_("format for a buffer with hotlist level \"private\" " + "(note: content is evaluated, see /help buflist)"), NULL, 0, 0, "${color:green}", NULL, 0, @@ -208,7 +214,8 @@ buflist_config_init () buflist_config_format_hotlist_level[3] = weechat_config_new_option ( buflist_config_file, ptr_section, "hotlist_highlight", "string", - N_("format for a buffer with hotlist level \"highlight\""), + N_("format for a buffer with hotlist level \"highlight\" " + "(note: content is evaluated, see /help buflist)"), NULL, 0, 0, "${color:magenta}", NULL, 0, @@ -218,7 +225,8 @@ buflist_config_init () buflist_config_format_hotlist_level_none = weechat_config_new_option ( buflist_config_file, ptr_section, "hotlist_none", "string", - N_("format for a buffer not in hotlist"), + N_("format for a buffer not in hotlist " + "(note: content is evaluated, see /help buflist)"), NULL, 0, 0, "${color:default}", NULL, 0, @@ -228,7 +236,8 @@ buflist_config_init () buflist_config_format_hotlist_separator = weechat_config_new_option ( buflist_config_file, ptr_section, "hotlist_separator", "string", - N_("separator for counts in hotlist"), + N_("separator for counts in hotlist " + "(note: content is evaluated, see /help buflist)"), NULL, 0, 0, "${color:default},", NULL, 0, @@ -238,7 +247,8 @@ buflist_config_init () buflist_config_format_lag = weechat_config_new_option ( buflist_config_file, ptr_section, "lag", "string", - N_("format for lag on an irc server buffer"), + N_("format for lag on an irc server buffer " + "(note: content is evaluated, see /help buflist)"), NULL, 0, 0, " ${color:green}[${color:brown}${lag}${color:green}]", NULL, 0, diff --git a/src/plugins/buflist/buflist.c b/src/plugins/buflist/buflist.c index daf83a1fd..1a6d772df 100644 --- a/src/plugins/buflist/buflist.c +++ b/src/plugins/buflist/buflist.c @@ -25,6 +25,7 @@ #include "../weechat-plugin.h" #include "buflist.h" #include "buflist-bar-item.h" +#include "buflist-command.h" #include "buflist-config.h" @@ -272,6 +273,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) if (!buflist_bar_item_init ()) return WEECHAT_RC_ERROR; + buflist_command_init (); + /* hook some signals */ for (i = 0; signals_buffers[i]; i++) {