]> Pileus Git - lackey/blobdiff - src/main.c
Add day and week view
[lackey] / src / main.c
index 5de195da34a006558770a10cc66a8d9be5e22b41..146e55e3fcd3bb7c356bab5c0ddd34817d74c39e 100644 (file)
@@ -14,7 +14,6 @@ static FILE *debug_fd = NULL;
 static void on_sigint(int signum)
 {
        endwin();
-       debug("got sigint\n");
        exit(0);
 }
 
@@ -23,6 +22,7 @@ static void on_sigwinch(int signum)
 {
        endwin();
        refresh();
+       screen_resize();
        screen_draw();
 }
 
@@ -32,6 +32,10 @@ int debug(char *fmt, ...)
        int rval;
        va_list ap;
 
+       /* Open log file */
+       if (!debug_fd)
+               debug_fd = fopen("acal.log", "w+");
+
        /* Log to debug file */
        va_start(ap, fmt);
        vfprintf(debug_fd, "debug: ", ap);
@@ -54,16 +58,13 @@ int debug(char *fmt, ...)
 int main(int argc, char **argv)
 {
        /* Misc setup */
-       debug_fd = fopen("acal.log", "w+");
        struct sigaction act;
        sigemptyset(&act.sa_mask);
        act.sa_flags   = 0;
        act.sa_handler = on_sigint;
-       if (sigaction(SIGINT, &act, NULL) < 0)
-               debug("sigint error\n");
+       sigaction(SIGINT, &act, NULL);
        act.sa_handler = on_sigwinch;
-       if (sigaction(SIGWINCH, &act, NULL) < 0)
-               debug("sigwinch error\n");
+       sigaction(SIGWINCH, &act, NULL);
 
        /* Curses setup */
        initscr();
@@ -76,6 +77,7 @@ int main(int argc, char **argv)
        init_pair(COLOR_TITLE, COLOR_GREEN, COLOR_BLACK);
        init_pair(COLOR_ERROR, COLOR_RED,   COLOR_BLACK);
        screen_init();
+       screen_draw();
 
        /* Run */
        while (1) {
@@ -103,6 +105,5 @@ int main(int argc, char **argv)
 
        /* Cleanup, see also on_sigint */
        endwin();
-       debug("cleanup");
        return 0;
 }