]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_getch.c
ncurses 5.9 - patch 20140503
[ncurses.git] / ncurses / base / lib_getch.c
index 0a04ef5a6e1bf1728b98a2a14aa52b625f704879..53e2c05669655db469db7870511be88268688d5f 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2013 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -42,7 +42,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_getch.c,v 1.126 2013/02/16 18:30:37 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.130 2014/05/03 20:49:50 tom Exp $")
 
 #include <fifo_defs.h>
 
@@ -133,7 +133,16 @@ check_mouse_activity(SCREEN *sp, int delay EVENTLIST_2nd(_nc_eventlist * evl))
     int rc;
 
 #ifdef USE_TERM_DRIVER
-    rc = TCBOf(sp)->drv->testmouse(TCBOf(sp), delay EVENTLIST_2nd(evl));
+    TERMINAL_CONTROL_BLOCK *TCB = TCBOf(sp);
+    rc = TCBOf(sp)->drv->td_testmouse(TCBOf(sp), delay EVENTLIST_2nd(evl));
+# ifdef __MINGW32__
+    /* if we emulate terminfo on console, we have to use the console routine */
+    if (IsTermInfoOnConsole(sp)) {
+       HANDLE fd = (HANDLE) _get_osfhandle(sp->_ifd);
+       rc = _nc_mingw_testmouse(sp, fd, delay EVENTLIST_2nd(evl));
+    } else
+# endif
+       rc = TCB->drv->td_testmouse(TCB, delay EVENTLIST_2nd(evl));
 #else
 #if USE_SYSMOUSE
     if ((sp->_mouse_type == M_SYSMOUSE)
@@ -259,7 +268,7 @@ fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
     } else
 #endif
 #if USE_KLIBC_KBD
-    if (isatty(sp->_ifd) && sp->_cbreak) {
+    if (NC_ISATTY(sp->_ifd) && sp->_cbreak) {
        ch = _read_kbd(0, 1, !sp->_raw);
        n = (ch == -1) ? -1 : 1;
        sp->_extended_key = (ch == 0);
@@ -268,7 +277,14 @@ fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
     {                          /* Can block... */
 #ifdef USE_TERM_DRIVER
        int buf;
-       n = CallDriver_1(sp, read, &buf);
+#ifdef __MINGW32__
+       if (NC_ISATTY(sp->_ifd) && IsTermInfoOnConsole(sp) && sp->_cbreak)
+           n = _nc_mingw_console_read(sp,
+                                      (HANDLE) _get_osfhandle(sp->_ifd),
+                                      &buf);
+       else
+#endif
+           n = CallDriver_1(sp, td_read, &buf);
        ch = buf;
 #else
        unsigned char c2 = 0;