[Python-checkins] bpo-39273: Expose BUTTON5_* constants in the curses module if available (GH-17996)
serhiy-storchaka
webhook-mailer at python.org
Thu Jan 14 04:40:36 EST 2021
https://github.com/python/cpython/commit/14cfa325c298ceb9eaf6b585a3cdcabf6c6378a9
commit: 14cfa325c298ceb9eaf6b585a3cdcabf6c6378a9
branch: master
author: Zackery Spytz <zspytz at gmail.com>
committer: serhiy-storchaka <storchaka at gmail.com>
date: 2021-01-14T11:40:09+02:00
summary:
bpo-39273: Expose BUTTON5_* constants in the curses module if available (GH-17996)
files:
A Misc/NEWS.d/next/Library/2020-01-13-23-37-58.bpo-39273.m5hzxV.rst
M Doc/library/curses.rst
M Doc/whatsnew/3.10.rst
M Modules/_cursesmodule.c
diff --git a/Doc/library/curses.rst b/Doc/library/curses.rst
index 26121acaacb7a..f55bb034b559b 100644
--- a/Doc/library/curses.rst
+++ b/Doc/library/curses.rst
@@ -220,11 +220,15 @@ The module :mod:`curses` defines the following functions:
multiple devices, and *x*, *y*, *z* are the event's coordinates. (*z* is
currently unused.) *bstate* is an integer value whose bits will be set to
indicate the type of event, and will be the bitwise OR of one or more of the
- following constants, where *n* is the button number from 1 to 4:
+ following constants, where *n* is the button number from 1 to 5:
:const:`BUTTONn_PRESSED`, :const:`BUTTONn_RELEASED`, :const:`BUTTONn_CLICKED`,
:const:`BUTTONn_DOUBLE_CLICKED`, :const:`BUTTONn_TRIPLE_CLICKED`,
:const:`BUTTON_SHIFT`, :const:`BUTTON_CTRL`, :const:`BUTTON_ALT`.
+ .. versionchanged:: 3.10
+ The ``BUTTON5_*`` constants are now exposed if they are provided by the
+ underlying curses library.
+
.. function:: getsyx()
diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst
index 7a51a9dbfb83a..7edc552d824ab 100644
--- a/Doc/whatsnew/3.10.rst
+++ b/Doc/whatsnew/3.10.rst
@@ -242,6 +242,10 @@ by :func:`curses.color_content`, :func:`curses.init_color`,
support is provided by the underlying ncurses library.
(Contributed by Jeffrey Kintscher and Hans Petter Jansson in :issue:`36982`.)
+The ``BUTTON5_*`` constants are now exposed in the :mod:`curses` module if
+they are provided by the underlying curses library.
+(Contributed by Zackery Spytz in :issue:`39273`.)
+
distutils
---------
diff --git a/Misc/NEWS.d/next/Library/2020-01-13-23-37-58.bpo-39273.m5hzxV.rst b/Misc/NEWS.d/next/Library/2020-01-13-23-37-58.bpo-39273.m5hzxV.rst
new file mode 100644
index 0000000000000..c942da07da377
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-01-13-23-37-58.bpo-39273.m5hzxV.rst
@@ -0,0 +1,2 @@
+The ``BUTTON5_*`` constants are now exposed in the :mod:`curses` module if
+available.
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index 7175c72296579..7ab68c78c3159 100644
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -4870,6 +4870,14 @@ PyInit__curses(void)
SetDictInt("BUTTON4_DOUBLE_CLICKED", BUTTON4_DOUBLE_CLICKED);
SetDictInt("BUTTON4_TRIPLE_CLICKED", BUTTON4_TRIPLE_CLICKED);
+#if NCURSES_MOUSE_VERSION > 1
+ SetDictInt("BUTTON5_PRESSED", BUTTON5_PRESSED);
+ SetDictInt("BUTTON5_RELEASED", BUTTON5_RELEASED);
+ SetDictInt("BUTTON5_CLICKED", BUTTON5_CLICKED);
+ SetDictInt("BUTTON5_DOUBLE_CLICKED", BUTTON5_DOUBLE_CLICKED);
+ SetDictInt("BUTTON5_TRIPLE_CLICKED", BUTTON5_TRIPLE_CLICKED);
+#endif
+
SetDictInt("BUTTON_SHIFT", BUTTON_SHIFT);
SetDictInt("BUTTON_CTRL", BUTTON_CTRL);
SetDictInt("BUTTON_ALT", BUTTON_ALT);
More information about the Python-checkins
mailing list