2 * Copyright (C) 2013 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/>.
30 /* Helper functions */
31 static const char *timestr(date_t date)
35 sprintf(buf, "%04d-%02d-%02d %02d:%02d",
36 date.year, date.month+1, date.day+1,
39 sprintf(buf, "[none]");
44 static void draw_event(event_t *event)
47 wprintw(win, "Edit Event\n");
48 wprintw(win, " Name: %s\n", event->name ?: "[none]");
49 wprintw(win, " Description: %s\n", event->desc ?: "[none]");
50 wprintw(win, " Location: %s\n", event->loc ?: "[none]");
51 wprintw(win, " Category: %s\n", event->cat ?: "[none]");
52 wprintw(win, " Start Time: %s\n", timestr(event->start));
53 wprintw(win, " End Time: %s\n", timestr(event->end));
54 wprintw(win, " Calendar: %s\n", event->cal->name ?: "[none]");
57 static int edit_event(event_t *event, int key, mmask_t btn, int row, int col)
63 static void draw_todo(todo_t *todo)
66 wprintw(win, "Edit Todo\n");
67 wprintw(win, " Name: %s\n", todo->name ?: "[none]");
68 wprintw(win, " Description: %s\n", todo->desc ?: "[none]");
69 wprintw(win, " Category: %s\n", todo->cat ?: "[none]");
70 wprintw(win, " Completed: %d%%\n", todo->status);
71 wprintw(win, " Start Time: %s\n", timestr(todo->start));
72 wprintw(win, " Due Date: %s\n", timestr(todo->due));
73 wprintw(win, " Calendar: %s\n", todo->cal->name ?: "[none]");
76 static int edit_todo(todo_t *todo, int key, mmask_t btn, int row, int col)
82 void edit_init(WINDOW *_win)
88 void edit_size(int rows, int cols)
97 case EDIT_EVENT: draw_event(EVENT); break;
98 case EDIT_TODO: draw_todo(TODO); break;
104 int edit_run(int key, mmask_t btn, int row, int col)
107 case EDIT_CAL: return 1;
108 case EDIT_EVENT: return edit_event(EVENT, key, btn, row, col);
109 case EDIT_TODO: return edit_todo(TODO, key, btn, row, col);