/****************************************************************************
- * Copyright (c) 1998-2011,2012 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 *
#include <curses.priv.h>
-MODULE_ID("$Id: lib_getch.c,v 1.125 2012/08/04 17:11:37 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.131 2014/05/10 20:36:57 tom Exp $")
#include <fifo_defs.h>
return (sp ? sp->_use_meta : 0);
}
+#ifdef USE_TERM_DRIVER
+# ifdef __MINGW32__
+static HANDLE
+_nc_get_handle(int fd)
+{
+ intptr_t value = _get_osfhandle(fd);
+ return (HANDLE) value;
+}
+# endif
+#endif
+
/*
* Check for mouse activity, returning nonzero if we find any.
*/
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 = _nc_get_handle(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)
} 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);
{ /* 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,
+ _nc_get_handle(sp->_ifd),
+ &buf);
+ else
+#endif
+ n = CallDriver_1(sp, td_read, &buf);
ch = buf;
#else
unsigned char c2 = 0;
/* ungetch in reverse order */
#ifdef NCURSES_WGETCH_EVENTS
rc = recur_wgetnstr(win, buf);
- if (rc != KEY_EVENT)
+ if (rc != KEY_EVENT && rc != ERR)
safe_ungetch(sp, '\n');
#else
- (void) recur_wgetnstr(win, buf);
- safe_ungetch(sp, '\n');
+ if (recur_wgetnstr(win, buf) != ERR)
+ safe_ungetch(sp, '\n');
#endif
for (bufp = buf + strlen(buf); bufp > buf; bufp--)
safe_ungetch(sp, bufp[-1]);