diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/wee-command.c | 129 | ||||
-rw-r--r-- | src/core/wee-upgrade.c | 11 |
2 files changed, 96 insertions, 44 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c index d33d4373f..f38477878 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -1823,7 +1823,6 @@ COMMAND_CALLBACK(filter) /* make C compiler happy */ (void) data; - (void) buffer; if ((argc == 1) || ((argc == 2) && (string_strcasecmp (argv[1], "list") == 0))) @@ -1860,26 +1859,41 @@ COMMAND_CALLBACK(filter) { if (argc > 2) { - /* enable a filter */ - ptr_filter = gui_filter_search_by_name (argv[2]); - if (ptr_filter) + if (strcmp (argv[2], "@") == 0) { - if (!ptr_filter->enabled) + /* enable filters in buffer */ + if (!buffer->filter) { - ptr_filter->enabled = 1; - gui_filter_all_buffers (); - gui_chat_printf_date_tags (NULL, 0, GUI_FILTER_TAG_NO_FILTER, - _("Filter \"%s\" enabled"), - ptr_filter->name); + buffer->filter = 1; + gui_filter_buffer (buffer, NULL); } } else { - gui_chat_printf_date_tags (NULL, 0, GUI_FILTER_TAG_NO_FILTER, - _("%sError: filter \"%s\" not found"), - gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], - argv[2]); - return WEECHAT_RC_OK; + /* enable a filter */ + ptr_filter = gui_filter_search_by_name (argv[2]); + if (ptr_filter) + { + if (!ptr_filter->enabled) + { + ptr_filter->enabled = 1; + gui_filter_all_buffers (); + gui_chat_printf_date_tags (NULL, 0, + GUI_FILTER_TAG_NO_FILTER, + _("Filter \"%s\" enabled"), + ptr_filter->name); + } + } + else + { + gui_chat_printf_date_tags (NULL, 0, + GUI_FILTER_TAG_NO_FILTER, + _("%sError: filter \"%s\" not " + "found"), + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], + argv[2]); + return WEECHAT_RC_OK; + } } } else @@ -1900,26 +1914,41 @@ COMMAND_CALLBACK(filter) { if (argc > 2) { - /* disable a filter */ - ptr_filter = gui_filter_search_by_name (argv[2]); - if (ptr_filter) + if (strcmp (argv[2], "@") == 0) { - if (ptr_filter->enabled) + /* disable filters in buffer */ + if (buffer->filter) { - ptr_filter->enabled = 0; - gui_filter_all_buffers (); - gui_chat_printf_date_tags (NULL, 0, GUI_FILTER_TAG_NO_FILTER, - _("Filter \"%s\" disabled"), - ptr_filter->name); + buffer->filter = 0; + gui_filter_buffer (buffer, NULL); } } else { - gui_chat_printf_date_tags (NULL, 0, GUI_FILTER_TAG_NO_FILTER, - _("%sError: filter \"%s\" not found"), - gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], - argv[2]); - return WEECHAT_RC_OK; + /* disable a filter */ + ptr_filter = gui_filter_search_by_name (argv[2]); + if (ptr_filter) + { + if (ptr_filter->enabled) + { + ptr_filter->enabled = 0; + gui_filter_all_buffers (); + gui_chat_printf_date_tags (NULL, 0, + GUI_FILTER_TAG_NO_FILTER, + _("Filter \"%s\" disabled"), + ptr_filter->name); + } + } + else + { + gui_chat_printf_date_tags (NULL, 0, + GUI_FILTER_TAG_NO_FILTER, + _("%sError: filter \"%s\" not " + "found"), + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], + argv[2]); + return WEECHAT_RC_OK; + } } } else @@ -1940,20 +1969,31 @@ COMMAND_CALLBACK(filter) { if (argc > 2) { - /* toggle a filter */ - ptr_filter = gui_filter_search_by_name (argv[2]); - if (ptr_filter) + if (strcmp (argv[2], "@") == 0) { - ptr_filter->enabled ^= 1; - gui_filter_all_buffers (); + /* toggle filters in buffer */ + buffer->filter ^= 1; + gui_filter_buffer (buffer, NULL); } else { - gui_chat_printf_date_tags (NULL, 0, GUI_FILTER_TAG_NO_FILTER, - _("%sError: filter \"%s\" not found"), - gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], - argv[2]); - return WEECHAT_RC_OK; + /* toggle a filter */ + ptr_filter = gui_filter_search_by_name (argv[2]); + if (ptr_filter) + { + ptr_filter->enabled ^= 1; + gui_filter_all_buffers (); + } + else + { + gui_chat_printf_date_tags (NULL, 0, + GUI_FILTER_TAG_NO_FILTER, + _("%sError: filter \"%s\" not " + "found"), + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], + argv[2]); + return WEECHAT_RC_OK; + } } } else @@ -6872,7 +6912,7 @@ command_init () N_("filter messages in buffers, to hide/show them according to tags or " "regex"), N_("list" - " || enable|disable|toggle [<name>]" + " || enable|disable|toggle [<name>|@]" " || add <name> <buffer>[,<buffer>...] <tags> <regex>" " || rename <name> <new_name>" " || del <name>|-all"), @@ -6880,7 +6920,8 @@ command_init () " enable: enable filters (filters are enabled by default)\n" "disable: disable filters\n" " toggle: toggle filters\n" - " name: filter name\n" + " name: filter name (\"@\" = enable/disable all filters in current " + "buffer)\n" " add: add a filter\n" " rename: rename a filter\n" " del: delete a filter\n" @@ -6936,9 +6977,9 @@ command_init () " filter lines containing \"weechat sucks\" on IRC channel #weechat:\n" " /filter add sucks irc.freenode.#weechat * weechat sucks"), "list" - " || enable %(filters_names)" - " || disable %(filters_names)" - " || toggle %(filters_names)" + " || enable %(filters_names)|@" + " || disable %(filters_names)|@" + " || toggle %(filters_names)|@" " || add %(filters_names) %(buffers_plugins_names)|*" " || rename %(filters_names) %(filters_names)" " || del %(filters_names)|-all", diff --git a/src/core/wee-upgrade.c b/src/core/wee-upgrade.c index ccc24ef37..0e1b6a242 100644 --- a/src/core/wee-upgrade.c +++ b/src/core/wee-upgrade.c @@ -481,6 +481,7 @@ upgrade_weechat_read_cb (void *data, { upgrade_current_buffer->day_change = 1; } + /* "clear" is in WeeChat >= 0.4.4 */ if (infolist_search_var (infolist, "clear")) { upgrade_current_buffer->clear = @@ -492,6 +493,16 @@ upgrade_weechat_read_cb (void *data, (upgrade_current_buffer->type == GUI_BUFFER_TYPE_FREE) ? 0 : 1; } + /* "filter" is in WeeChat >= 0.4.4 */ + if (infolist_search_var (infolist, "filter")) + { + upgrade_current_buffer->filter = + infolist_integer (infolist, "filter"); + } + else + { + upgrade_current_buffer->filter = 1; + } upgrade_current_buffer->nicklist_case_sensitive = infolist_integer (infolist, "nicklist_case_sensitive"); upgrade_current_buffer->nicklist_display_groups = |