| 1 |
/* |
| 2 |
* Copyright 2008-2011 Various Authors |
| 3 |
* Copyright 2005 Timo Hirvonen |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU General Public License as |
| 7 |
* published by the Free Software Foundation; either version 2 of the |
| 8 |
* License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, but |
| 11 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program; if not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
|
| 19 |
#ifndef FILTERS_H |
| 20 |
#define FILTERS_H |
| 21 |
|
| 22 |
#include "list.h" |
| 23 |
#include "window.h" |
| 24 |
#include "search.h" |
| 25 |
|
| 26 |
/* factivate foo !bar |
| 27 |
* |
| 28 |
* foo: FS_YES |
| 29 |
* bar: FS_NO |
| 30 |
* baz: FS_IGNORE |
| 31 |
*/ |
| 32 |
enum { |
| 33 |
/* [ ] filter not selected */ |
| 34 |
FS_IGNORE, |
| 35 |
/* [*] filter selected */ |
| 36 |
FS_YES, |
| 37 |
/* [!] filter selected and inverted */ |
| 38 |
FS_NO, |
| 39 |
}; |
| 40 |
|
| 41 |
struct filter_entry { |
| 42 |
struct list_head node; |
| 43 |
|
| 44 |
char *name; |
| 45 |
char *filter; |
| 46 |
unsigned visited : 1; |
| 47 |
|
| 48 |
/* selected and activated status (FS_* enum) */ |
| 49 |
unsigned sel_stat : 2; |
| 50 |
unsigned act_stat : 2; |
| 51 |
}; |
| 52 |
|
| 53 |
static inline struct filter_entry *iter_to_filter_entry(struct iter *iter) |
| 54 |
{ |
| 55 |
return iter->data1; |
| 56 |
} |
| 57 |
|
| 58 |
extern struct window *filters_win; |
| 59 |
extern struct searchable *filters_searchable; |
| 60 |
extern struct list_head filters_head; |
| 61 |
|
| 62 |
void filters_init(void); |
| 63 |
void filters_exit(void); |
| 64 |
|
| 65 |
/* parse filter and expand sub filters */ |
| 66 |
struct expr *parse_filter(const char *val); |
| 67 |
|
| 68 |
/* add filter to filter list (replaces old filter with same name) |
| 69 |
* |
| 70 |
* @keyval "name=value" where value is filter |
| 71 |
*/ |
| 72 |
void filters_set_filter(const char *keyval); |
| 73 |
|
| 74 |
/* set throwaway filter (not saved to the filter list) |
| 75 |
* |
| 76 |
* @val filter or NULL to disable filtering |
| 77 |
*/ |
| 78 |
void filters_set_anonymous(const char *val); |
| 79 |
|
| 80 |
/* set live filter (not saved to the filter list) |
| 81 |
* |
| 82 |
* @val filter or NULL to disable filtering |
| 83 |
*/ |
| 84 |
void filters_set_live(const char *val); |
| 85 |
|
| 86 |
void filters_activate_names(const char *str); |
| 87 |
|
| 88 |
void filters_activate(void); |
| 89 |
void filters_toggle_filter(void); |
| 90 |
void filters_delete_filter(void); |
| 91 |
|
| 92 |
#endif |