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)
29 /* Debugging functions */
30 int debug(char *fmt, ...)
37 debug_fd = fopen("acal.log", "w+");
39 /* Log to debug file */
41 vfprintf(debug_fd, "debug: ", ap);
42 rval = vfprintf(debug_fd, fmt, ap);
44 /* Log to status bar */
46 mvhline(LINES-2, 0, ACS_HLINE, COLS);
48 attron(COLOR_PAIR(COLOR_ERROR));
49 vwprintw(stdscr, fmt, ap);
50 attroff(COLOR_PAIR(COLOR_ERROR));
58 int main(int argc, char **argv)
62 sigemptyset(&act.sa_mask);
64 act.sa_handler = on_sigint;
65 sigaction(SIGINT, &act, NULL);
66 act.sa_handler = on_sigwinch;
67 sigaction(SIGWINCH, &act, NULL);
76 mousemask(ALL_MOUSE_EVENTS, NULL);
77 init_pair(COLOR_TITLE, COLOR_GREEN, COLOR_BLACK);
78 init_pair(COLOR_ERROR, COLOR_RED, COLOR_BLACK);
87 if (getmouse(&btn) != OK)
92 //debug("mouse xyz=%d,%d,%d id=%hd state=%lx\n",
93 // btn.x, btn.y, btn.z, btn.id, btn.bstate);
101 screen_run(chr, btn.bstate, btn.y, btn.x);
106 /* Cleanup, see also on_sigint */