1 #define _POSIX_C_SOURCE 1
11 static FILE *debug_fd = NULL;
13 /* Control-C handler, so we don't hose the therminal */
14 static void on_sigint(int signum)
21 static void on_sigwinch(int signum)
28 /* Debugging functions */
29 int debug(char *fmt, ...)
34 /* Log to debug file */
36 vfprintf(debug_fd, "debug: ", ap);
37 rval = vfprintf(debug_fd, fmt, ap);
39 /* Log to status bar */
41 mvhline(LINES-2, 0, ACS_HLINE, COLS);
43 attron(COLOR_PAIR(COLOR_ERROR));
44 vwprintw(stdscr, fmt, ap);
45 attroff(COLOR_PAIR(COLOR_ERROR));
53 int main(int argc, char **argv)
56 debug_fd = fopen("acal.log", "w+");
58 sigemptyset(&act.sa_mask);
60 act.sa_handler = on_sigint;
61 sigaction(SIGINT, &act, NULL);
62 act.sa_handler = on_sigwinch;
63 sigaction(SIGWINCH, &act, NULL);
72 mousemask(ALL_MOUSE_EVENTS, NULL);
73 init_pair(COLOR_TITLE, COLOR_GREEN, COLOR_BLACK);
74 init_pair(COLOR_ERROR, COLOR_RED, COLOR_BLACK);
83 if (getmouse(&btn) != OK)
88 //debug("mouse xyz=%d,%d,%d id=%hd state=%lx\n",
89 // btn.x, btn.y, btn.z, btn.id, btn.bstate);
97 screen_run(chr, btn.bstate, btn.y, btn.x);
102 /* Cleanup, see also on_sigint */