Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // gcc -o pointer pointer.c -static -lncurses -DNCURSES_STATIC
- #include <ncurses.h>
- int main() {
- // Initialize ncurses
- initscr();
- cbreak(); // Line buffering disabled
- noecho(); // Don't echo user input
- keypad(stdscr, TRUE); // Enable keypad mode
- // Enable mouse events
- mousemask(ALL_MOUSE_EVENTS, NULL);
- // Print instructions
- mvprintw(0, 0, "Move the mouse around the terminal window...");
- // Track mouse events
- while (1) {
- int ch = getch();
- if (ch == KEY_MOUSE) {
- MEVENT event;
- if (getmouse(&event) == OK) {
- // Print mouse event information
- mvprintw(2, 0, "Mouse event at (%d, %d)", event.x, event.y);
- refresh();
- }
- }
- // Exit on 'q' key press
- if (ch == 'q')
- break;
- }
- // Cleanup
- endwin();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement