#include "main.h"
#include "screen.h"
-/* Global data */
-int win_rows = 0;
-int win_cols = 0;
-
/* Static data */
-static WINDOW *win = NULL;
static FILE *debug_fd = NULL;
/* Control-C handler, so we don't hose the therminal */
exit(0);
}
-/* Window change */
-static void update(void)
-{
- getmaxyx(win, win_rows, win_cols);
- win_rows++;
- win_cols++;
- screen_draw();
-}
-
/* Window change */
static void on_sigwinch(int signum)
{
endwin();
refresh();
- update();
+ screen_draw();
}
/* Debugging functions */
{
int rval;
va_list ap;
+
+ /* Log to debug file */
va_start(ap, fmt);
vfprintf(debug_fd, "debug: ", ap);
rval = vfprintf(debug_fd, fmt, ap);
+
+ /* Log to status bar */
+ va_start(ap, fmt);
+ mvhline(LINES-2, 0, ACS_HLINE, COLS);
+ move(LINES-1, 0);
+ attron(COLOR_PAIR(COLOR_ERROR));
+ vwprintw(stdscr, fmt, ap);
+ attroff(COLOR_PAIR(COLOR_ERROR));
+ clrtoeol();
+
va_end(ap);
return rval;
}
debug("sigwinch error\n");
/* Curses setup */
- win = initscr();
+ initscr();
cbreak();
noecho();
+ keypad(stdscr, TRUE);
start_color();
curs_set(false);
+ mousemask(ALL_MOUSE_EVENTS, NULL);
+ init_pair(COLOR_TITLE, COLOR_GREEN, COLOR_BLACK);
+ init_pair(COLOR_ERROR, COLOR_RED, COLOR_BLACK);
screen_init();
/* Run */
while (1) {
+ MEVENT btn;
int chr = getch();
+ if (chr == KEY_MOUSE)
+ if (getmouse(&btn) != OK)
+ continue;
if (chr == 'q')
break;
+ if (KEY_MOUSE)
+ //debug("mouse xyz=%d,%d,%d id=%hd state=%lx\n",
+ // btn.x, btn.y, btn.z, btn.id, btn.bstate);
switch (chr) {
case 'L':
clear();
case 'l':
- update();
+ screen_draw();
break;
default:
- screen_run(chr);
+ screen_run(chr, btn.bstate, btn.y, btn.x);
break;
}
}