diff options
author | Lukas Fleischer <lfleischer@calcurse.org> | 2016-01-17 22:46:24 +0100 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2016-01-18 18:08:34 +0100 |
commit | beea88e5feb6f14b4912c6aa4878c39a7632977c (patch) | |
tree | 6559c7090a687a4b96319b9bc1539050f913f27a /src/ui-todo.c | |
parent | 1a4bf2b0a2a54393c401522611f85c2637d1de88 (diff) | |
download | calcurse-beea88e5feb6f14b4912c6aa4878c39a7632977c.zip |
Use a separate field for the completed status
Add a new field that indicates whether a todo item is completed or not
instead of encoding completed todo items by negative priorities.
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src/ui-todo.c')
-rw-r--r-- | src/ui-todo.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/ui-todo.c b/src/ui-todo.c index 86592c1..2a03844 100644 --- a/src/ui-todo.c +++ b/src/ui-todo.c @@ -60,7 +60,7 @@ void ui_todo_add(void) status_mesg(mesg_id, ""); ch = wgetch(win[KEY].p); } - todo_add(todo_input, ch - '0', NULL); + todo_add(todo_input, ch - '0', 0, NULL); ui_todo_load_items(); io_set_modified(); } @@ -163,14 +163,14 @@ void ui_todo_draw(int n, WINDOW *win, int y, int hilt, void *cb_data) int j; if (ui_todo_view == TODO_HIDE_COMPLETED_VIEW) { - while (i && todo->id < 0) { + while (i && todo->completed) { i = i->next; if (i) todo = LLIST_TS_GET_DATA(i); } } - mark[0] = todo->id > 0 ? '0' + todo->id : 'X'; + mark[0] = todo->completed ? 'X' : '0' + todo->id; mark[1] = todo->note ? '>' : '.'; hilt = hilt && (wins_slctd() == TOD); @@ -217,7 +217,8 @@ void ui_todo_load_items(void) /* TODO: Optimize this by keeping the list size in a variable. */ LLIST_FOREACH(&todolist, i) { struct todo *todo = LLIST_TS_GET_DATA(i); - if (ui_todo_view == TODO_HIDE_COMPLETED_VIEW && todo->id < 0) + if (ui_todo_view == TODO_HIDE_COMPLETED_VIEW && + todo->completed) continue; n++; } @@ -263,7 +264,7 @@ void ui_todo_chg_priority(int diff) else if (id > 9) id = 9; - item_new = todo_add(item->mesg, id, item->note); + item_new = todo_add(item->mesg, id, item->completed, item->note); todo_delete(item); io_set_modified(); listbox_set_sel(&lb_todo, todo_get_position(item_new)); |