]> Pileus Git - lackey/blobdiff - view/day.c
Add full boxes
[lackey] / view / day.c
index ed5ee6f1848778b0a7d17f7d22fdedb98db28cca..37f9e2f4b6d7d289f6144dec9ad2578e5bb922ea 100644 (file)
@@ -1,8 +1,23 @@
-#include <string.h>
+/*
+ * Copyright (C) 2012 Andy Spencer <andy753421@gmail.com>
+ * 
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
 #include <ncurses.h>
 
-#include "main.h"
-#include "util.h"
+#include "date.h"
 
 /* Static data */
 static WINDOW *win;
@@ -13,15 +28,23 @@ void day_init(WINDOW *_win)
        win = _win;
 }
 
+/* Day size */
+void day_size(int rows, int cols)
+{
+}
+
 /* Day draw */
 void day_draw(void)
 {
        const char *mstr = month_to_string(MONTH);
        const char *dstr = day_to_string(day_of_week(YEAR, MONTH, DAY));
 
+       /* Clear */
+       werase(win);
+
        /* Print Header */
-       mvwprintw(win, 0, 0, "%s, %s %d", dstr, mstr, DAY);
-       mvwprintw(win, 0, COLS-10, "%d-%02d-%02d", YEAR, MONTH, DAY);
+       mvwprintw(win, 0, 0, "%s, %s %d", dstr, mstr, DAY+1);
+       mvwprintw(win, 0, COLS-10, "%d-%02d-%02d", YEAR, MONTH, DAY+1);
        mvwhline(win, 1, 0, ACS_HLINE, COLS);
 
        /* Print times */
@@ -34,5 +57,18 @@ void day_draw(void)
 /* Day run */
 int day_run(int key, mmask_t btn, int row, int col)
 {
+       int days = 0;
+       switch (key)
+       {
+               case 'h': days = -1; break;
+               case 'l': days =  1; break;
+               case 'i': days = -7; break;
+               case 'o': days =  7; break;
+       }
+       if (days) {
+               add_days(&YEAR, &MONTH, &DAY, days);
+               day_draw();
+               wrefresh(win);
+       }
        return 0;
 }