2 * Copyright (C) 2012 Andy Spencer <andy753421@gmail.com>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #define _POSIX_C_SOURCE 1
28 static FILE *debug_fd = NULL;
30 /* Control-C handler, so we don't hose the therminal */
31 static void on_sigint(int signum)
38 static void on_sigwinch(int signum)
46 /* Debugging functions */
47 int debug(char *fmt, ...)
54 debug_fd = fopen("lackey.log", "w+");
56 /* Log to debug file */
58 vfprintf(debug_fd, "debug: ", ap);
59 rval = vfprintf(debug_fd, fmt, ap);
61 /* Log to status bar */
63 mvhline(LINES-2, 0, ACS_HLINE, COLS);
65 attron(COLOR_PAIR(COLOR_ERROR));
66 vwprintw(stdscr, fmt, ap);
67 attroff(COLOR_PAIR(COLOR_ERROR));
75 int main(int argc, char **argv)
79 sigemptyset(&act.sa_mask);
81 act.sa_handler = on_sigint;
82 sigaction(SIGINT, &act, NULL);
83 act.sa_handler = on_sigwinch;
84 sigaction(SIGWINCH, &act, NULL);
93 mousemask(ALL_MOUSE_EVENTS, NULL);
94 init_pair(COLOR_TITLE, COLOR_GREEN, COLOR_BLACK);
95 init_pair(COLOR_ERROR, COLOR_RED, COLOR_BLACK);
103 if (chr == KEY_MOUSE)
104 if (getmouse(&btn) != OK)
109 //debug("mouse xyz=%d,%d,%d id=%hd state=%lx\n",
110 // btn.x, btn.y, btn.z, btn.id, btn.bstate);
118 screen_run(chr, btn.bstate, btn.y, btn.x);
123 /* Cleanup, see also on_sigint */