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)
17 debug("got sigint\n");
22 static void on_sigwinch(int signum)
29 /* Debugging functions */
30 int debug(char *fmt, ...)
35 /* Log to debug file */
37 vfprintf(debug_fd, "debug: ", ap);
38 rval = vfprintf(debug_fd, fmt, ap);
40 /* Log to status bar */
42 mvhline(LINES-2, 0, ACS_HLINE, COLS);
44 attron(COLOR_PAIR(COLOR_ERROR));
45 vwprintw(stdscr, fmt, ap);
46 attroff(COLOR_PAIR(COLOR_ERROR));
54 int main(int argc, char **argv)
57 debug_fd = fopen("acal.log", "w+");
59 sigemptyset(&act.sa_mask);
61 act.sa_handler = on_sigint;
62 if (sigaction(SIGINT, &act, NULL) < 0)
63 debug("sigint error\n");
64 act.sa_handler = on_sigwinch;
65 if (sigaction(SIGWINCH, &act, NULL) < 0)
66 debug("sigwinch error\n");
75 mousemask(ALL_MOUSE_EVENTS, NULL);
76 init_pair(COLOR_TITLE, COLOR_GREEN, COLOR_BLACK);
77 init_pair(COLOR_ERROR, COLOR_RED, COLOR_BLACK);
85 if (getmouse(&btn) != OK)
90 //debug("mouse xyz=%d,%d,%d id=%hd state=%lx\n",
91 // btn.x, btn.y, btn.z, btn.id, btn.bstate);
99 screen_run(chr, btn.bstate, btn.y, btn.x);
104 /* Cleanup, see also on_sigint */