X-Git-Url: http://pileus.org/git/?p=lackey;a=blobdiff_plain;f=view%2Fmonth.c;h=2179f4f2c178f9e611d6a696375eb7311eb70ea5;hp=60f6b601c4c01347a296175e6bc65d112f0f4e5d;hb=19a02d772c5753208c667b37a57527796ac6dc75;hpb=aa360e05a1ab85e49adad6fa38c02850cd75dfe4 diff --git a/view/month.c b/view/month.c index 60f6b60..2179f4f 100644 --- a/view/month.c +++ b/view/month.c @@ -20,8 +20,10 @@ #include #include -#include "main.h" #include "util.h" +#include "date.h" +#include "event.h" +#include "screen.h" /* Static data */ static WINDOW *win; @@ -32,6 +34,11 @@ void month_init(WINDOW *_win) win = _win; } +/* Month size */ +void month_size(int rows, int cols) +{ +} + /* Month draw */ void month_draw(void) { @@ -43,9 +50,6 @@ void month_draw(void) const float hstep = (float)(COLS-1)/7.0; const float vstep = (float)(LINES-6)/weeks; - /* Clear */ - werase(win); - /* Print Header */ mvwprintw(win, 0, midpt, "%s %d", name, YEAR); for (int d = 0; d < 7; d++) { @@ -63,6 +67,23 @@ void month_draw(void) if (d == DAY) wattroff(win, A_BOLD); } + /* Print events */ + event_t *event = EVENTS; + for (int d = 0; d < days; d++) { + int y = ROUND(4+(((start + d) / 7) )*vstep); + int e = ROUND(4+(((start + d) / 7)+1)*vstep)-2; + int x = ROUND(1+(((start + d) % 7) )*hstep)+3; + int w = ROUND(1+(((start + d) % 7)+1)*hstep)-x-1; + while (event && before(&event->start, YEAR, MONTH, d, 24, 0)) { + if (!before(&event->start, YEAR, MONTH, d, 0, 0)){ + if (y == e) mvwhline(win, y, x-3, ACS_DARROW, 2); + if (y <= e) event_line(win, event, y, x, w); + y++; + } + event = event->next; + } + } + /* Print lines */ for (int w = 1; w < weeks; w++) mvwhline(win, ROUND(3+w*vstep), 1, ACS_HLINE, COLS-2); @@ -70,7 +91,7 @@ void month_draw(void) int top = d >= start ? 0 : 1; int bot = d <= (start+days-1)%7+1 ? weeks : weeks-1; mvwvline(win, ROUND(4+top*vstep), ROUND(d*hstep), - ACS_VLINE, (bot-top)*vstep-1); + ACS_VLINE, (bot-top)*vstep); for (int w = 1; w < weeks; w++) { int chr = w == top ? ACS_TTEE : w == bot ? ACS_BTEE : ACS_PLUS; @@ -111,6 +132,7 @@ int month_run(int key, mmask_t btn, int row, int col) if (days || months) { add_days(&YEAR, &MONTH, &DAY, days); add_months(&YEAR, &MONTH, months); + werase(win); month_draw(); wrefresh(win); }