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, ...)
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 sigaction(SIGINT, &act, NULL);
63 act.sa_handler = on_sigwinch;
64 sigaction(SIGWINCH, &act, NULL);
73 mousemask(ALL_MOUSE_EVENTS, NULL);
74 init_pair(COLOR_TITLE, COLOR_GREEN, COLOR_BLACK);
75 init_pair(COLOR_ERROR, COLOR_RED, COLOR_BLACK);
84 if (getmouse(&btn) != OK)
89 //debug("mouse xyz=%d,%d,%d id=%hd state=%lx\n",
90 // btn.x, btn.y, btn.z, btn.id, btn.bstate);
98 screen_run(chr, btn.bstate, btn.y, btn.x);
103 /* Cleanup, see also on_sigint */