diff options
author | Lukas Fleischer <calcurse@cryptocrack.de> | 2014-08-06 08:53:51 +0200 |
---|---|---|
committer | Lukas Fleischer <calcurse@cryptocrack.de> | 2014-08-06 12:08:14 +0200 |
commit | bfe73d0e5d66c43006a8a0dd8d58e311432bcb57 (patch) | |
tree | 584c1f12effddb2501566a872f7787be65124b89 /src/event.c | |
parent | 4ec7fe123925144506297df5eba4ed41c6f8331d (diff) | |
download | calcurse-bfe73d0e5d66c43006a8a0dd8d58e311432bcb57.zip |
Add item filters
This adds the following filter options that allow for restricting the
set of items that are read from the appointments file:
* --filter-type
* --filter-start-from
* --filter-start-to
* --filter-start-after
* --filter-start-before
* --filter-end-from
* --filter-end-to
* --filter-end-after
* --filter-end-before
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/event.c')
-rw-r--r-- | src/event.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/event.c b/src/event.c index 38305b8..96ac41d 100644 --- a/src/event.c +++ b/src/event.c @@ -120,7 +120,8 @@ void event_write(struct event *o, FILE * f) } /* Load the events from file */ -struct event *event_scan(FILE * f, struct tm start, int id, char *note) +struct event *event_scan(FILE * f, struct tm start, int id, char *note, + struct item_filter *filter) { char buf[BUFSIZ], *nl; time_t tstart; @@ -147,6 +148,16 @@ struct event *event_scan(FILE * f, struct tm start, int id, char *note) tstart = mktime(&start); EXIT_IF(tstart == -1, _("date error in the event\n")); + /* Filter item. */ + if (filter) { + if (!(filter->type_mask & TYPE_MASK_EVNT)) + return NULL; + if (filter->start_from >= 0 && tstart < filter->start_from) + return NULL; + if (filter->start_to >= 0 && tstart > filter->start_to) + return NULL; + } + return event_new(buf, note, tstart, id); } |