diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2017-11-01 12:35:41 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-11-01 12:35:41 (GMT) |
commit | ff6ae4de3874f4922a5883f08bb661c93834b060 (patch) | |
tree | 4f19cb9363c125dc7f91e180a58234b5ad05de9d /Modules | |
parent | 84e252b79eed94bc9e9175f82191322c89e489ad (diff) | |
download | cpython-ff6ae4de3874f4922a5883f08bb661c93834b060.zip cpython-ff6ae4de3874f4922a5883f08bb661c93834b060.tar.gz cpython-ff6ae4de3874f4922a5883f08bb661c93834b060.tar.bz2 |
bpo-25720: Fix the method for checking pad state of curses WINDOW (GH-4164) (#4212)
Modify the code to use ncurses is_pad() instead of checking WINDOW
_flags field. If your platform does not provide the is_pad(), the
existing way that checks the field will be enabled.
Note: This change does not drop support for platforms where do not
have both WINDOW _flags field and is_pad().
(cherry picked from commit 8bc7d63560024681dce9f40445f2877b2987e92c)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_cursesmodule.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index ec6316b..94c67c1 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -936,6 +936,12 @@ int py_mvwdelch(WINDOW *w, int y, int x) } #endif +#if defined(HAVE_CURSES_IS_PAD) +#define py_is_pad(win) is_pad(win) +#elif defined(WINDOW_HAS_FLAGS) +#define py_is_pad(win) ((win) ? ((win)->_flags & _ISPAD) != 0 : FALSE) +#endif + /* chgat, added by Fabian Kreutz <fabian.kreutz at gmx.net> */ static PyObject * @@ -1075,10 +1081,11 @@ PyCursesWindow_EchoChar(PyCursesWindowObject *self, PyObject *args) if (!PyCurses_ConvertToChtype(self, temp, &ch)) return NULL; -#ifdef WINDOW_HAS_FLAGS - if (self->win->_flags & _ISPAD) +#ifdef py_is_pad + if (py_is_pad(self->win)) { return PyCursesCheckERR(pechochar(self->win, ch | attr), "echochar"); + } else #endif return PyCursesCheckERR(wechochar(self->win, ch | attr), @@ -1607,10 +1614,10 @@ PyCursesWindow_NoOutRefresh(PyCursesWindowObject *self, PyObject *args) int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol; int rtn; -#ifndef WINDOW_HAS_FLAGS +#ifndef py_is_pad if (0) #else - if (self->win->_flags & _ISPAD) + if (py_is_pad(self->win)) #endif { switch(PyTuple_Size(args)) { @@ -1782,10 +1789,10 @@ PyCursesWindow_Refresh(PyCursesWindowObject *self, PyObject *args) int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol; int rtn; -#ifndef WINDOW_HAS_FLAGS +#ifndef py_is_pad if (0) #else - if (self->win->_flags & _ISPAD) + if (py_is_pad(self->win)) #endif { switch(PyTuple_Size(args)) { @@ -1851,9 +1858,10 @@ PyCursesWindow_SubWin(PyCursesWindowObject *self, PyObject *args) } /* printf("Subwin: %i %i %i %i \n", nlines, ncols, begin_y, begin_x); */ -#ifdef WINDOW_HAS_FLAGS - if (self->win->_flags & _ISPAD) +#ifdef py_is_pad + if (py_is_pad(self->win)) { win = subpad(self->win, nlines, ncols, begin_y, begin_x); + } else #endif win = subwin(self->win, nlines, ncols, begin_y, begin_x); |