Filter option: invert

New filter option: --filter-invert. When present it inverts (negates)
the other filter options combined. This is mostly useful with the -G
option (with -Q the output is limited by the query range (day range)).

The ouput from "calcurse -G <filter options>" is the (set) complement of
"calcurse -G <filter options> --filter-invert". Here <filter options>
may be any combination of filter options.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lars Henriksen
2018-12-06 09:56:45 +01:00
committed by Lukas Fleischer
parent 9300e9154c
commit 42abbf5346
6 changed files with 133 additions and 126 deletions

View File

@@ -54,7 +54,8 @@ enum {
/* Long options */
enum {
OPT_FILTER_TYPE = 1000,
OPT_FILTER_INVERT = 1000,
OPT_FILTER_TYPE,
OPT_FILTER_HASH,
OPT_FILTER_PATTERN,
OPT_FILTER_START_FROM,
@@ -410,7 +411,7 @@ int parse_args(int argc, char **argv)
int range = 0;
int limit = INT_MAX;
/* Filters */
struct item_filter filter = { 0, NULL, NULL, -1, -1, -1, -1, 0, 0, 0 };
struct item_filter filter = { 0, 0, NULL, NULL, -1, -1, -1, -1, 0, 0, 0 };
/* Format strings */
const char *fmt_apt = NULL;
const char *fmt_rapt = NULL;
@@ -457,6 +458,7 @@ int parse_args(int argc, char **argv)
{"quiet", no_argument, NULL, 'q'},
{"query", optional_argument, NULL, 'Q'},
{"filter-invert", no_argument, NULL, OPT_FILTER_INVERT},
{"filter-type", required_argument, NULL, OPT_FILTER_TYPE},
{"filter-hash", required_argument, NULL, OPT_FILTER_HASH},
{"filter-pattern", required_argument, NULL, OPT_FILTER_PATTERN},
@@ -623,6 +625,10 @@ int parse_args(int argc, char **argv)
case 'Q':
query = 1;
break;
case OPT_FILTER_INVERT:
filter.invert = !filter.invert;
filter_opt = 1;
break;
case OPT_FILTER_TYPE:
filter.type_mask = parse_type_mask(optarg);
EXIT_IF(filter.type_mask == 0,