about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-11-25 17:43:04 +0000
committerJames Booth <boothj5@gmail.com>2012-11-25 17:43:04 +0000
commit529a31904cbc522f3dbe6c3227eec53fb47102bd (patch)
tree79d087330d2cc62d79f543ed74f3dafcc1712e34
parentb75256fffde3d80e8afb4529dbe28b7de68dd45f (diff)
parenta42ff49dab2d2b1c3ce8f74b4e490927df202185 (diff)
downloadprofani-tty-529a31904cbc522f3dbe6c3227eec53fb47102bd.tar.gz
Merge branch 'wheel'
-rw-r--r--configure.ac6
-rw-r--r--src/input_win.c2
-rw-r--r--src/windows.c43
3 files changed, 49 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index b7774c13..f6ff55ad 100644
--- a/configure.ac
+++ b/configure.ac
@@ -12,6 +12,12 @@ AM_INIT_AUTOMAKE([foreign subdir-objects])
 # Checks for programs.
 AC_PROG_CC
 
+# get canonical host
+AC_CANONICAL_HOST
+if test "$host_os" == "cygwin"; then
+    AC_DEFINE([PLATFORM_CYGWIN], [1], [Cygwin])
+fi
+
 # Options
 AC_ARG_WITH([libxml2],
     [AS_HELP_STRING([--with-libxml2], [link with libxml2 instead of expat])])
diff --git a/src/input_win.c b/src/input_win.c
index accfc687..55977706 100644
--- a/src/input_win.c
+++ b/src/input_win.c
@@ -417,7 +417,7 @@ static int
 _printable(const int ch)
 {
    return (ch != ERR && ch != '\n' &&
-            ch != KEY_PPAGE && ch != KEY_NPAGE &&
+            ch != KEY_PPAGE && ch != KEY_NPAGE && ch != KEY_MOUSE &&
             ch != KEY_F(1) && ch != KEY_F(2) && ch != KEY_F(3) &&
             ch != KEY_F(4) && ch != KEY_F(5) && ch != KEY_F(6) &&
             ch != KEY_F(7) && ch != KEY_F(8) && ch != KEY_F(9) &&
diff --git a/src/windows.c b/src/windows.c
index db444fa5..b705d9c4 100644
--- a/src/windows.c
+++ b/src/windows.c
@@ -108,6 +108,13 @@ gui_init(void)
     raw();
     keypad(stdscr, TRUE);
 
+#ifdef PLATFORM_CYGWIN
+    mousemask(BUTTON5_PRESSED | BUTTON4_PRESSED, NULL);
+#else
+    mousemask(BUTTON2_PRESSED | BUTTON4_PRESSED, NULL);
+#endif
+    mouseinterval(5);
+
     win_load_colours();
 
     refresh();
@@ -1816,8 +1823,42 @@ _win_handle_page(const int * const ch)
     int page_space = rows - 4;
     int *page_start = &(current->y_pos);
 
+    MEVENT mouse_event;
+
+    if (*ch == KEY_MOUSE) {
+        if (getmouse(&mouse_event) == OK) {
+
+#ifdef PLATFORM_CYGWIN
+            if (mouse_event.bstate & BUTTON5_PRESSED) { // mouse wheel down
+#else
+            if (mouse_event.bstate & BUTTON2_PRESSED) { // mouse wheel down
+#endif
+                *page_start += 4;
+
+                // only got half a screen, show full screen
+                if ((y - (*page_start)) < page_space)
+                    *page_start = y - page_space;
+
+                // went past end, show full screen
+                else if (*page_start >= y)
+                    *page_start = y - page_space;
+
+                current->paged = 1;
+                dirty = TRUE;
+            } else if (mouse_event.bstate & BUTTON4_PRESSED) { // mouse wheel up
+                *page_start -= 4;
+
+                // went past beginning, show first page
+                if (*page_start < 0)
+                    *page_start = 0;
+
+                current->paged = 1;
+                dirty = TRUE;
+            }
+        }
+
     // page up
-    if (*ch == KEY_PPAGE) {
+    } else if (*ch == KEY_PPAGE) {
         *page_start -= page_space;
 
         // went past beginning, show first page