2 * Copyright (C) 2012 Andy Spencer <andy753421@gmail.com>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 static int show_new = 1;
29 static int show_started = 1;
30 static int show_finished = 1;
32 /* Helper functions */
33 static int print_todos(WINDOW *win, int y, todo_t *todos, status_t low, status_t high)
36 for (todo_t *cur = todos; cur; cur = cur->next)
37 if (low <= cur->status && cur->status <= high)
38 todo_line(win, cur, y+n++, 2, COLS-2, 1);
42 static int print_group(WINDOW *win, int y, todo_t *todos,
43 int show, const char *label, status_t low, status_t high)
48 mvwprintw(win, y, 0, "%s", label);
52 n = print_todos(win, y+1, todos, low, high);
56 mvwprintw(win, y+1, 4, "[hidden]");
58 mvwprintw(win, y+1, 4, "[no tasks]");
60 return y+1+MAX(n,1)+1;
64 void todo_init(WINDOW *_win)
70 void todo_size(int rows, int cols)
79 y = print_group(win, y, TODOS,
80 show_new, "New Tasks", NEW, NEW);
82 y = print_group(win, y, TODOS,
83 show_started, "Started Tasks", NEW+1, DONE-1);
85 y = print_group(win, y, TODOS,
86 show_finished, "Finished Tasks", DONE, DONE);
90 int todo_run(int key, mmask_t btn, int row, int col)
95 case 'n': ref = 1; show_new ^= 1; break;
96 case 's': ref = 1; show_started ^= 1; break;
97 case 'f': ref = 1; show_finished ^= 1; break;