FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.15] gh-152502: Detect the curses mouse interface portably (GH-152705) by serhiy-storchaka · Pull Request #152707 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .ac  (1) .c  (1) .h  (2) .in  (1) .rst  (1) No extension  (1) All 6 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
7 changes: 7 additions & 0 deletions Include/py_curses.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@
#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)
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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``).
10 changes: 5 additions & 5 deletions Modules/_cursesmodule.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,7 @@ _curses_window_echochar_impl(PyCursesWindowObject *self, PyObject *ch,
return curses_window_check_err(self, rtn, funcname, "echochar");
}

#ifdef NCURSES_MOUSE_VERSION
#if defined(HAVE_CURSES_GETMOUSE) || defined(PDCURSES)
/*[clinic input]
@permit_long_summary
_curses.window.enclose
Expand Down Expand Up @@ -3532,7 +3532,7 @@ _curses_getsyx_impl(PyObject *module)
}
#endif

#ifdef NCURSES_MOUSE_VERSION
#if defined(HAVE_CURSES_GETMOUSE) || defined(PDCURSES)
/*[clinic input]
_curses.getmouse

Expand Down Expand Up @@ -4253,7 +4253,7 @@ _curses_meta_impl(PyObject *module, int yes)
return curses_check_err(module, meta(stdscr, yes), "meta", NULL);
}

#ifdef NCURSES_MOUSE_VERSION
#if defined(HAVE_CURSES_GETMOUSE) || defined(PDCURSES)
/*[clinic input]
_curses.mouseinterval

Expand Down Expand Up @@ -5685,7 +5685,7 @@ cursesmodule_exec(PyObject *module)
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);
Expand All @@ -5711,7 +5711,7 @@ cursesmodule_exec(PyObject *module)
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);
Expand Down
22 changes: 11 additions & 11 deletions Modules/clinic/_cursesmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions configure.ac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -7287,6 +7287,18 @@ PY_CHECK_CURSES_FUNC([set_escdelay])
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
Expand Down
3 changes: 3 additions & 0 deletions pyconfig.h.in
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@
/* 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

Expand Down
Loading

Back | FazBrowse Home | New Git URL