#define NCURSES_OPAQUE 0
#endif
+/* PDCurses exposes its ncurses-compatible mouse API, the one this module uses,
+ only when this is defined before the curses header is included below.
+ Ignored by other curses implementations. */
+#ifndef PDC_NCMOUSE
+# define PDC_NCMOUSE
+#endif
+
#if defined(HAVE_NCURSESW_NCURSES_H)
# include <ncursesw/ncurses.h>
#elif defined(HAVE_NCURSESW_CURSES_H)
--- /dev/null
+Detect the :mod:`curses` mouse interface (:func:`~curses.getmouse`, the
+``BUTTON*`` constants, and others) with a configure capability probe or library
+macros instead of gating it on ncurses-specific macros. It is now also
+available with other curses implementations that provide it, such as NetBSD
+curses and PDCurses (the latter underpins ``windows-curses``).
"echochar");
}
-#ifdef NCURSES_MOUSE_VERSION
+#if defined(HAVE_CURSES_GETMOUSE) || defined(PDCURSES)
/*[clinic input]
_curses.window.enclose
}
#endif
-#ifdef NCURSES_MOUSE_VERSION
+#if defined(HAVE_CURSES_GETMOUSE) || defined(PDCURSES)
/*[clinic input]
_curses.getmouse
return PyCursesCheckERR(module, meta(stdscr, yes), "meta");
}
-#ifdef NCURSES_MOUSE_VERSION
+#if defined(HAVE_CURSES_GETMOUSE) || defined(PDCURSES)
/*[clinic input]
_curses.mouseinterval
SetDictInt("COLOR_CYAN", COLOR_CYAN);
SetDictInt("COLOR_WHITE", COLOR_WHITE);
-#ifdef NCURSES_MOUSE_VERSION
+#if defined(HAVE_CURSES_GETMOUSE) || defined(PDCURSES)
/* Mouse-related constants */
SetDictInt("BUTTON1_PRESSED", BUTTON1_PRESSED);
SetDictInt("BUTTON1_RELEASED", BUTTON1_RELEASED);
SetDictInt("BUTTON4_DOUBLE_CLICKED", BUTTON4_DOUBLE_CLICKED);
SetDictInt("BUTTON4_TRIPLE_CLICKED", BUTTON4_TRIPLE_CLICKED);
-#if NCURSES_MOUSE_VERSION > 1
+#ifdef BUTTON5_PRESSED
SetDictInt("BUTTON5_PRESSED", BUTTON5_PRESSED);
SetDictInt("BUTTON5_RELEASED", BUTTON5_RELEASED);
SetDictInt("BUTTON5_CLICKED", BUTTON5_CLICKED);
return return_value;
}
-#if defined(NCURSES_MOUSE_VERSION)
+#if (defined(HAVE_CURSES_GETMOUSE) || defined(PDCURSES))
PyDoc_STRVAR(_curses_window_enclose__doc__,
"enclose($self, y, x, /)\n"
return return_value;
}
-#endif /* defined(NCURSES_MOUSE_VERSION) */
+#endif /* (defined(HAVE_CURSES_GETMOUSE) || defined(PDCURSES)) */
PyDoc_STRVAR(_curses_window_getbkgd__doc__,
"getbkgd($self, /)\n"
#endif /* defined(getsyx) */
-#if defined(NCURSES_MOUSE_VERSION)
+#if (defined(HAVE_CURSES_GETMOUSE) || defined(PDCURSES))
PyDoc_STRVAR(_curses_getmouse__doc__,
"getmouse($module, /)\n"
return _curses_getmouse_impl(module);
}
-#endif /* defined(NCURSES_MOUSE_VERSION) */
+#endif /* (defined(HAVE_CURSES_GETMOUSE) || defined(PDCURSES)) */
-#if defined(NCURSES_MOUSE_VERSION)
+#if (defined(HAVE_CURSES_GETMOUSE) || defined(PDCURSES))
PyDoc_STRVAR(_curses_ungetmouse__doc__,
"ungetmouse($module, id, x, y, z, bstate, /)\n"
return return_value;
}
-#endif /* defined(NCURSES_MOUSE_VERSION) */
+#endif /* (defined(HAVE_CURSES_GETMOUSE) || defined(PDCURSES)) */
PyDoc_STRVAR(_curses_getwin__doc__,
"getwin($module, file, /)\n"
return return_value;
}
-#if defined(NCURSES_MOUSE_VERSION)
+#if (defined(HAVE_CURSES_GETMOUSE) || defined(PDCURSES))
PyDoc_STRVAR(_curses_mouseinterval__doc__,
"mouseinterval($module, interval, /)\n"
return return_value;
}
-#endif /* defined(NCURSES_MOUSE_VERSION) */
+#endif /* (defined(HAVE_CURSES_GETMOUSE) || defined(PDCURSES)) */
-#if defined(NCURSES_MOUSE_VERSION)
+#if (defined(HAVE_CURSES_GETMOUSE) || defined(PDCURSES))
PyDoc_STRVAR(_curses_mousemask__doc__,
"mousemask($module, newmask, /)\n"
return return_value;
}
-#endif /* defined(NCURSES_MOUSE_VERSION) */
+#endif /* (defined(HAVE_CURSES_GETMOUSE) || defined(PDCURSES)) */
PyDoc_STRVAR(_curses_napms__doc__,
"napms($module, ms, /)\n"
#ifndef _CURSES_ASSUME_DEFAULT_COLORS_METHODDEF
#define _CURSES_ASSUME_DEFAULT_COLORS_METHODDEF
#endif /* !defined(_CURSES_ASSUME_DEFAULT_COLORS_METHODDEF) */
-/*[clinic end generated code: output=728a704064bc8b85 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=945fcc1c41f2ffe7 input=a9049054013a1b77]*/
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ncurses-style curses function getmouse" >&5
+printf %s "checking for ncurses-style curses function getmouse... " >&6; }
+if test ${ac_cv_lib_curses_getmouse+y}
+then :
+ printf %s "(cached) " >&6
+else case e in #(
+ e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#define NCURSES_OPAQUE 0
+#if defined(HAVE_NCURSESW_NCURSES_H)
+# include <ncursesw/ncurses.h>
+#elif defined(HAVE_NCURSESW_CURSES_H)
+# include <ncursesw/curses.h>
+#elif defined(HAVE_NCURSES_NCURSES_H)
+# include <ncurses/ncurses.h>
+#elif defined(HAVE_NCURSES_CURSES_H)
+# include <ncurses/curses.h>
+#elif defined(HAVE_NCURSES_H)
+# include <ncurses.h>
+#elif defined(HAVE_CURSES_H)
+# include <curses.h>
+#endif
+
+int
+main (void)
+{
+MEVENT event; (void)getmouse(&event);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+ ac_cv_lib_curses_getmouse=yes
+else case e in #(
+ e) ac_cv_lib_curses_getmouse=no ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;;
+esac
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_getmouse" >&5
+printf "%s\n" "$ac_cv_lib_curses_getmouse" >&6; }
+if test "x$ac_cv_lib_curses_getmouse" = xyes
+then :
+
+printf "%s\n" "#define HAVE_CURSES_GETMOUSE 1" >>confdefs.h
+
+fi
CPPFLAGS=$ac_save_cppflags
fi
PY_CHECK_CURSES_FUNC([set_tabsize])
PY_CHECK_CURSES_VAR([ESCDELAY])
PY_CHECK_CURSES_VAR([TABSIZE])
+
+dnl Probe for the X/Open getmouse(MEVENT *) signature specifically: PDCurses
+dnl declares an incompatible getmouse(void) unless built for the ncurses mouse API.
+AC_CACHE_CHECK([for ncurses-style curses function getmouse],
+ [ac_cv_lib_curses_getmouse],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(_CURSES_INCLUDES, [MEVENT event; (void)getmouse(&event);])],
+ [ac_cv_lib_curses_getmouse=yes],
+ [ac_cv_lib_curses_getmouse=no])])
+AS_VAR_IF([ac_cv_lib_curses_getmouse], [yes],
+ [AC_DEFINE([HAVE_CURSES_GETMOUSE], [1],
+ [Define if you have the 'getmouse' function with the X/Open signature.])])
CPPFLAGS=$ac_save_cppflags
])dnl have_curses != no
])dnl save env
/* Define if you have the 'filter' function. */
#undef HAVE_CURSES_FILTER
+/* Define if you have the 'getmouse' function with the X/Open signature. */
+#undef HAVE_CURSES_GETMOUSE
+
/* Define to 1 if you have the <curses.h> header file. */
#undef HAVE_CURSES_H