From 1878b7c4b053f6f2600d3edd84227d7e505f9e37 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Wed, 6 Aug 2014 10:14:03 +0200 Subject: Allow for filtering TODO items The item filters now apply to both appointments and TODO items. Also, add a new type mask "todo" and the following new filter options: * --filter-priority * --filter-completed * --filter-uncompleted Signed-off-by: Lukas Fleischer --- src/io.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/io.c') diff --git a/src/io.c b/src/io.c index a6c29ac..4733802 100644 --- a/src/io.c +++ b/src/io.c @@ -644,7 +644,7 @@ void io_load_app(struct item_filter *filter) } /* Load the todo data */ -void io_load_todo(void) +void io_load_todo(struct item_filter *filter) { FILE *data_file; char *newline; @@ -687,6 +687,22 @@ void io_load_todo(void) if (newline) *newline = '\0'; io_extract_data(e_todo, buf, sizeof buf); + + /* Filter item. */ + if (filter) { + if (!(filter->type_mask & TYPE_MASK_TODO)) + continue; + if (filter->regex && + regexec(filter->regex, e_todo, 0, 0, 0)) + continue; + if (filter->priority && id != filter->priority) + continue; + if (filter->completed && id > 0) + continue; + if (filter->uncompleted && id < 0) + continue; + } + todo_add(e_todo, id, note); ++nb_tod; } -- cgit v1.2.3-54-g00ecf