1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-27 13:26:38 +02:00

Use '!' to reverse a regex in a filter (to keep lines matching regex and hide other lines)

This commit is contained in:
Sebastien Helleu
2010-07-16 19:45:14 +02:00
parent 790b1cdf1a
commit 8dc23863c5
12 changed files with 119 additions and 44 deletions
+3 -1
View File
@@ -1,12 +1,14 @@
WeeChat ChangeLog
=================
Sébastien Helleu <flashcode@flashtux.org>
v0.3.3-dev, 2010-07-12
v0.3.3-dev, 2010-07-16
Version 0.3.3 (under dev!)
--------------------------
* core: use '!' to reverse a regex in a filter (to keep lines matching regex
and hide other lines)
* core: add keys for undo/redo changes on command line
(default: ctrl/alt + underscore) (task #9483)
* core: add new option weechat.look.align_end_of_lines
+9 -3
View File
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.3-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-07-11 12:14+0200\n"
"POT-Creation-Date: 2010-07-16 15:42+0200\n"
"PO-Revision-Date: 2010-06-20 21:24+0200\n"
"Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1040,6 +1040,7 @@ msgstr ""
"[list] | [enable|disable|toggle [name]] | [add jméno plugin.buffer tags "
"regex] | [del name|-all]"
#, fuzzy
msgid ""
" list: list all filters\n"
" enable: enable filters (filters are enabled by default)\n"
@@ -1053,8 +1054,11 @@ msgid ""
"buffers)\n"
" tags: comma separated list of tags, for example: \"irc_join,"
"irc_part,irc_quit\"\n"
" regex: regular expression to search in line (use \\t to separate "
"prefix from message, special chars like '|' must be escaped: '\\|')\n"
" regex: regular expression to search in line\n"
" - use '\\t' to separate prefix from message, special chars "
"like '|' must be escaped: '\\|'\n"
" - if regex starts with '!', then matching result is reversed "
"(use '\\!' to start with '!')\n"
"\n"
"The default key alt+'=' toggles filtering on/off.\n"
"\n"
@@ -1074,6 +1078,8 @@ msgid ""
" /filter add nicks * irc_366 *\n"
" filter nick \"toto\" on IRC channel #weechat:\n"
" /filter add toto irc.freenode.#weechat * toto\\t\n"
" keep only nick \"titi\" on IRC channel #test:\n"
" /filter add titi irc.freenode.#test * !titi\\t\n"
" filter lines containing word \"spam\":\n"
" /filter add filterspam * * spam\n"
" filter lines containing \"weechat sucks\" on IRC channel #weechat:\n"
+9 -3
View File
@@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.3-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-07-15 08:32+0200\n"
"POT-Creation-Date: 2010-07-16 15:42+0200\n"
"PO-Revision-Date: 2010-07-12 11:04+0100\n"
"Last-Translator: Nils G.\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1062,6 +1062,7 @@ msgstr ""
"[list] | [enable|disable|toggle [name]] | [add name plugin.buffer tags "
"regex] | [del name|-all]"
#, fuzzy
msgid ""
" list: list all filters\n"
" enable: enable filters (filters are enabled by default)\n"
@@ -1075,8 +1076,11 @@ msgid ""
"buffers)\n"
" tags: comma separated list of tags, for example: \"irc_join,"
"irc_part,irc_quit\"\n"
" regex: regular expression to search in line (use \\t to separate "
"prefix from message, special chars like '|' must be escaped: '\\|')\n"
" regex: regular expression to search in line\n"
" - use '\\t' to separate prefix from message, special chars "
"like '|' must be escaped: '\\|'\n"
" - if regex starts with '!', then matching result is reversed "
"(use '\\!' to start with '!')\n"
"\n"
"The default key alt+'=' toggles filtering on/off.\n"
"\n"
@@ -1096,6 +1100,8 @@ msgid ""
" /filter add nicks * irc_366 *\n"
" filter nick \"toto\" on IRC channel #weechat:\n"
" /filter add toto irc.freenode.#weechat * toto\\t\n"
" keep only nick \"titi\" on IRC channel #test:\n"
" /filter add titi irc.freenode.#test * !titi\\t\n"
" filter lines containing word \"spam\":\n"
" /filter add filterspam * * spam\n"
" filter lines containing \"weechat sucks\" on IRC channel #weechat:\n"
+9 -3
View File
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.3-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-07-11 12:14+0200\n"
"POT-Creation-Date: 2010-07-16 15:42+0200\n"
"PO-Revision-Date: 2010-06-20 21:24+0200\n"
"Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1046,6 +1046,7 @@ msgstr ""
"[list] | [enable|disable|toggle [nombre]] | [add nombre plugin.buffer "
"etiquetas regex] | [del nombre|-all]"
#, fuzzy
msgid ""
" list: list all filters\n"
" enable: enable filters (filters are enabled by default)\n"
@@ -1059,8 +1060,11 @@ msgid ""
"buffers)\n"
" tags: comma separated list of tags, for example: \"irc_join,"
"irc_part,irc_quit\"\n"
" regex: regular expression to search in line (use \\t to separate "
"prefix from message, special chars like '|' must be escaped: '\\|')\n"
" regex: regular expression to search in line\n"
" - use '\\t' to separate prefix from message, special chars "
"like '|' must be escaped: '\\|'\n"
" - if regex starts with '!', then matching result is reversed "
"(use '\\!' to start with '!')\n"
"\n"
"The default key alt+'=' toggles filtering on/off.\n"
"\n"
@@ -1080,6 +1084,8 @@ msgid ""
" /filter add nicks * irc_366 *\n"
" filter nick \"toto\" on IRC channel #weechat:\n"
" /filter add toto irc.freenode.#weechat * toto\\t\n"
" keep only nick \"titi\" on IRC channel #test:\n"
" /filter add titi irc.freenode.#test * !titi\\t\n"
" filter lines containing word \"spam\":\n"
" /filter add filterspam * * spam\n"
" filter lines containing \"weechat sucks\" on IRC channel #weechat:\n"
+16 -7
View File
@@ -21,8 +21,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.3-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-07-11 12:14+0200\n"
"PO-Revision-Date: 2010-07-10 09:31+0200\n"
"POT-Creation-Date: 2010-07-16 15:42+0200\n"
"PO-Revision-Date: 2010-07-16 14:57+0200\n"
"Last-Translator: Sebastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: French\n"
@@ -1063,8 +1063,11 @@ msgid ""
"buffers)\n"
" tags: comma separated list of tags, for example: \"irc_join,"
"irc_part,irc_quit\"\n"
" regex: regular expression to search in line (use \\t to separate "
"prefix from message, special chars like '|' must be escaped: '\\|')\n"
" regex: regular expression to search in line\n"
" - use '\\t' to separate prefix from message, special chars "
"like '|' must be escaped: '\\|'\n"
" - if regex starts with '!', then matching result is reversed "
"(use '\\!' to start with '!')\n"
"\n"
"The default key alt+'=' toggles filtering on/off.\n"
"\n"
@@ -1084,6 +1087,8 @@ msgid ""
" /filter add nicks * irc_366 *\n"
" filter nick \"toto\" on IRC channel #weechat:\n"
" /filter add toto irc.freenode.#weechat * toto\\t\n"
" keep only nick \"titi\" on IRC channel #test:\n"
" /filter add titi irc.freenode.#test * !titi\\t\n"
" filter lines containing word \"spam\":\n"
" /filter add filterspam * * spam\n"
" filter lines containing \"weechat sucks\" on IRC channel #weechat:\n"
@@ -1101,9 +1106,11 @@ msgstr ""
"tous les tampons)\n"
" tags: liste de tags, séparés par des virgules, par exemple: "
"\"irc_join,irc_part,irc_quit\"\n"
" regex: expressoin régulière à rechercher dans la ligne (utiliser "
"\\t pour séparer le préfixe du message, les caractères spéciaux comme '|' "
"doivent être échappés: '\\|')\n"
" regex: expression régulière à rechercher dans la ligne\n"
" - utiliser '\\t' pour séparer le préfixe du message, les "
"caractères spéciaux comme '|' doivent être échappés: '\\|'\n"
" - si l'expression régulière commence par '!' alors le "
"résultat est inversé (utiliser '\\!' pour démarrer par '!')\n"
"\n"
"La touche par défaut alt+'=' active/désactive le filtrage.\n"
"\n"
@@ -1123,6 +1130,8 @@ msgstr ""
" /filter add nicks * irc_366 *\n"
" filtrer le pseudo \"toto\" sur le canal IRC #weechat:\n"
" /filter add toto irc.freenode.#weechat * toto\\t\n"
" garder uniquement le pseudo \"titi\" sur le canal IRC #test:\n"
" /filter add titi irc.freenode.#test * !titi\\t\n"
" filtrer les lignes contenant le mot \"spam\":\n"
" /filter add filtrespam * * spam\n"
" filtrer les lignes contenant \"weechat sucks\" sur le canal IRC #weechat:\n"
+8 -3
View File
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.3-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-07-11 12:14+0200\n"
"POT-Creation-Date: 2010-07-16 15:42+0200\n"
"PO-Revision-Date: 2010-06-20 21:24+0200\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1030,8 +1030,11 @@ msgid ""
"buffers)\n"
" tags: comma separated list of tags, for example: \"irc_join,"
"irc_part,irc_quit\"\n"
" regex: regular expression to search in line (use \\t to separate "
"prefix from message, special chars like '|' must be escaped: '\\|')\n"
" regex: regular expression to search in line\n"
" - use '\\t' to separate prefix from message, special chars "
"like '|' must be escaped: '\\|'\n"
" - if regex starts with '!', then matching result is reversed "
"(use '\\!' to start with '!')\n"
"\n"
"The default key alt+'=' toggles filtering on/off.\n"
"\n"
@@ -1051,6 +1054,8 @@ msgid ""
" /filter add nicks * irc_366 *\n"
" filter nick \"toto\" on IRC channel #weechat:\n"
" /filter add toto irc.freenode.#weechat * toto\\t\n"
" keep only nick \"titi\" on IRC channel #test:\n"
" /filter add titi irc.freenode.#test * !titi\\t\n"
" filter lines containing word \"spam\":\n"
" /filter add filterspam * * spam\n"
" filter lines containing \"weechat sucks\" on IRC channel #weechat:\n"
+9 -3
View File
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Weechat 0.3.3-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-07-11 12:14+0200\n"
"POT-Creation-Date: 2010-07-16 15:42+0200\n"
"PO-Revision-Date: 2010-06-20 21:24+0200\n"
"Last-Translator: Marco Paolone <marcopaolone@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1039,6 +1039,7 @@ msgstr ""
"[list] | [enable|disable|toggle [nome]] | [add nome plugin.buffer tag regex] "
"| [del nome|-all]"
#, fuzzy
msgid ""
" list: list all filters\n"
" enable: enable filters (filters are enabled by default)\n"
@@ -1052,8 +1053,11 @@ msgid ""
"buffers)\n"
" tags: comma separated list of tags, for example: \"irc_join,"
"irc_part,irc_quit\"\n"
" regex: regular expression to search in line (use \\t to separate "
"prefix from message, special chars like '|' must be escaped: '\\|')\n"
" regex: regular expression to search in line\n"
" - use '\\t' to separate prefix from message, special chars "
"like '|' must be escaped: '\\|'\n"
" - if regex starts with '!', then matching result is reversed "
"(use '\\!' to start with '!')\n"
"\n"
"The default key alt+'=' toggles filtering on/off.\n"
"\n"
@@ -1073,6 +1077,8 @@ msgid ""
" /filter add nicks * irc_366 *\n"
" filter nick \"toto\" on IRC channel #weechat:\n"
" /filter add toto irc.freenode.#weechat * toto\\t\n"
" keep only nick \"titi\" on IRC channel #test:\n"
" /filter add titi irc.freenode.#test * !titi\\t\n"
" filter lines containing word \"spam\":\n"
" /filter add filterspam * * spam\n"
" filter lines containing \"weechat sucks\" on IRC channel #weechat:\n"
+9 -3
View File
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.3-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-07-11 12:14+0200\n"
"POT-Creation-Date: 2010-07-16 15:42+0200\n"
"PO-Revision-Date: 2010-06-20 21:25+0200\n"
"Last-Translator: B.J. Stobiecki <bartek@stobiecki.eu>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1052,6 +1052,7 @@ msgstr ""
"[list] | [enable|disable|toggle [nazwa]] | [add nazwa wtyczka.bufor tagi "
"regex] | [del nazwa|-all]"
#, fuzzy
msgid ""
" list: list all filters\n"
" enable: enable filters (filters are enabled by default)\n"
@@ -1065,8 +1066,11 @@ msgid ""
"buffers)\n"
" tags: comma separated list of tags, for example: \"irc_join,"
"irc_part,irc_quit\"\n"
" regex: regular expression to search in line (use \\t to separate "
"prefix from message, special chars like '|' must be escaped: '\\|')\n"
" regex: regular expression to search in line\n"
" - use '\\t' to separate prefix from message, special chars "
"like '|' must be escaped: '\\|'\n"
" - if regex starts with '!', then matching result is reversed "
"(use '\\!' to start with '!')\n"
"\n"
"The default key alt+'=' toggles filtering on/off.\n"
"\n"
@@ -1086,6 +1090,8 @@ msgid ""
" /filter add nicks * irc_366 *\n"
" filter nick \"toto\" on IRC channel #weechat:\n"
" /filter add toto irc.freenode.#weechat * toto\\t\n"
" keep only nick \"titi\" on IRC channel #test:\n"
" /filter add titi irc.freenode.#test * !titi\\t\n"
" filter lines containing word \"spam\":\n"
" /filter add filterspam * * spam\n"
" filter lines containing \"weechat sucks\" on IRC channel #weechat:\n"
+8 -3
View File
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.3-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-07-11 12:14+0200\n"
"POT-Creation-Date: 2010-07-16 15:42+0200\n"
"PO-Revision-Date: 2010-06-20 21:25+0200\n"
"Last-Translator: Pavel Shevchuk <stlwrt@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1038,8 +1038,11 @@ msgid ""
"buffers)\n"
" tags: comma separated list of tags, for example: \"irc_join,"
"irc_part,irc_quit\"\n"
" regex: regular expression to search in line (use \\t to separate "
"prefix from message, special chars like '|' must be escaped: '\\|')\n"
" regex: regular expression to search in line\n"
" - use '\\t' to separate prefix from message, special chars "
"like '|' must be escaped: '\\|'\n"
" - if regex starts with '!', then matching result is reversed "
"(use '\\!' to start with '!')\n"
"\n"
"The default key alt+'=' toggles filtering on/off.\n"
"\n"
@@ -1059,6 +1062,8 @@ msgid ""
" /filter add nicks * irc_366 *\n"
" filter nick \"toto\" on IRC channel #weechat:\n"
" /filter add toto irc.freenode.#weechat * toto\\t\n"
" keep only nick \"titi\" on IRC channel #test:\n"
" /filter add titi irc.freenode.#test * !titi\\t\n"
" filter lines containing word \"spam\":\n"
" /filter add filterspam * * spam\n"
" filter lines containing \"weechat sucks\" on IRC channel #weechat:\n"
+8 -3
View File
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-07-11 12:14+0200\n"
"POT-Creation-Date: 2010-07-16 15:42+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -888,8 +888,11 @@ msgid ""
"buffers)\n"
" tags: comma separated list of tags, for example: \"irc_join,"
"irc_part,irc_quit\"\n"
" regex: regular expression to search in line (use \\t to separate "
"prefix from message, special chars like '|' must be escaped: '\\|')\n"
" regex: regular expression to search in line\n"
" - use '\\t' to separate prefix from message, special chars "
"like '|' must be escaped: '\\|'\n"
" - if regex starts with '!', then matching result is reversed "
"(use '\\!' to start with '!')\n"
"\n"
"The default key alt+'=' toggles filtering on/off.\n"
"\n"
@@ -909,6 +912,8 @@ msgid ""
" /filter add nicks * irc_366 *\n"
" filter nick \"toto\" on IRC channel #weechat:\n"
" /filter add toto irc.freenode.#weechat * toto\\t\n"
" keep only nick \"titi\" on IRC channel #test:\n"
" /filter add titi irc.freenode.#test * !titi\\t\n"
" filter lines containing word \"spam\":\n"
" /filter add filterspam * * spam\n"
" filter lines containing \"weechat sucks\" on IRC channel #weechat:\n"
+8 -4
View File
@@ -1239,7 +1239,7 @@ command_filter (void *data, struct t_gui_buffer *buffer,
{
if (argc > 2)
{
/* enable a filter */
/* disable a filter */
ptr_filter = gui_filter_search_by_name (argv[2]);
if (ptr_filter)
{
@@ -4605,9 +4605,11 @@ command_init ()
"(\"*\" for all buffers)\n"
" tags: comma separated list of tags, for "
"example: \"irc_join,irc_part,irc_quit\"\n"
" regex: regular expression to search in "
"line (use \\t to separate prefix from message, special "
"chars like '|' must be escaped: '\\|')\n\n"
" regex: regular expression to search in line\n"
" - use '\\t' to separate prefix from message, special "
"chars like '|' must be escaped: '\\|'\n"
" - if regex starts with '!', then matching "
"result is reversed (use '\\!' to start with '!')\n\n"
"The default key alt+'=' toggles filtering on/off.\n\n"
"Tags most commonly used:\n"
" no_filter, no_highlight, log0..log9 (log level),\n"
@@ -4624,6 +4626,8 @@ command_init ()
" /filter add nicks * irc_366 *\n"
" filter nick \"toto\" on IRC channel #weechat:\n"
" /filter add toto irc.freenode.#weechat * toto\\t\n"
" keep only nick \"titi\" on IRC channel #test:\n"
" /filter add titi irc.freenode.#test * !titi\\t\n"
" filter lines containing word \"spam\":\n"
" /filter add filterspam * * spam\n"
" filter lines containing \"weechat sucks\" on IRC "
+23 -8
View File
@@ -76,6 +76,7 @@ gui_filter_check_line (struct t_gui_buffer *buffer, struct t_gui_line *line)
{
struct t_gui_filter *ptr_filter;
const char *buffer_plugin_name;
int rc;
/* line is always displayed if filters are disabled */
if (!gui_filters_enabled)
@@ -103,12 +104,18 @@ gui_filter_check_line (struct t_gui_buffer *buffer, struct t_gui_line *line)
ptr_filter->tags_array)))
{
/* check line with regex */
rc = 1;
if (!ptr_filter->regex_prefix && !ptr_filter->regex_message)
return 0;
rc = 0;
if (gui_line_match_regex (line,
ptr_filter->regex_prefix,
ptr_filter->regex_message))
{
rc = 0;
}
if (ptr_filter->regex && (ptr_filter->regex[0] == '!'))
rc ^= 1;
if (rc == 0)
return 0;
}
}
@@ -291,28 +298,36 @@ gui_filter_new (int enabled, const char *name, const char *buffer_name,
struct t_gui_filter *new_filter;
regex_t *regex1, *regex2;
char *pos_tab, *pos_point, *regex_prefix;
const char *pos_regex_message;
const char *ptr_start_regex, *pos_regex_message;
if (!name || !buffer_name || !tags || !regex)
return NULL;
if (gui_filter_search_by_name (name))
return NULL;
ptr_start_regex = regex;
if ((ptr_start_regex[0] == '!')
|| ((ptr_start_regex[0] == '\\') && (ptr_start_regex[1] == '!')))
{
ptr_start_regex++;
}
regex1 = NULL;
regex2 = NULL;
if (strcmp (regex, "*") != 0)
if (strcmp (ptr_start_regex, "*") != 0)
{
pos_tab = strstr (regex, "\\t");
pos_tab = strstr (ptr_start_regex, "\\t");
if (pos_tab)
{
regex_prefix = string_strndup (regex, pos_tab - regex);
regex_prefix = string_strndup (ptr_start_regex,
pos_tab - ptr_start_regex);
pos_regex_message = pos_tab + 2;
}
else
{
regex_prefix = NULL;
pos_regex_message = regex;
pos_regex_message = ptr_start_regex;
}
if (regex_prefix)