aboutsummaryrefslogtreecommitdiffstats
path: root/src/todo.c
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2016-01-17 20:04:25 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2016-01-18 18:04:18 +0100
commit1a4bf2b0a2a54393c401522611f85c2637d1de88 (patch)
treeba67832cbddbe7fd3a45a7797b369e8dd5d357aa /src/todo.c
parent2857bac97163ea43bf087e6350d44016fe1764b6 (diff)
downloadcalcurse-1a4bf2b0a2a54393c401522611f85c2637d1de88.tar.gz
calcurse-1a4bf2b0a2a54393c401522611f85c2637d1de88.zip
Add a "hide completed" view to the todo panel
Add a second view to the todo panel that hides all completed items. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src/todo.c')
-rw-r--r--src/todo.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/todo.c b/src/todo.c
index 9869a1e..707628c 100644
--- a/src/todo.c
+++ b/src/todo.c
@@ -43,10 +43,23 @@
llist_t todolist;
+static int todo_is_uncompleted(struct todo *todo, void *cbdata)
+{
+ return todo->id >= 0;
+}
+
/* Returns a structure containing the selected item. */
-struct todo *todo_get_item(int item_number)
+struct todo *todo_get_item(int item_number, int skip_completed)
{
- return LLIST_GET_DATA(LLIST_NTH(&todolist, item_number));
+ llist_item_t *i;
+
+ if (skip_completed)
+ i = LLIST_FIND_NTH(&todolist, item_number, NULL,
+ todo_is_uncompleted);
+ else
+ i = LLIST_NTH(&todolist, item_number);
+
+ return LLIST_GET_DATA(i);
}
static int todo_cmp_id(struct todo *a, struct todo *b)