]> Pileus Git - lackey/blobdiff - src/util.c
Move main loop and curses init to view
[lackey] / src / util.c
index 37b004d94896899b95312fdc3abc387fe5d725b6..1ebecfc02dae764fead047a08765eecbc4c0e3ca 100644 (file)
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdarg.h>
 #include <string.h>
-#include <ncurses.h>
 
 #include "date.h"
 #include "cal.h"
 #include "view.h"
 #include "util.h"
 
-/* For testing */
-#pragma weak COMPACT
+#pragma weak view_debug
 
 /* Static data */
 static FILE *debug_fd = NULL;
 
+/* View debugging */
+extern void view_debug(const char *fmt, va_list ap);
+
 /* Helper functions */
 static void message(FILE *output_fd, const char *prefix, const char *fmt, va_list ap)
 {
@@ -58,17 +60,9 @@ static void message(FILE *output_fd, const char *prefix, const char *fmt, va_lis
        }
 
        /* Log to status bar */
-       if (&COMPACT && stdscr) {
-               int rev = COMPACT ? A_BOLD : 0;
+       if (&view_debug) {
                va_copy(tmp, ap);
-               if (!COMPACT)
-                       mvhline(LINES-2, 0, ACS_HLINE, COLS);
-               move(LINES-1, 0);
-               attron(COLOR_PAIR(COLOR_ERROR) | rev);
-               vwprintw(stdscr, fmt, tmp);
-               attroff(COLOR_PAIR(COLOR_ERROR) | rev);
-               if (!COMPACT)
-                       clrtoeol();
+               view_debug(fmt, tmp);
        }
 }
 
@@ -161,9 +155,6 @@ void error(char *fmt, ...)
        fflush(stderr);
        message(stderr, "error", fmt, ap);
        va_end(ap);
-       if (stdscr) {
-               getch();
-               endwin();
-       }
+       view_exit();
        exit(-1);
 }