aboutsummaryrefslogtreecommitdiffstats
path: root/src/io.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2014-08-06 10:14:03 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2014-08-06 12:08:14 +0200
commit1878b7c4b053f6f2600d3edd84227d7e505f9e37 (patch)
treecbb928e0017f91f1d211ebd531a467be766b1267 /src/io.c
parent86553f35feea67f0ac70018ccfde1903106b4c4d (diff)
downloadcalcurse-1878b7c4b053f6f2600d3edd84227d7e505f9e37.tar.gz
calcurse-1878b7c4b053f6f2600d3edd84227d7e505f9e37.zip
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 <calcurse@cryptocrack.de>
Diffstat (limited to 'src/io.c')
-rw-r--r--src/io.c18
1 files changed, 17 insertions, 1 deletions
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;
}