Okay, I'm going to get a linux box soon, I swear. However, in the mean time I'm still experimenting with curses. However the web seems short on example programs, so I've fiddled with the documentation and came up with a program that works. however, using PDCurses there have been certain things that don't uite match the documentation that I had to do. I expected it to look something like this:
Code:
#include <curses.h>
int main () {
int input;
MEVENT mouseinput;
initscr();
raw (); nodelay(stdscr,1); noecho(); curs_set(0); nonl(); keypad(stdscr,1);
mousemask (ALL_MOUSE_EVENTS, NULL);
mvprintw (0,30, "Press q to quit");
refresh();
do { // A nasty 100% resource hogging loop, I know. Sorry about that.
input = wgetch(stdscr);
if (input == KEY_MOUSE) {
getmouse (&mouseinput);
mvprintw (11, 30, " x = %d y = %d ", mouseinput.x, mouseinput.y);
mvaddch (mouseinput.y, mouseinput.x, 'X');
refresh ();
}
} while (input != 'q');
endwin ();
}
and instead I needed to tweak it and came up with:
Code:
#include <curses.h>
int main () {
int input;
MEVENT mouseinput;
initscr();
raw (); nodelay(stdscr,1); noecho(); curs_set(0); nonl(); keypad(stdscr,1);
mousemask (ALL_MOUSE_EVENTS, NULL);
mvprintw (0,30, "Press q to quit");
refresh();
do { // A nasty 100% resource hogging loop, I know. Sorry about that.
input = wgetch(stdscr);
nc_getmouse (&mouseinput); // nc_ is for NCurses compatability, I guess.
mvprintw (11, 30, " x = %d y = %d ", mouseinput.x, mouseinput.y);
// Aparently moving the mouse isn't a KEY_MOUSE event
if (input == KEY_MOUSE) { // KEY_MOUSE is only clicks, so an X will be drawn
mvaddch (mouseinput.y, mouseinput.x, 'X');
} // No refresh? Nope, works without it. Shouldn't, but it does.
} while (input != 'q');
endwin ();
}
So would anyone be willing to help me out here. Do these programs work in a linux environment and what tweaking was necessary to make it work. If it's too difficult to write mouse handling code that's cross-platform compatible I'll just have to forget about it.