diff options
Diffstat (limited to 'src/todo.c')
-rw-r--r-- | src/todo.c | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -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) |