X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=views%2Fevents.c;h=ced1a3fc3e3bb577333ed17a594a8810a2b8a17c;hb=296fd1bb5f87b1961e98c7ea4c224219012f7161;hp=1a8f8b9d777ee3aad4f9e80f09dac75fddfe6f56;hpb=9d6df8f874cef59df16086c71031db2ba0267d3a;p=lackey diff --git a/views/events.c b/views/events.c index 1a8f8b9..ced1a3f 100644 --- a/views/events.c +++ b/views/events.c @@ -1,28 +1,26 @@ /* - * Copyright (C) 2012 Andy Spencer - * + * Copyright (C) 2012-2013 Andy Spencer + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#define DEBUG - #include -#include -#include -#include -#include +#include "util.h" +#include "date.h" +#include "cal.h" +#include "view.h" /* Static data */ static WINDOW *win; @@ -46,10 +44,11 @@ void events_draw(void) int days = 2*7; int min = 12; - date_t start = {YEAR, MONTH, DAY, 0, 0}; - date_t cur = {YEAR, MONTH, DAY-1, 0, 0}; - date_t end = {YEAR, MONTH, DAY, 24, 0}; + date_t start = {SEL.year, SEL.month, SEL.day, 0, 0}; + date_t cur = {SEL.year, SEL.month, SEL.day-1, 0, 0}; + date_t end = {SEL.year, SEL.month, SEL.day, 24, 0}; add_days(&end.year, &end.month, &end.day, days); + cal_load(SEL.year, SEL.month, SEL.day, days); int row = 0; int count = 0; @@ -68,17 +67,17 @@ void events_draw(void) row++; if (newdate) { wday_t wday = day_of_week(next.year, next.month, next.day); - wattron(win, A_UNDERLINE); + wattron(win, A_BOLD); mvwprintw(win, row-line, 0, "%04d-%02d-%02d", next.year, next.month+1, next.day+1); mvwprintw(win, row-line, 13, "%s, %s %d", day_to_string(wday), month_to_string(next.month), next.day); - wattroff(win, A_UNDERLINE); + wattroff(win, A_BOLD); row++; } - event_line(win, event, row++-line, 3, COLS-2, 1); + event_line(win, event, row++-line, 4, COLS-4, SHOW_DETAILS); if (event->name && event->desc) - mvwprintw(win, row++-line, 13, "%s", event->desc); + mvwprintw(win, row++-line, 14, "%s", event->desc); cur = next; count += 1; } @@ -108,5 +107,5 @@ int events_run(int key, mmask_t btn, int row, int col) events_draw(); wrefresh(win); } - return 0; + return scroll; }