+void todo_line(WINDOW *win, todo_t *todo, int y, int x, int w, int flags)
+{
+ char perc[16];
+ char desc[LINES];
+ sprintf(perc, "%2d%%", todo->status);
+
+ int cat = get_color(todo->cat);
+ int status = todo->status == NEW ? COLOR_NEW :
+ todo->status == DONE ? COLOR_DONE : COLOR_WIP;
+
+ sprintf(desc, "%s", todo->name ?: todo->desc ?: "");
+ strsub(desc, '\n', ';');
+
+ /* Print category */
+ if (cat) wattron(win, COLOR_PAIR(cat));
+ mvwaddch(win, y, x, ACS_BLOCK);
+ if (cat) wattroff(win, COLOR_PAIR(cat));
+ x += 2;
+
+ /* Set background */
+ if (flags & SHOW_ACTIVE && todo == TODO)
+ wattron(win, A_REVERSE | A_BOLD);
+ mvwhline(win, y, x, ' ', COLS-x);
+
+ /* Print time */
+ if (no_date(&todo->due))
+ mvwprintw(win, y, x, "[no due date]");
+ else
+ mvwprintw(win, y, x, "%04d-%02d-%02d %2d:%02d",
+ todo->due.year, todo->due.month+1, todo->due.day+1,
+ todo->due.hour, todo->due.min);
+ x += 18;
+
+ /* Print status */
+ if (status) wattron(win, COLOR_PAIR(status));
+ mvwprintw(win, y, x, "%s",
+ todo->status == NEW ? "new" :
+ todo->status == DONE ? "done" : perc);
+ if (status) wattroff(win, COLOR_PAIR(status));
+ x += 6;
+
+ /* Print description */
+ mvwprintw(win, y, x, "%s", desc);
+
+ /* Reset flags */
+ if (flags & SHOW_ACTIVE && todo == TODO)
+ wattroff(win, A_REVERSE | A_BOLD);
+}