X-Git-Url: http://pileus.org/git/?p=lackey;a=blobdiff_plain;f=src%2Futil.c;h=1ebecfc02dae764fead047a08765eecbc4c0e3ca;hp=0d64fc4b2bb70598a4ccb26bb275a64f49d6385d;hb=569a0db79c00169e15d5abed2a82f28d1b2391c4;hpb=e1c3ab2bd61a81054b713f735fa31f827d258d76 diff --git a/src/util.c b/src/util.c index 0d64fc4..1ebecfc 100644 --- a/src/util.c +++ b/src/util.c @@ -20,20 +20,22 @@ #include #include +#include #include -#include #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) { @@ -45,6 +47,7 @@ static void message(FILE *output_fd, const char *prefix, const char *fmt, va_lis fprintf(output_fd, "%s: ", prefix); vfprintf(output_fd, fmt, tmp); fprintf(output_fd, "\n"); + fflush(output_fd); } /* Log to debug file */ @@ -53,20 +56,13 @@ static void message(FILE *output_fd, const char *prefix, const char *fmt, va_lis fprintf(debug_fd, "%s: ", prefix); vfprintf(debug_fd, fmt, tmp); fprintf(debug_fd, "\n"); + fflush(debug_fd); } /* 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); } } @@ -159,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); }