From 7984b05d3168c63451d25024c22bd598cb111ed8 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Sun, 14 Oct 2012 06:47:56 +0000 Subject: [PATCH] Add events to year view --- view/year.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/view/year.c b/view/year.c index ba2eaad..17a5c92 100644 --- a/view/year.c +++ b/view/year.c @@ -20,6 +20,8 @@ #include "util.h" #include "date.h" +#include "event.h" +#include "screen.h" /* Constants */ #define MW (2*7+6) @@ -30,6 +32,7 @@ static WINDOW *win; /* Helper functions */ static void print_month(month_t month, int y, int x) { + event_t *event = EVENTS; const char *name = month_to_string(month); const int start = start_of_month(YEAR, month); const char days = days_in_month(YEAR, month); @@ -40,9 +43,22 @@ static void print_month(month_t month, int y, int x) for (int d = 0; d < days; d++) { int row = (start + d) / 7; int col = (start + d) % 7; - if (month == MONTH && d == DAY) wattron(win, A_REVERSE); + + int busy = 0; + while (event && before(&event->start, YEAR, month, d, 24, 0)) { + if (!before(&event->start, YEAR, month, d, 0, 0)) + busy = 1; + event = event->next; + } + + int today = month == MONTH && d == DAY; + + int attr = (busy ? A_BOLD|A_UNDERLINE : A_DIM) + | (today ? A_REVERSE : 0 ); + + wattron(win, attr); mvwprintw(win, y+2+row, x+col*3, "%2d", d+1); - if (month == MONTH && d == DAY) wattroff(win, A_REVERSE); + wattroff(win, attr); } } -- 2.43.2